Saved classifier forgets its predict function
Mostrar comentarios más antiguos
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 comentario
Johannes Steenbuck
el 12 de En. de 2021
Editada: Johannes Steenbuck
el 12 de En. de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Python Package Integration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!