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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.