Saved classifier forgets its predict function
Show older comments
In a project I'm training several classifiers in Matlab 2020b, new data though should be processed in python 3.8. To do so I save the trained classifiers as .mat files (simply with "save(classifier_obj)").
In order to allow multiple users (without a matlab licence but with the runtime v9.9 installed) to use the classifiers I store these files as blob in a mysql DB (I know its not the best practice as stated here: https://de.mathworks.com/matlabcentral/answers/84154-storing-a-mat-file-in-mysql-database.).
When accessing, I download the blob file, store it temporaly on disc with these 2 lines in python and pass the file_name to the compiled matlab function (described below)
tmp = open(file_name, "wb")
tmp.write(mat)
In order to classify new data elements I've written this little function and compiled it as python code.
function label=new_classifier_predict(file_name,data)
load(file_name);
label=predict(classifier,data);
My problem now is that the classifier seems to forget its class method "predict"...
File C:\Users\steenbuck\AppData\Local\Temp\steenbuck\mcrCache9.9\new_cl0\new_classifi\classificators\new_classifier_predict.m, line 4, in new_classifier_predict
Method 'predict' is not defined for class 'ClassificationKNN' or is removed from MATLAB's search path.
I'm guessing that the object can't be reconstructed completly and therefore fails.. Strangely this error only occours when running the compiled python file. Matlab 2020b can handle all files as expected.
Is there a way to solve this or to debug and see whats happening the the matlab runtime environment?
1 Comment
Johannes Steenbuck
on 12 Jan 2021
Edited: Johannes Steenbuck
on 12 Jan 2021
Accepted Answer
More Answers (0)
Categories
Find more on Python Package Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!