Libsvm以二进制格式保存模型文件 [英] Libsvm save model file in binary format

查看:118
本文介绍了Libsvm以二进制格式保存模型文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为libsvm训练一个巨大的数据文件,结果训练文件太大.有什么方法可以将libsvm库模型文件保存为二进制格式?

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?

推荐答案

如果您使用的是Matlab: 下载 svm_savemodel.c

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');

如果您使用的是C ++: 有一个将模型保存到文件的功能:

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);

更多详细信息包含在 github 中.

More details are included in the github.

这篇关于Libsvm以二进制格式保存模型文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆