我一直在混淆矩阵错误。我也遇到了表格功能错误
advertising <- read.csv('C:/Users/matpo/Desktop/advertising_1.csv', stringsAsFactors = TRUE)
LogMod <- glm(Clicked.on.Ad ~ Daily.Time.Spent.on.Site + Age + Area.Income, data=advertising, family=binomial(link="logit"))
predicted <- predict(LogMod, advertising, type="response")
#matrix below
glm.pred <- ifelse(predicted > 0.8, "click", "not_click")
table(glm.pred, Clicked.on.Ad)
confusionMatrix(glm.pred, advertising)
我得到的错误:
Error in table(glm.pred, Clicked.on.Ad) :
object 'Clicked.on.Ad' not found
> confusionMatrix(glm.pred, advertising)
Error: `data` and `reference` should be factors with the same levels.
您能指出我在哪里出错吗?