python - H2O 变量对于模型中包含的所有离散级别的重要性

标签 python h2o

我想从给定模型的可变重要性的角度提取各个分类级别。下面提供的数据集中有几个分类预测变量,但是当我去计算特征重要性时,仅显示“整列”的重要性,而不是将重要性分解为诸如 C1_level0: important 之类的内容> 和C1_level1:重要性。如何查看列的重要性,就像我手动对这些离散级别进行单热编码时所看到的那样?

>>> import h2o
>>> h2o.init()
Checking whether there is an H2O instance running at http://localhost:54321. connected.
--------------------------  ----------------------------------------
H2O cluster uptime:         48 mins 24 secs
H2O cluster timezone:       America/Chicago
H2O data parsing timezone:  UTC
H2O cluster version:        3.20.0.5
H2O cluster version age:    6 days
H2O cluster name:           H2O_from_python_user_9znggm
H2O cluster total nodes:    1
H2O cluster free memory:    1.464 Gb
H2O cluster total cores:    8
H2O cluster allowed cores:  8
H2O cluster status:         locked, healthy
H2O connection url:         http://localhost:54321
H2O connection proxy:
H2O internal security:      False
H2O API Extensions:         XGBoost, Algos, AutoML, Core V3, Core V4
Python version:             3.6.5 final
--------------------------  ----------------------------------------
>>>
>>> df = h2o.create_frame(categorical_fraction=0.5)
Create Frame progress: |██████████████████████████████████████████████████████████████████████| 100%
>>>
>>> model = H2OGradientBoostingEstimator()
>>> model.train(x=[c for c in df.columns if c != 'C1'], y='C1', training_frame=df)
gbm Model Build progress: |███████████████████████████████████████████████████████████████████| 100%
>>>
>>> model.varimp(True)
  variable  relative_importance  scaled_importance  percentage
0       C3          4448.583984           1.000000    0.255125
1       C9          4424.002930           0.994474    0.253715
2       C6          4273.684082           0.960684    0.245094
3       C4          4249.320312           0.955207    0.243697
4      C10            12.800615           0.002877    0.000734
5       C7            12.022744           0.002703    0.000689
6       C8             8.271964           0.001859    0.000474
7       C2             4.649746           0.001045    0.000267
8       C5             3.567022           0.000802    0.000205

最佳答案

这是您在使用 model.std_coef_plot() 时可以通过 H2O 的 GLM 获得的结果,但是 model.varimp(True) 的预期行为是为您提供每个功能的重要性而不是各个级别的重要性。

如果您想了解个体水平与结果之间的关系,我建议使用 H2O 的部分依赖图(文档 herehere

关于python - H2O 变量对于模型中包含的所有离散级别的重要性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51863256/

相关文章:

python - 在 python3 中使用 os.walk 时文件读取不正确

python - Python 中的希伯来语文本

r - H2O.深度学习神经网络

r - 读取 100,000 个 .dat.gz 文件的最快方法

r - h2o.deeplearning 中的意外预测

python - 测试整数是否是切片的索引值

python - 打开终端,运行 python 脚本并保持打开状态以获得结果?

python - 在 matplotlib 中对齐 TeX 方程

python - 在python h2o模块中,如何在使用h2o.import_sql_select()导入数据时指定na_strings?

python - h2o ensemble 抛出错误 : "Base model does not keep cross-validation predictions"