【发布时间】:2019-06-27 16:30:46
【问题描述】:
我有一个 numpy.ndarray 和 pandas DataFrame 类型的数组,需要一种方法来相互比较每个值。
以下是我尝试过的方法之一。我还使用pd.get(labels) 来提取值并返回None。 y_test 是一个 pandas 数据帧,preds 是一个 numpy 预测数组。
尝试将它们都转换为列表以及 numpy 数组进行比较:
sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy',
optimizer='adam',metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5, batch_size=2000)
preds = model.predict(x_test)
preds[preds>=0.5] = 1
preds[preds<0.5] = 0
print(type(preds))
print(y_test.get('labels'))
total = 0
for i in range(len(preds)):
if int(preds[i]) == y_test[i]:
total = total + 1
这就是我得到的 - TypeError: 'NoneType' object is not callable - KeyError: 0
【问题讨论】: