小编jc0*_*023的帖子

随机森林分类器决策路径法(scikit)

我已经在泰坦尼克号数据集上实现了一个标准的随机森林分类器,并希望探索 v0.18 中引入的 sklearn 的决策路径方法。( http://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html )

但是,它输出一个稀疏矩阵,我不确定如何理解。任何人都可以就如何最好地形象化这一点提出建议吗?

#Training a simplified random forest
estimator = RandomForestClassifier(random_state=0, n_estimators=3, max_depth=3)
estimator.fit(X_train, y_train)

#Extracting the decision path for instance i = 12
i_data = X_test.iloc[12].values.reshape(1,-1)
d_path = rf_best.decision_path(i_data)

print(d_path)
Run Code Online (Sandbox Code Playgroud)

输出:

(<1x3982 '' 类型的稀疏矩阵,以压缩稀疏行格式存储 598 个元素>, array([ 0, 45,
98, 149, 190, 233, 258, 309, 360, 401, 430, 42,5, 411 , 580, 623, 668, 711, 760, 803, 852, 889, 932, 981, 1006, 1035, 1074, 1107, 1136, 1165, 1146, 135, 120, 135, 125, 135, 120 …

python random-forest scikit-learn

5
推荐指数
1
解决办法
2345
查看次数

标签 统计

python ×1

random-forest ×1

scikit-learn ×1