Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data <- gdata::read.xls("EDU408saID.xls")
- data <- data[,-1]
- data <- data[,-5]
- data <- data[,-6]
- attach(data)
- set.seed(77)
- ind <- sample(2, nrow(data), replace = TRUE, prob = c(0.7, 0.3))
- train <- data[ind==1,]
- test <- data[ind==2,]
- test_y <- data[ind==2,"GradePASS"]
- logistic_model <- glm(GradePASS ~ videos,data = train,family = "binomial")
- summary(logistic_model)
- logistic_probs <- predict(logistic_model, test, type = "response")
- head(logistic_probs)
- fix(logistic_probs)
- sort_probs <- sort(logistic_probs)
- logistic_pred_y = rep(0, length(test_y)) #stavimo da su sve vrijednosti FAIL
- logistic_pred_y[logistic_probs > 0.5] = 1 #gdje je >0.5 stavljamo PASS
- table(logistic_pred_y, test_y) # matrica konfuzije
- mean(logistic_pred_y != test_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement