【发布时间】:2018-08-28 00:56:39
【问题描述】:
我正在尝试评估我的火车数据集:
评估培训
score = classifier.evaluate(X_test, y_test, verbose=1)
print("\nTest Results for {} test entries \
on which we did not trained the neural network.\n".format(len(X_test)))
print("Keras evaluation result:", score[0])
print("Percentage right: {}%.".format(score[1]*100))
print("Error: {}%.\n".format((1-score[1])*100))
def evaluate_model(classifier, X_test, y_test):
confusion_matrix = np.array([
[0, 0],
[0, 0]
])
pred = classifier.predict(X_train)
for i in range(len(pred)):
prediction = pred[i]
if prediction[0]>prediction[1]:
prediction = 1
else:
prediction = 0
expected = y_train[i][0]
confusion_matrix[prediction][expected] += 1
return confusion_matrix
confusion_matrix = evaluate_model(classifier, X_test, y_test)
confusion_matrix_interpretation = np.array([
["true negative", "false negative"],
["false positive", "true positive"]
])
print("Confusion matrix:")
print(confusion_matrix)
print("Confusion matrix, percentage of data:")
print(confusion_matrix*100/sum(confusion_matrix.flatten()))
print("Confusion matrix interpretation:\n", confusion_matrix_interpretation)
问题:对于大小为 1 的轴 0,索引 1 超出范围 可能的解决方案是什么。提前致谢
【问题讨论】:
-
IndexError: 索引 1 超出轴 0 的范围,大小为 1
-
你能分享你得到的错误的整个追溯吗?
标签: python tensorflow machine-learning keras artificial-intelligence