本文整理汇总了Python中sklearn.ensemble.RandomForestClassifier.compute_importances方法的典型用法代码示例。如果您正苦于以下问题:Python RandomForestClassifier.compute_importances方法的具体用法?Python RandomForestClassifier.compute_importances怎么用?Python RandomForestClassifier.compute_importances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.ensemble.RandomForestClassifier
的用法示例。
在下文中一共展示了RandomForestClassifier.compute_importances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: allClassifierPredictions
# 需要导入模块: from sklearn.ensemble import RandomForestClassifier [as 别名]
# 或者: from sklearn.ensemble.RandomForestClassifier import compute_importances [as 别名]
def allClassifierPredictions(kidCapsule):
decisionTree = DecisionTreeClassifier(max_depth=None, min_samples_split=1, random_state=0)
randomForest = RandomForestClassifier(n_estimators=50, max_depth=None, min_samples_split=1, random_state=0)
extraTrees = ExtraTreesClassifier(n_estimators=50, max_depth=None, min_samples_split=1, random_state=0)
gradientBoost = GradientBoostingClassifier(n_estimators=50, max_depth=1, learn_rate=1.0, random_state=0)
decisionTree.compute_importances = True
randomForest.compute_importances = True
extraTrees.compute_importances = True
gradientBoost.compute_importances = True
decisionTree.fit(kidCapsule.train_M, kidCapsule.trainLabels)
randomForest.fit(kidCapsule.train_M, kidCapsule.trainLabels)
extraTrees.fit(kidCapsule.train_M, kidCapsule.trainLabels)
gradientBoost.fit(kidCapsule.train_M, kidCapsule.trainLabels)
print decisionTree.feature_importances_
print randomForest.feature_importances_
print extraTrees.feature_importances_
print gradientBoost.feature_importances_
dt_pred = decisionTree.predict(kidCapsule.M)
rf_pred = randomForest.predict(kidCapsule.M)
et_pred = extraTrees.predict(kidCapsule.M)
gb_pred = gradientBoost.predict(kidCapsule.M)
#import pdb; pdb.set_trace()
return dt_pred, rf_pred, et_pred, gb_pred