R中的glm输出预期为0和1

时间:2017-06-06 00:24:50

标签: r glm

我开始学习R,我正在玩Kaggle的Titanic数据集。当尝试对存活率进行逻辑回归时,我的期望为0和1?

PassengerId Survived    Pclass  Sex Age SibSp   Parch   Fare    Embarked    Title   FamSize FamSizeD    AgeRange
1   0   3   male    22  1   0   7.25    S   Mr  2   small   21-30
2   1   1   female  38  1   0   71.2833 C   Mrs 2   small   31-40
3   1   3   female  26  0   0   7.925   S   Miss    1   single  21-30
4   1   1   female  35  1   0   53.1    S   Mrs 2   small   31-40
5   0   3   male    35  0   0   8.05    S   Mr  1   single  31-40
6   0   3   male    28  0   0   8.4583  Q   Mr  1   single  21-30
7   0   1   male    54  0   0   51.8625 S   Mr  1   single  51-60
8   0   3   male    2   3   1   21.075  S   Master  5   large   0-20
9   1   3   female  27  0   2   11.1333 S   Mrs 3   small   21-30
10  1   2   female  14  1   0   30.0708 C   Mrs 2   small   0-20
logistix <- glm(Survived ~ Pclass + Sex + Embarked + Title + FamSizeD + AgeRange,
                data = train,
                family = 'binomial')

Prediction <- predict(logistix, test, type = "response")

Prediction

train

0 个答案:

没有答案