3
从MultiOutputClassifier了解predict_proba
我正在scikit-learn网站上跟踪此示例,以使用随机森林模型执行多输出分类。 from sklearn.datasets import make_classification from sklearn.multioutput import MultiOutputClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.utils import shuffle import numpy as np X, y1 = make_classification(n_samples=5, n_features=5, n_informative=2, n_classes=2, random_state=1) y2 = shuffle(y1, random_state=1) Y = np.vstack((y1, y2)).T forest = RandomForestClassifier(n_estimators=10, random_state=1) multi_target_forest = MultiOutputClassifier(forest, n_jobs=-1) multi_target_forest.fit(X, Y).predict(X) print(multi_target_forest.predict_proba(X)) 由此predict_proba我得到2个5x2数组: [array([[ …