I am training a huge data file for libsvm and the resulting training file is too large. Is there any way to save the libsvm libraries model file in binary format?
0
votes
1 Answers
1
votes
If you are using Matlab:
Download svm_savemodel.c and svm_model_matlab.c (this is already included in libsvm, you can try to use the original one, but if it doesn't work, try this link) to your libsvm dir. Compile the Mex file (mex svm_savemodel.c
), then it should work:
%save model model
fid = fopen('model.bin','w');
model = fwrite(fid, model, 'int16');
%load('model.mat');
fid = fopen('model.bin','rb');
model = fread(fid, model, 'int16');
svm_savemodel(model,'model.model');
If you are using C++: There is a function that saves a model to a file:
int svm_save_model(const char *model_file_name, const struct svm_model *model);
More details are included in the github.