Ask Your Question

Revision history [back]

Load an SVM from a string in Python?

Is there a way to load a pre-trained SVM model from an XML string in Python? I am looking to use it on a platform that does not support an external file system, so the model must be saved as a string in the .py file itself.

These examples (1, 2) seem possible in C++; however, it doesn't appear that svm->read is exposed in Python.

Is there a workaround that would accomplish something similar in Python?

string yml; // the whole schlepp in a string
FileStorage fs;,FileStorage::READ|FileStorage::MEMORY);

string data_string; //containing xml/yml data
FileStorage fs( data_string, FileStorage::READ | FileStorage::MEMORY);; // or the node with your trainset