-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiris
More file actions
76 lines (62 loc) · 2.04 KB
/
iris
File metadata and controls
76 lines (62 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
summary(iris)
library(caret)
library(tidyr)
colnames(iris)<-c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width","Species")
head(iris)
index<-createDataPartition(iris$Species,p=0.80,list = FALSE)
testset<-iris[-index,]
trainset<-iris[index,]
dim(trainset)
str(trainset)
summary(trainset)
levels(as.factor(trainset$Species))
hist(trainset$Sepal.Width)
plot(trainset$Petal.Length,trainset$Petal.Width)
par(mfrow=c(1,4))
for (i in 1:4) {
boxplot(trainset[,i],main=names(trainset[i]))
}
library(ggplot2)
g<-ggplot(data=trainset,aes(x=Petal.Length,y=Petal.Width))
g <-g +
geom_point(aes(color=Species, shape=Species)) +
xlab("Petal Length") +
ylab("Petal Width") +
ggtitle("Petal Length-Width")+
geom_smooth(method="lm")
#h<-ggplot(data=trainset,aes(x=Sepal.Length,y=Sepal.Width))
#h <-h +
# geom_point(aes(color=Species, shape=Species)) +
# xlab("Sepal Length") +
# ylab("Sepal Width") +
# ggtitle("Sepal Length-Width")+
# geom_smooth(method="lm")
box<-ggplot(data = trainset,aes(y=Sepal.Length,x=Species))+
geom_boxplot(aes(fill=Species))+
ggtitle("Iris Boxplot") +
stat_summary(fun.y=mean, geom="point", shape=5, size=4)
box1<-ggplot(data = trainset,aes(y=Sepal.Width,x=Species))+
geom_boxplot(aes(fill=Species))+
ggtitle("Iris Boxplot") +
stat_summary(fun.y=mean, geom="point", shape=5, size=4)
library(ggthemes)
histogram<-ggplot(data = iris,aes(x=Sepal.Width))+
geom_histogram(binwidth = 0.2,color='black',aes(fill=Species))+
xlab('Sepal Width')+
ylab('frequency')+
ggtitle('hist of sepal width')+
theme_economist()
histogram1<-ggplot(data = iris,aes(x=Sepal.Length))+
geom_histogram(binwidth = 0.2,color='black',aes(fill=Species))+
xlab('Sepal Length')+
ylab('frequency')+
ggtitle('hist of sepal Length')+
theme_economist()
facet<-ggplot(data = trainset,aes(x=Sepal.Length,y=Sepal.Width,color=Species))+
geom_point(aes(shape=Species,size=1.5))+
geom_smooth(method = 'lm')+
xlab('Sepal Length')+
ylab('Sepal Width')+
ggtitle('facetting')+
theme_fivethirtyeight() +
facet_grid(. ~ Species)