- 29th Dec 2022
- 06:03 am
data<- read.csv(file = "C:\\Users\\dell\\Downloads\\GHQ1(2).csv")
library("ggplot2")
library("dplyr")
head(data)
View(data)
data_so2<-data%>%select(scap,city,year,e_so2_mean,e_so2_mean_r)
colSums(is.na(data_so2))
df<-na.omit (data_so2)
colSums(is.na(df))
df1<-df%>%select(year,e_so2_mean)%>%group_by(year)%>%summarise(me=mean(e_so2_mean))
ggplot(df1, aes(x=year, y=me)) +geom_line()
df2<-df%>%select(year,scap,e_so2_mean,city)%>%filter(scap=='1')
df3<-df2%>%select(year,e_so2_mean)%>%group_by(year)%>%summarise(me=mean(e_so2_mean))
ggplot(df3, aes(x=year, y=me)) +geom_line()
df4<-df%>%select(year,scap,e_so2_mean,city)%>%filter(scap=='0')
df5<-df2%>%select(year,e_so2_mean)%>%group_by(year)%>%summarise(me=mean(e_so2_mean))
ggplot(df5, aes(x=year, y=me)) +geom_line()
###############no2
df<-data%>%select(scap,city,year,e_no2_mean)
df<-na.omit (df)
df1<-df%>%select(year,e_no2_mean)%>%group_by(year)%>%summarise(me=mean(e_no2_mean))
ggplot(df1, aes(x=year, y=me)) +geom_line()
df2<-df%>%select(year,scap,e_no2_mean,city)%>%filter(scap=='1')
df3<-df2%>%select(year,e_no2_mean)%>%group_by(year)%>%summarise(me=mean(e_no2_mean))
ggplot(df3, aes(x=year, y=me)) +geom_line()
df4<-df%>%select(year,scap,e_no2_mean)%>%filter(scap=='0')
df5<-df2%>%select(year,e_no2_mean)%>%group_by(year)%>%summarise(me=mean(e_no2_mean))
ggplot(df5, aes(x=year, y=me)) +geom_line()
##############################33
library(caret)
df<-na.omit (data_so2)
set.seed(100)
training<-sample(1:nrow(df),0.70*nrow(df))
train<-df[training,]
test<-df[-training,]
nrow(train)
nrow(test)
glmod<-glm(scap~(e_so2_mean),data = train,family = "binomial")
summary(glmod)
library(prediction)
predict <- predict(glmod,test)
#confusion matrix
test$scap<-factor(test$scap)
levels(test$scap)<-levels(test$scap)
test$Dataoutput<-predict(glmod,test,type="response")
table(round(test$Dataoutput),test$scap)
xyz<-sum(diag(table(round(test$Dataoutput),test$scap)))/sum(table(round(test$Dataoutput),test$scap))
accuracy<-xyz*100
accuracy