Sagemaker 中 XGBoost 的功能重要性 [英] Feature Importance for XGBoost in Sagemaker

查看:34
本文介绍了Sagemaker 中 XGBoost 的功能重要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Amazon Sagemaker 构建了一个 XGBoost 模型,但是我找不到任何可以帮助我解释模型并验证它是否学习到正确依赖项的东西.

I have built an XGBoost model using Amazon Sagemaker, but I was unable to find anything which will help me interpret the model and validate if it has learned the right dependencies.

通常,我们可以通过 python API 中的 get_fscore() 函数查看 XGBoost 的 Feature Importance (https://xgboost.readthedocs.io/en/latest/python/python_api.html) 我在 sagemaker api(https://sagemaker.readthedocs.io/en/stable/estimators.html).

Generally, we can see Feature Importance for XGBoost by get_fscore() function in the python API (https://xgboost.readthedocs.io/en/latest/python/python_api.html) I see nothing of that sort in the sagemaker api(https://sagemaker.readthedocs.io/en/stable/estimators.html).

我知道我可以构建自己的模型,然后使用 sagemaker 进行部署,但我很好奇是否有人遇到过这个问题以及他们是如何克服它的.

I know I can build my own model and then deploy that using sagemaker but I am curious if anyone has faced this problem and how they overcame it.

谢谢.

推荐答案

SageMaker XGBoost 目前不提供从模型中检索特征重要性的接口.您可以编写一些代码来从 XGBoost 模型中获取特征重要性.您必须从 S3 中的模型中获取 booster 对象工件,然后使用以下代码段

SageMaker XGBoost currently does not provide interface to retrieve feature importance from the model. You can write some code to get the feature importance from the XGBoost model. You have to get the booster object artifacts from the model in S3 and then use the following snippet

import pickle as pkl
import xgboost
booster = pkl.load(open(model_file, 'rb'))
booster.get_score()
booster.get_fscore()

请参阅 XGBoost 文档,了解从Booster 对象,例如 get_score()get_fscore().

Refer XGBoost doc for methods to get feature importance from the Booster object such as get_score() or get_fscore().

这篇关于Sagemaker 中 XGBoost 的功能重要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆