-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.R
40 lines (34 loc) · 1.24 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(shiny)
shinyServer(function(input, output) {
output$text1 <- renderText(input$sex)
output$text2 <- renderText(input$ticketClass)
output$text3 <- renderText(input$embarked)
output$text4 <- renderText(input$age)
output$text5 <- renderText(input$parentChild)
output$text6 <- renderText(input$familySize)
train <- read.csv('titanicShiny_train.csv')
model <- glm(formula=Survived ~. , family = binomial(link = "logit"), data = train)
modelprob <- reactive({
sexInput <- input$sex
classInput <- input$ticketClass
embarkInput <- input$embarked
ageInput <- input$age
parchInput <- input$parentChild
fam.sizeInput <- input$familySize
dat <- data.frame('Pclass' = classInput, 'Sex' =factor(sexInput) , 'Age'=ageInput, 'Parch'=parchInput, 'Embarked'=factor(embarkInput),
'FSize.Category'=fam.sizeInput)
#predict(model, newdata=dat, type = "response")
fitted.prob <- predict(model, newdata=dat, type = "response")
fitted.prob
})
modelpred <- reactive({
fitted.pred <- ifelse(modelprob() > 0.5, "You Survived", "Sorry, you didn't make it")
fitted.pred
})
output$prob <- renderText({
modelprob()
})
output$pred <- renderText({
modelpred()
})
})