The code snippet is as follows:
>>> for c in np.arange(-5, 5):
... lr = LogisticRegression(C=np.int(10**c), random_state=0)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
ValueError: Integers to negative integer powers are not allowed.
>>>
To fix that error, the for block will be:
... lr = LogisticRegression(C=10**c, random_state=0)
...
>>>
本文介绍了一段Python代码在尝试使用整数进行负指数运算时出现的ValueError错误,并给出了修正方法,即将整数类型改为浮点数类型。
5162

被折叠的 条评论
为什么被折叠?



