运用了决策树相关知识
注意这里转换成字典的原因:因为特征中有分类
预估器参数entropy选择为信息增益
结果:
y_predict:
[0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0
0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 1
0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1
1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 0
0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0
0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0
0 1 1 1 0 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1]
直接比对真实值和预测值:
831 True
261 True
1210 True
1155 True
255 True
762 True
615 True
507 True
1175 True
301 True
1134 True
177 False
183 False
125 False
1093 True
1304 False
1124 True
798 False
1101 True
1239 False
1153 True
1068 False
846 True
148 True
478 True
642 True
1298 True
540 True
28 True
130 True
...
194 True
663 True
1209 True
117 False
595 False
1151 False
1143 True
1216 True
874 True
246 True
160 True
1208 True
682 True
307 True
67 True
961 True
400 True
923 False
866 True
134 True
613 True
242 True
320 False
829 True
94 True
1146 True
1125 False
386 True
1025 False
337 True
Name: survived, Length: 329, dtype: bool
准确率为:
0.7811550151975684