gpt4 book ai didi

python - “列表”对象不可调用以检查分数准确性?

转载 作者:行者123 更新时间:2023-12-04 09:29:57 25 4
gpt4 key购买 nike

我正在使用 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)

关于python - “列表”对象不可调用以检查分数准确性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62889449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com