I am trying to make an MLModel for use it on my app and I do it with python, since I wanna get confusion_matrix with evalute() func
here is my python code:
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
I tested all of them before and they work well , just when I run model.evaluate(test_data)
I got error
and My error is :
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'
I ran it on macosx highSierra (10.13.6)(cause my macbook is 2011 and I can't update it to 10.14) , python 3.6 (with conda) and I Installed turicreate via pip.
I realized it's a bug on turecreate 5.5 with python 3.6 (see this link) but when you try downgrade turicreate version to 5.4, it appears a new error that says : ‘map’ object is not subscriptable
it works well on version 5.1, so if you got this error , you should downgrade turicreate version to 5.1 and it works (thanks @MatthijsHollemans for helping me)
it solved on version 5.5.1 🙂
Note
Turi's group try to solve it on the next version ( you can see this card Error Image_Classifier )