Matlab Liblinear安装及测试过程

Matlab Liblinear安装及测试过程

时间:2013-08-15 14:42来源:网络整理 作者:采集侠 点击: 60 次
Liblinear自带多种软件接口,本篇中使用的是Liblinear文件夹下的matlab文件夹中的内容,目的是将用C编
写的文件编译成
Liblinear自带多种软件接口,本篇中使用的是Liblinear文件夹下的matlab文件夹中的内容,目的是将用C编写的文件编译成matlab可调用的程序。

一、准备工作

Liblinear的下载地址~cjlin/liblinear/

我使用的是最新版本liblinear-1.93

matlab使用版本的是R2011b

 

二、Liblinear的安装过程

1.在matlab中设子路径。打开matlab,点击File->SetPath->Add withSubfolders,找到liblinear-1.93\matlab所在文件夹,点击save,点击close。

2.在matlab的command window中输入mex -setup,选择合适的编译器,具体如下(其中绿字部分是需要手动输入的,其他是自动生成的):

K>> mex -setup Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see Please choose your compiler for building MEX-files: Would you like mex to locate installed compilers [y]/n? Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011b\sys\lcc [2] Microsoft Visual C++ 2010 in F:\应用程序\VISUAL STUDIO [0] None Compiler: Please verify your choices: Compiler: Microsoft Visual C++ 2010 Location: F:\应用程序\VISUAL STUDIO Are these correct [y]/n? y*************************************************************************** Warning: MEX-files generated using Microsoft Visual C++ 2010 require that Microsoft Visual Studio 2010 run-time libraries be available on the computer they are run on. If you plan to redistribute your MEX-files to other MATLAB users, be sure that they have the run-time libraries. *************************************************************************** Trying to update options file: C:\Users\william\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2011b\bin\win32\mexopts\msvc100opts.bat Done . . . ************************************************************************** Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: ?solution=1-5C27B9 Building with the -largeArrayDims option enables the new API. **************************************************************************

 

3.修改当前路径。将matlab的current folder的目录该成liblinear-1.93\matlab所在文件夹

4.在matlab的command window中输入make,如果正确的话,会如下所示:

K>> make

在当前目录下生成下图中的文件

Matlab Liblinear安装及测试过程

特别是生成train.mexw32和predict.mexw32.

到这一步,Liblinear安装成功

三、在matlab中测试Liblinear是否能用

model = train(svm_category', sparseTrainMatrix)

[output_label, accuracy] = predict(svm_category', sparseTestMatrix, model);

train中参数:svm_category'为列向量,表示training set的class label,假设为n维

sparseTrainMatrix为n*m维矩阵,n表示training set中样本的个数,m表示每个样本中feature的个数

model的内容为

Matlab Liblinear安装及测试过程

predict中参数和train中取的类似,本例中直接把training set作为testing set重新预测了一下,model为train中输出的结构体

output_label输出的是testing set的class label的预测值

 accuracy是预测准确度

 


 

 


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值