MCPcopy Create free account
hub / github.com/antlr/codebuff / print_importance

Function print_importance

python/play/random_forest_on_token_features.py:7–18  ·  view source on GitHub ↗
(forest)

Source from the content-addressed store, hash-verified

5import sys
6
7def print_importance(forest):
8 importances = forest.feature_importances_
9 indices = np.argsort(importances)[::-1]
10 # Compute stddev of forest's feature importances over all trees
11 std = np.std([tree.feature_importances_ for tree in forest.estimators_], axis=0)
12 for f in range(X_training.shape[1]):
13 print "%d. feature %s col %d (%f, inter-tree variability=%f)" % \
14 (f + 1,
15 token_features[indices[f]],
16 indices[f],
17 importances[indices[f]],
18 std[indices[f]])
19
20def graph_importance(forest):
21 importances = forest.feature_importances_

Calls

no outgoing calls

Tested by

no test coverage detected