turicreate icon indicating copy to clipboard operation
turicreate copied to clipboard

'NearestNeighborClassifier' object has no attribute 'export_coreml'

Open johnlev opened this issue 6 years ago • 6 comments

I created a KNN model which works well, but the export_coreml function seems missing! Am I misunderstanding? Are KNN models not exportable?

johnlev avatar Dec 09 '17 21:12 johnlev

Thanks for trying out the KNN and letting us know that you're interested in exporting it to Core ML! Unfortunately, the KNN model is currently not supported in Core ML. I think that's currently the only classifier that is not supported, so hopefully you can find another model that suits your needs.

If you let us know what kind of model you are building, we might be able to give you a suggestion for another classifier that does support Core ML deployment.

gustavla avatar Dec 09 '17 22:12 gustavla

Thanks for trying out Turi Create. We will be working hard to make sure everything can be deployed. Currently, the list of deployable models are: https://apple.github.io/turicreate/docs/userguide/deployment/introduction.html

Could share with us what the distance function you are using? Is it the default one? That would really help us.

srikris avatar Dec 09 '17 22:12 srikris

I was using the default one, yes

johnlev avatar Dec 09 '17 22:12 johnlev

Is there any plan to make this exportable? Disappointed that it's not currently - would be extremely interested in having this exportable to CoreML - would also be good if the documentation clearly indicated this type of model isn't exportable.

rringham avatar Jan 08 '19 22:01 rringham

I understand why it is currently not supported. KNN is a method of classification that requires packing ALL (or most) of the training data into the model so inputs can be compared to the stored information. This makes it possibly the most heavy weight ML models out there, and it’s results can still be matched using Gaussian Bayesian classifiers, SVMs, and more. I would understand if Apple was not interested in exporting a model that might be larger than the destination app itself when a smaller model can be achieved using another method with just as accurate results (in most cases).

Thanks for all the help, but unless it is an intended upgrade for the future we can close this.

johnlev avatar Jan 10 '19 14:01 johnlev

I just ran into this issue, from looking at the documentation I thought it'd be possible to use turicreate to train and export the model, considering that it is listed in the docs:

I think it should be added as it'd make the ML toolset much more complete. I initially chose KNN because I have a relative small dataset. I tried first training KNN using SKLearn and using coremltools 4.0 to convert it to CoreML but the *.mlmodel was invalid. Failing that I tried to use turicreate directly to create the KNN model but seems like that might not be an option either.

triztian avatar Dec 02 '20 22:12 triztian