gpt4 book ai didi

python - 弄清楚如何在 sklearn 中编写逻辑回归模型

转载 作者:行者123 更新时间:2023-11-30 09:44:37 25 4
gpt4 key购买 nike

所以我正在尝试在 sklearn 中编写一个模型。我有维度为 (num_samples,65000,2) 的 xtrain 和维度为 (num_samples) 的 ytrain 的训练集。

我正在使用

clf = LogisticRegression(random_state=0, solver='lbfgs',
multi_class='multinomial').fit(xtrain, ytrain)

但是出现错误:

Found array with dim 3. Estimator expected <= 2.

任何人都可以建议我如何解决这个问题。

谢谢

最佳答案

该错误表明您正在传递 3d 数组,而您应该传递 2d 数组。

如果我们能看到您的数据,也许我们可以为您提供更多帮助。

这应该可以解决您的错误:

samples, x, y = xtrain.shape
new_dataset = xtrain.reshape((samples,x*y))

然后再次适应新数据集

关于python - 弄清楚如何在 sklearn 中编写逻辑回归模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54125939/

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