解释scikit learn的决策树和随机林预测的包。
treeinterpreter的Python项目详细描述
解释scikit learn的决策树和随机林预测的包。 允许将每个预测分解为http://blog.datadive.net/interpreting-random-forests/中描述的偏差和特征贡献组件。对于具有n特性的数据集,数据集上的每个预测都分解为prediction = bias + feature_1_contribution + ... + feature_n_contribution。
它适用于scikit learn的
- 决策者
- 决策者助理
- ExtraTreeRegressor
- ExtraTreeClassifier
- 随机森林回归器
- 随机林分类器
- ExtraTreesRegressor
- ExtraTreesClassifier
免费软件:BSD许可证
依赖关系
- SCIKIT学习0.17+
安装
安装软件包的最简单方法是通过pip:
$ pip install treeinterpreter
用法
from treeinterpreter import treeinterpreter as ti # fit a scikit-learn's regressor model rf = RandomForestRegressor() rf.fit(trainX, trainY) prediction, bias, contributions = ti.predict(rf, testX)
预测是偏差和特征贡献的总和:
assert(numpy.allclose(prediction, bias + np.sum(contributions, axis=1))) assert(numpy.allclose(rf.predict(testX), bias + np.sum(contributions, axis=1)))
更多用法示例请参见http://blog.datadive.net/random-forest-interpretation-with-scikit-learn/。
历史记录
0.1.0(2015-07-22)
- pypi上的第一个版本。