Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(pROC)
- d<- data.frame(Titanic)
- d$Survived <- ifelse(d$Survived == "No", 0,1)
- m<- glm(Survived ~ Class+Sex+Age+Freq, data=d, family = binomial(link = "logit"))
- fitted.results <- predict(m,newdata=subset(d,select=c(1,2,3,5)),type='response')
- auc(d$Survived, fitted.results)
- ### unbalancing the data by converting y to 1 where freq is even( just a random condition)
- d$Survived_unbalanced <-ifelse(d$Freq %% 2 == 0,1,d$Survived)
- m_ub<- glm(Survived_unbalanced ~ Class+Sex+Age+Freq, data=d, family = binomial(link = "logit"))
- fitted.results_ub <- predict(m_ub,newdata=subset(d,select=c(1,2,3,5)),type='response')
- auc(d$Survived_unbalanced, fitted.results_ub)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement