Assignment Task:
Task:
Problem Description:
Need Help Writing an Essay?
Tell us about your assignment and we will find the best writer for your paper.
Get Help Now!Program to perform Principal component analysis (PCA) on the dataset in R PROGRAM: a. Implement PCA on IRIS Dataset. Also compare our results by calculating eigenvectors and eigenvalues separately # Taking the numeric part of the IRIS data data_iris <- iris[1:4]
# Calculating the covariance matrix Cov_data <- cov(data_iris )
# Find out the eigenvectors and eigenvalues using the covariance matrix Eigen_data <- eigen(Cov_data) # Using the inbuilt function PCA_data <- princomp(data_iris ,cor=”False”)
# Let’s now compare the output variances Eigen_data$values PCA_data$sdev^2
# Compare the eigenvectors of both models. PCA_data$loadings[,1:4] Eigen_data$vectors summary(PCA_data) biplot (PCA_data) screeplot(PCA_data, type=”lines”)
# Fit two naive Bayes models. one over the entire data. The second on the first principal component. We will calculate the difference in accuracy between these two models. Building two models. #Select the first principal component for the second model model2 = PCA_data$loadings[,1] #For the second model, we need to calculate scores by multiplying our loadings with the data model2_scores <- as.matrix(data_iris) %*% model2
#Loading libraries for naiveBayes model library(class) library(e1071)
#Fitting the first model over the entire data mod1<-naiveBayes(iris[,1:4], iris[,5])
Welcome to Our Online Academic Writing Service. Our online assignment writing website provide various guarantees that will never be broken. No matter whether you need a narrative essay, 5-paragraph essay, persuasive essay, descriptive essay, or expository essay, we will provide you with quality papers at student friendly price.
Ask for Instant Writing Help. No Plagiarism Guarantee!
