【发布时间】:2020-04-05 12:30:51
【问题描述】:
我之前发布过类似的问题 (Categorical Data with tpot)。感谢 Randy,我能够让代码运行,但现在我在几个小时后停止了它,我收到了类似的错误:
File "XXXXXXXX", line 832, in score
if np.any(np.isnan(testing_features)):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
我不确定我是否错误地停止了它(我只是在 spyder 中按了 ctrl+c)还是有其他问题。我确保数据都是数字的,包括特征标题。知道可能是什么问题吗?
这是我正在运行的代码:
train_x, test_x, train_y, test_y=train_test_split(x,y)
train_x=pd.get_dummies(train_x).values
from tpot import TPOTRegressor
regressor=TPOTRegressor()
regressor.fit(train_x,train_y)
print(regressor.score(test_x,test_y))
我不知道如何显示训练和测试数组的内容。 train_x 是一个大小为 (2400,62) 的 float64,而 train_y 是一个 (2400,) 大小的系列。
【问题讨论】:
-
testing_features的类型是什么? -
如何找到变量的类型?它在 tpot 代码中。对不起,我是 python 新手。
-
那么,你能展示一下你用来调用导致错误的函数的代码吗?
-
是的,很抱歉。我完全忘记了那部分。我将编辑上面的帖子以包含我的代码。
-
哪一行导致错误? (编辑:我刚刚看到这是得分电话)。试试
print(type(test_x), type(test_y))。