Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server = function(input,output){
- df = reactive({
- req(input$file1)
- read.csv(file = input$file1$datapath)
- })
- #Perform Regression
- output$prediction = renderTable({
- req(df())
- new_data_pre <- transform(df(),
- line_change_y = ifelse(line_change == "y", 1, 0),
- line_change_n = ifelse(line_change == "n", 1, 0),
- #
- touch_screen_y = ifelse(touch_screen == "y", 1, 0),
- touch_screen_n = ifelse(touch_screen == "n", 1, 0),
- #
- button_color_b = ifelse(button_color == "blue", 1, 0),
- button_color_g = ifelse(button_color == "green", 1, 0),
- button_color_o = ifelse(button_color == "orange", 1, 0),
- button_color_p = ifelse(button_color == "pink", 1, 0),
- button_color_r = ifelse(button_color == "red", 1, 0),
- button_color_v = ifelse(button_color == "violet", 1, 0),
- button_color_w = ifelse(button_color == "white", 1, 0),
- button_color_y = ifelse(button_color == "yellow", 1, 0),
- button_color_others = ifelse(button_color != "blue" &
- button_color != "green" &
- button_color != "orange" &
- button_color != "pink" &
- button_color != "red" &
- button_color != "violet" &
- button_color != "white" &
- button_color != "yellow", 1, 0),
- #
- auto_color_bk = ifelse(auto_color == "black", 1, 0),
- auto_color_b = ifelse(auto_color == "blue", 1, 0),
- auto_color_gd = ifelse(auto_color == "gold", 1, 0),
- auto_color_g = ifelse(auto_color == "green", 1, 0),
- auto_color_o = ifelse(auto_color == "orange", 1, 0),
- auto_color_p = ifelse(auto_color == "pink", 1, 0),
- auto_color_r = ifelse(auto_color == "red", 1, 0),
- auto_color_v = ifelse(auto_color == "violet", 1, 0),
- auto_color_w = ifelse(auto_color == "white", 1, 0),
- auto_color_y = ifelse(auto_color == "yellow", 1, 0),
- auto_color_another = ifelse(auto_color != "black" &
- auto_color != "blue" &
- auto_color != "gold" &
- auto_color != "green" &
- auto_color != "orange" &
- auto_color != "pink" &
- auto_color != "red" &
- auto_color != "violet" &
- auto_color != "white" &
- auto_color != "yellow", 1, 0),
- #
- Fruit_y = ifelse(Fruit == "y", 1, 0),
- Fruit_n = ifelse(Fruit == "n", 1, 0),
- #
- poker_y = ifelse(poker == "y", 1, 0),
- poker_n = ifelse(poker == "n", 1, 0),
- #
- BAR_y = ifelse(BAR == "y", 1, 0),
- BAR_n = ifelse(BAR == "n", 1, 0),
- #
- jewel_y = ifelse(jewel == "y", 1, 0),
- jewel_n = ifelse(jewel == "n", 1, 0),
- #
- type_v = ifelse(type == "video", 1, 0),
- type_c = ifelse(type == "classic", 1, 0),
- #
- type_of_image_c = ifelse(type_of_image == "cartoon", 1, 0),
- type_of_image_p = ifelse(type_of_image == "photo", 1, 0),
- #
- entertainer_y = ifelse(entertainer == "y", 1, 0),
- entertainer_n = ifelse(entertainer== "n", 1, 0),
- #
- TV_show_y = ifelse(TV_show == "y", 1, 0),
- TV_show_n = ifelse(TV_show== "n", 1, 0),
- #
- wild_type_m = ifelse(wild_type == "multi", 1, 0),
- wild_type_no = ifelse(wild_type == "no", 1, 0),
- wild_type_nor = ifelse(wild_type == "normal", 1, 0),
- wild_type_s = ifelse(wild_type == "stacked", 1, 0),
- wild_type_sm = ifelse(wild_type == "stack & multi", 1, 0),
- #
- stacked_symbol_y = ifelse(stacked_symbol == "y", 1, 0),
- stacked_symbol_n = ifelse(stacked_symbol == "n", 1, 0),
- #
- tumbling_y = ifelse(tumbling == "y", 1, 0),
- tumbling_n = ifelse(tumbling == "n", 1, 0),
- #
- # seasonal_event_12_y = ifelse(seasonal_event_12 == "y", 1, 0),
- # seasonal_event_12_n = ifelse(seasonal_event_12 == "n", 1, 0),
- #
- seasonal_event_y = ifelse(seasonal_event == "y", 1, 0),
- seasonal_event_n = ifelse(seasonal_event == "n", 1, 0),
- #
- spin_stop_y = ifelse(spin_stop == "y", 1, 0),
- spin_stop_n = ifelse(spin_stop == "n", 1, 0)
- #
- )
- new_data_pre <- subset(new_data_pre, select = colnames(raw_pre_rbind))
- new_data_pre <- subset(new_data_pre, select = -revenue)
- colnames(new_data_pre)
- colnames(raw_pre_rbind)
- normalizing <- function(x){
- (x-min(x))/(max(x)-min(x))
- }
- scale_info <- apply(raw_pre_rbind[1:34], 2, max)
- scale_info <- rbind(scale_info, apply(raw_pre_rbind[1:34], 2, min))
- scale_info <- as.data.frame(scale_info)
- class(scale_info)
- temp <- 0
- for(i in 1:34){
- if(i == 1){
- temp <- (new_data_pre[, i] - scale_info[2, i]) / (scale_info[1, i] - scale_info[2, i])
- }
- else{
- temp <- cbind(temp, (new_data_pre[, i] - scale_info[2, i]) / (scale_info[1, i] - scale_info[2, i]))
- }
- }
- colnames(temp) <- colnames(new_data_pre[1:34])
- new_data_pre_scaled <- cbind(temp, new_data_pre[, 35:87])
- prediction <- predict(load_model, as.matrix(new_data_pre_scaled[1:3, ]))
- plot.new()
- #plot(Actual$Class,type = "l",lty= 1.8,col = "red")
- lines(prediction, type = "l", col = "blue")
- plot(prediction,type = "l",lty= 1.8,col = "blue")
- predict_df = data.frame(Revenue = prediction)
- output_df = cbind(predict_df)
- return(output_df)
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement