在使用sklearn.linear_model.SGDClassizer(随机状态值不同)进行逻辑回归时获得完全不同的权重值

2024-09-29 00:21:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我认为,权重应该随着随机状态的不同而略有变化。 随机_state=None时,每次跑步时获得不同权重的原因是什么

以下是几次运行的权重值(包含3个功能) 1)4.67100318,1.26129186,17.26554955 2)3.39793468,2.10265234,18.42484435 3)-2.08082186,1.25948975,10.37120852 4) 3.71122156,0.93510126,16.63007864

由于这种波动,我不确定应该使用哪种随机_状态,这在执行特征选择时造成了麻烦。 请注意,我是在执行标准化后使用数据的

我使用下面非常简单的代码来训练我的模型,因为我的数据只包含200行数据和3个特性

from sklearn.linear_model import SGDClassifier
SGDClf = SGDClassifier(loss='log',random_state=1)
SGDClf.fit(X,Y)

Tags: 数据代码from模型功能none状态原因
1条回答
网友
1楼 · 发布于 2024-09-29 00:21:26

Machine learning models will produce different results on same datasetrandom_state = None
模型生成一个称为random seed的随机数序列,用于从给定数据集生成测试、验证和训练数据集的过程,例如:random_state = 1
将模型种子配置为设定值将确保(权重)结果可重复。

SGDClassifier()洗牌输入的数据:

The passed (random state) value will have an effect on the reproducibility of the results returned by the function (fit, split, or any other function like k_means). - random state doc

希望对你有帮助

相关问题 更多 >