WEEK
WEEK
a)How to find a correlation matrix and plot the correlation on iris data set
library(corrplot)
b) Plot the correlation plot on dataset and visualize giving an overview of on iris
data.
library(ggplot2)
# Scatter plot
# Box plot
print(relation)
Call:
lm(formula = y ~ x)
Coefficients:
(Intercept) x
-42.0787 0.7046
print(summary(relation))
Call:
lm(formula = y ~ x)
Residuals:
1 2 3
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
print(summary(relation))
Call:
lm(formula = y ~ x)
Residuals:
1 2 3
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
print(predicted_y)
1 2 3
# Example dataset
data(mtcars)
summary(mylogit)
Call:
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
AIC: 24.588
data(mtcars)
coef(summary(model))
Estimate Std. Error t value Pr(>|t|)
anova(model)
Analysis of Variance Table
Response: mpg
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
WEEK – 9
install.packages("rpart.plot")
install.packages("tree")
install.packages("ISLR")
install.packages("rattle")
library(tree)
library(ISLR)
library(rpart.plot)
library(rattle)
summary(tree.fit)
Regression tree:
Distribution of residuals:
set.seed(123)
plot(trees)
text(trees, pretty = 0)
plot(prune.trees)
text(prune.trees, pretty = 0)
plot(yhat, test$Salary)
abline(0, 1)
library(cluster)
set.seed(20)
print(irisCluster)
K-means clustering with 3 clusters of sizes 52, 48, 50
Cluster means:
Petal.Length Petal.Width
1 4.269231 1.342308
2 5.595833 2.037500
3 1.462000 0.246000
Clustering vector:
[1] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
[46] 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1
[91] 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2
[136] 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2
Available components:
[1] "cluster" "centers" "totss" "withinss" "tot.withinss" "betweenss"
library(ggplot2)
geom_point() +
d <- dist(as.matrix(mtcars))
hc <- hclust(d)
library(cluster)
clusplot(pam(x, 2))
library(cluster)
clusplot(pam(x4, 2))