EL之DT&RF&GBT:基于三种算法(DT、RF、GBT)对泰坦尼克号乘客数据集进行二分类(是否获救)预测并对比各自性能
EL之DT&RF&GBT:基于三种算法(DT、RF、GBT)对泰坦尼克号乘客数据集进行二分类(是否获救)预测并对比各自性能
输出结果
设计思路
核心代码
vec = DictVectorizer(sparse=False)
X_train = vec.fit_transform(X_train.to_dict(orient='record'))
X_test = vec.transform(X_test.to_dict(orient='record'))
dtc.fit(X_train, y_train)
dtc_y_pred = dtc.predict(X_test)
rfc.fit(X_train, y_train)
rfc_y_pred = rfc.predict(X_test)
rfc.score(X_test, y_test)
classification_report(rfc_y_pred, y_test)
gbc.fit(X_train, y_train)
gbc_y_pred = gbc.predict(X_test)
gbc.score(X_test, y_test)
classification_report(gbc_y_pred, y_test)
赞 (0)