pouder-Man

first commit

No preview for this file type
No preview for this file type
df<-read.csv('result_4.csv')
tail(df,10)
set.seed(2)
id<-sample(2,nrow(df),prob = c(0.8,0.2), replace = TRUE)
train<-df[id==1,]
test<-df[id==2,]
tail(test,2)
library(C50)
model <- readRDS("./c5_model.rds")
prob <- predict(model, newdata = test[1:1, 1:126], type = "prob")
max1 <- 0
max2 <- 0
max3 <- 0
idx1 <- -1
idx2 <- -1
idx3 <- -1
for(i in 1:17){
if(max1 < prob[1:1,i:i]){
max3 <- max2
max2 <- max1
max1 <- prob[1:1,i:i]
idx3 <- idx2
idx2 <- idx1
idx1 <- i
}
else{
if(max2 <prob[1:1,i:i]){
max3 <- max2
max2 <- prob[1:1,i:i]
idx3 <- idx2
idx2 <- i
}
else{
if(max3 <prob[1:1,i:i]){
max3 <-prob[1:1,i:i]
idx3 <-i
}
}
}
}
library(ggplot2)
v <-c("51","54,51","56","56,51","56,54,51","59","59,51","59,56,51","59,56,54,51",
"61,51","61,54,51","61,56,51","61,56,54,51","61,59,51","61,59,54,51",
"61,59,56,51","61,59,56,54,51")
plot <- list(data.frame(idx=toString(v[idx1]),probability=max1),data.frame(idx=toString(v[idx2]),probability=max2),data.frame(idx=toString(v[idx3]),probability=max3))
newplot <- do.call(rbind,plot)
p <- ggplot(newplot,aes(idx,probability))+geom_bar(stat="identity",fill = "blue")
ggsave(file="~/bar_plot.png",plot=p,dpi=300)