Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. data <- gdata::read.xls("EDU408saID.xls")
  2.  
  3. data <- data[,-1]
  4. data <- data[,-5]
  5. data <- data[,-6]
  6. attach(data)
  7. set.seed(77)
  8.  
  9. ind <- sample(2, nrow(data), replace = TRUE, prob = c(0.7, 0.3))
  10. train <- data[ind==1,]
  11. test <- data[ind==2,]
  12. test_y <- data[ind==2,"GradePASS"]
  13.  
  14. logistic_model <- glm(GradePASS ~ videos,data = train,family = "binomial")
  15.  
  16. summary(logistic_model)
  17.  
  18. logistic_probs <- predict(logistic_model, test, type = "response")
  19.  
  20. head(logistic_probs)
  21.  
  22. fix(logistic_probs)
  23.  
  24. sort_probs <- sort(logistic_probs)
  25.  
  26. logistic_pred_y = rep(0, length(test_y)) #stavimo da su sve vrijednosti FAIL
  27.  
  28. logistic_pred_y[logistic_probs > 0.5] = 1 #gdje je >0.5 stavljamo PASS
  29.  
  30. table(logistic_pred_y, test_y) # matrica konfuzije
  31.  
  32. mean(logistic_pred_y != test_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement