Tugas Besar ML
Tugas Besar ML
REGRESI LOGISTIK
• selanjutnya
• nrow tes
<=50K >50K
7416 2352
> 9713/nrow(test)
[1] 0.9943694
> predict_LR<-predict(censusglm, newdata=test, type="response")
Error in predict(censusglm, newdata = test, type = "response") :
object 'censusglm' not found
> predict_LR<-predict(adultdataglm, newdata=test,
type="response") Warning message:
In predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == :
prediction from a rank-deficient fit may be misleading
> confusionmatrix_LR<- table(test$X, predict_LR > 0.5)
> accuracy_LR <-(confusionmatrix_LR[1,1] +
confusionmatrix_LR[2,2])/sum(confusionmatrix_ LR)
> accuracy_LR
[1] 0.8585176 >
library(ROCR)
Loading required package: gplots
lowess
Warning messages:
1: package ‘ROCR’ was built under R version 3.3.3
2: package ‘gplots’ was built under R version 3.3.3
> ROCRpred<- prediction(predict_LR, test$X)
> perf<- performance(ROCRpred, "tpr",
"fpr") > plot(perf)
> ROCRpred<- prediction(predict_LR, test$X)
> as.numeric(performance(ROCRpred, "auc")@y.values)as.numeric(performance(ROCRpred,
"auc ")@y.values)
Error: unexpected symbol in "as.numeric(performance(ROCRpred, "auc")@y.values)as.numeric
"
>