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

查看:164
本文介绍了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的功能重要性(

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中的模型中获取增强器对象工件,然后使用以下代码段

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文档,以了解从助推器对象,例如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天全站免登陆