Showing
1 changed file
with
8 additions
and
9 deletions
1 | -df<-read.csv('result_4.csv') | 1 | +library('rjson') |
2 | -tail(df,10) | 2 | +args <- commandArgs(trailingOnly=TRUE) |
3 | -set.seed(2) | 3 | +json <- fromJSON(args) |
4 | -id<-sample(2,nrow(df),prob = c(0.8,0.2), replace = TRUE) | 4 | +path = json$path |
5 | -train<-df[id==1,] | 5 | + |
6 | -test<-df[id==2,] | 6 | +df<-read.csv(path) |
7 | -tail(test,2) | ||
8 | 7 | ||
9 | library(C50) | 8 | library(C50) |
10 | model <- readRDS("./c5_model.rds") | 9 | model <- readRDS("./c5_model.rds") |
11 | 10 | ||
12 | -prob <- predict(model, newdata = test[1:1, 1:126], type = "prob") | 11 | +prob <- predict(model, newdata = df[1:1, 1:126], type = "prob") |
13 | max1 <- 0 | 12 | max1 <- 0 |
14 | max2 <- 0 | 13 | max2 <- 0 |
15 | max3 <- 0 | 14 | max3 <- 0 |
... | @@ -49,4 +48,4 @@ v <-c("51","54,51","56","56,51","56,54,51","59","59,51","59,56,51","59,56,54,51" | ... | @@ -49,4 +48,4 @@ v <-c("51","54,51","56","56,51","56,54,51","59","59,51","59,56,51","59,56,54,51" |
49 | 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)) | 48 | 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)) |
50 | newplot <- do.call(rbind,plot) | 49 | newplot <- do.call(rbind,plot) |
51 | p <- ggplot(newplot,aes(idx,probability))+geom_bar(stat="identity",fill = "blue") | 50 | p <- ggplot(newplot,aes(idx,probability))+geom_bar(stat="identity",fill = "blue") |
52 | -ggsave(file="~/bar_plot.png",plot=p,dpi=300) | 51 | +ggsave(file="./bar_plot.png",plot=p,dpi=300) | ... | ... |
-
Please register or login to post a comment