Как получить выходные данные в приложении Riny для логистической регрессии на моих данных - PullRequest
0 голосов
/ 18 февраля 2019

Я пытаюсь создать блестящее приложение R, которое выполняет логистическую регрессию для входных данных и добавляет и добавляет столбец с его результатами к входным данным, входные данные состоят из четырех столбцов, а мой 5-й столбец является прогнозируемыми результатами.

Спасибо !!

Я новичок и пытаюсь выучить R и блестящее приложение R, я изменил и попробовал приведенный ниже код, который я скопировал из Fisseha Berhane https://datascience -enthusiast.com / R / блестящая_ML.html

В столбце результатов будет указано, что клиент в тренажерном зале выберет пакет на 1 месяц или 3 месяца.

library(caret)
library(shiny)
library(LiblineaR)
library(readr)
library(ggplot2)
load("C:/Users/Sampath/Desktop/PROJECT/LogisticRegression.rda")

shinyServer(function(input, output) {
    options(shiny.maxRequestSize = 800*1024^2)   
    output$sample_input_data_heading = renderUI({   
    inFile <- input$file1

    if (is.null(inFile)){
        return(NULL)
    }else{
        tags$h4('Sample data')
    }
  })

  output$sample_input_data = renderTable({    
      inFile <- input$file1

      if (is.null(inFile)){
          return(NULL)
      }else{
      input_data =readr::read_csv(input$file1$datapath, col_names = TRUE)

      colnames(input_data) = c("age", "Gender","height","weight","Label")

      input_data$Label = as.factor(input_data$Label )

      levels(input_data$Label) <- c("1","3")
      head(input_data)
    }
  })

  predictions<-reactive({

    inFile <- input$file1

    if (is.null(inFile)){
      return(NULL)
    }else{
      withProgress(message = 'Predictions in progress. Please wait ...', {
        input_data =  readr::read_csv(input$file1$datapath, col_names = TRUE)

        colnames(input_data) = c("age", "Gender","height","weight","Label")

        input_data$Label = as.factor(input_data$Label )
        input_data$age=as.integer(input_data$age)
        levels(input_data$Label) <- c("1","3")

        #mapped = feature_mapping(input_data)

        #df_final = cbind(input_data, mapped)
        prediction = predict(classifier,input_data[c(1:4)])

        input_data_with_prediction = cbind(input_data,prediction )
        input_data_with_prediction

      })
    }
  })


 output$sample_prediction_heading = renderUI({  
    inFile <- input$file1

    if (is.null(inFile)){
      return(NULL)
    }else{
      tags$h4('Sample predictions')
    }
  })

  output$sample_predictions = renderTable({ 
    predictions


  })

  })

  # Downloadable csv of predictions ----

  output$downloadData <- downloadHandler(
    filename = function() {
      paste("input_data_with_prediction", ".csv", sep = "")
    },
    content = function(file) {
      write.csv(predictions(), file, row.names = FALSE)
    })

})

Ожидаемый вывод - это 5-й столбец с прогнозируемыми результатами, но я продолжаю получать ошибки

error1: -объект 'X' не найден

error2: -не удается вызвать класс 'c ("реактивныйExpr", "реактивный") к data.frame

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...