gpt4 book ai didi

python - XGBoost算法: Feature importance change after renaming columns

转载 作者:行者123 更新时间:2023-11-30 09:15:20 28 4
gpt4 key购买 nike

我对我的数据运行了 XGBoost 算法,发现有 15 个特征很重要。我重命名了数据框中的列,然后再次运行相同的 XGBoost 算法,并注意到我的重要特征发生了变化。矩阵中的顺序稍微困惑,并且出现了 2-3 个新变量。基本上是相同的,但我想知道考虑到我只更改了列名称,可能会导致功能重要性发生这种变化。我使用树形来查找特征重要性,下面是我如何重命名列。

colnames = pd.read_csv("kbmg_colnames.csv")
d = dict(zip(colnames['Actual'], colnames['To be changed']))
Data_test = Data_test.rename(columns=d)

最佳答案

几乎每个机器学习算法都有一个 random_state。

random_state : int, RandomState instance or None, optional (default=None)

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

要在每次运行中获得相同的结果,您必须将其设置为某个数字:random_state=42。强烈建议每个 ML 任务都这样做。

Random state (Pseudo-random number) in Scikit learn

关于python - XGBoost算法: Feature importance change after renaming columns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57473183/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com