我正在尝试制作一个 MLModel 以在我的应用程序上使用它,并且我使用 python 来完成它,因为我想用 evalute() func 获得confusion_matrix
这是我的python代码:
import turicreate as tc
import matplotlib.pyplot as plt
import os
train_data = tc.image_analysis.load_images("snacks/train", with_path=True)
test_data = tc.image_analysis.load_images("snacks/test", with_path=True)
model = tc.image_classifier.create(train_data, target="label",
model="squeezenet_v1.1",
verbose=True, max_iterations=100)
metrics = model.evaluate(test_data) #Here is my Error
我之前测试了所有这些并且它们运行良好,只是当我运行时 model.evaluate(test_data)
出现错误
我的错误是:
AttributeError Traceback (most recent call last)
<ipython-input-48-56e8ce3f107f> in <module>
----> 1 model.evaluate(test_data)
~/anaconda3/envs/turienv/lib/python3.6/site-packages/turicreate/toolkits/image_classifier/image_classifier.py in evaluate(self, dataset, metric, verbose, batch_size)
798 vectors = map(lambda l: {'name': l, 'pos':list(sf_conf_mat[sf_conf_mat['target_label']==l].sort('predicted_label')['norm_prob'])},
799 labels)
--> 800 evaluation_result['sorted_labels'] = hclusterSort(vectors, l2Dist)[0]['name'].split("|")
801
802 # Get recall and precision per label
~/anaconda3/envs/turienv/lib/python3.6/site-packages/turicreate/toolkits/image_classifier/image_classifier.py in hclusterSort(vectors, dist_fn)
750 for vj in new_vec['members']:
751 total += dist_fn(vi, vj)
--> 752 distances.append({'from': v, 'to': new_vec, 'dist': total/len(v.get('members', [v]))/len(new_vec['members'])})
753
754 vecs.append(new_vec)
AttributeError: 'filter' object has no attribute 'append'
我在macosx highSierra(10.13.6)上运行它(因为我的macbook是2011,我无法将它更新到10.14),python 3.6(带有conda),我通过pip安装了turicreate。