输出结果
设计思路
核心代码
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)