我正在使用SVM创建一个模型。我想将分类器模型和使用的参数保存到excel和.json
文件中,然后打开该文件,查看所有.json
文件中的最佳模型。
然而,当我试图运行代码的第二部分时,我出现了这个错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-9fd85866127d> in <module>
88 for x in func:
89 count=count+1
---> 90 train_val(x[0],x[1],x[2],count)
91 end_time = time.time()
<ipython-input-4-9fd85866127d> in train_val(kernel, c, gamma, count)
43 scoring.append(score(y_test, predictions))
44 else:
---> 45 scoring.append(score(y_test, predictions,average='macro'))
46
47 # saving kernel that is used to the list
TypeError: 'list' object is not callable
我没有放任何带有单词'list'
的东西,所以它不应该被覆盖。是什么原因导致评分表无法计数?非常感谢。
创建列表:
accuracy = []
precision = []
recall = []
f1 = []
...
然后你定义分数来保存这些列表:
scores = [accuracy, precision, recall, f1]
然后迭代这些列表:
for score in scores:
...
但在这个循环中,你使用这些列表,就好像它们是函数一样:
score(y_test, predictions)