You are on page 1of 2

CSE3020 - Data Visualization

L3+L4
17BCE2049
LINGALA ANTHONY NIKHIL REDDY

##Anthony-17BCE2049
car=read.csv("/Users/anthony/Desktop/5th Sem/G2 - Data Visualisation/Lab/car.csv")
library(rpart)
library(rpart.plot)
library(dplyr)
library(ggplot2)
##Histogram
ggplot(data=car,aes(x=Present_Price))+geom_histogram()
ggplot(data=car,aes(x=Present_Price))+geom_histogram(bins=50)
ggplot(data=car,aes(x=Present_Price))+geom_histogram(bins=50,fill="palegreen4")
ggplot(data=car,aes(x=Present_Price))+geom_histogram(bins=50,fill="palegreen4",col="gre
en")
##Bar Graph
ggplot(data=car,aes(x=Present_Price,fill=Indian.Marble))+geom_histogram()
ggplot(data=car,aes(x=Present_Price,fill=Indian.Marble))+geom_histogram(fill="palegreen4"
,col="green")
#Barplot
ggplot(data=car,aes(x=Present_Price))+geom_bar()
ggplot(data=car,aes(x=Present_Price,fill=Area))+geom_bar()
ggplot(data=car,aes(x=Present_Price,fill=Area))+geom_bar(position="fill")
# Frequency Polygon
ggplot(data=car,aes(x=Present_Price))+geom_freqpoly()
ggplot(data=car,aes(x=Present_Price))+geom_freqpoly(bins=10)
ggplot(data=car,aes(x=Present_Price,col=Area))+geom_freqpoly(bins=10,fill="palegreen4",c
ol="red")
# Boxplot9
#Smooth-Line
ggplot(data=car,aes(y=Present_Price,x=Area))+geom_smooth()

#Faceting
ggplot(data=car,aes(y=Present_Price,x=Area,col=Area))+geom_point()+geom_smooth(meth
od="lm",se=F
)

#Decision Tree
dim(car)
s<-sample(150,100)
s
car_train <- car[s,]
car_test <- car[-s,]
dim(car_test)
dim(car_train)
dtm<- rpart(Species~., car_train, method="class")
dtm
plot(dtm)
text(dtm)
rpart.plot(dtm)
?rpart.plot
rpart.plot(dtm,type=4 ,extra=101)
p<-predict (dtm,car_test, type="class")
table(car_test[,5],p)

You might also like