简体   繁体   English

如何设置LIBSVM Matlab界面?

[英]How to set up LIBSVM Matlab interface?

I am having problem with implementing LibSVM to MATLAB. 我在向MATLAB实现LibSVM时遇到问题。 I am using MATLAB R2009a (I also have the latest version, R2012b, but I dont use that one) I downloaded LibSVM package, libsvm-3.14 to my Windows 7 PC, which MATLAB and OCTAVE interface come together. 我正在使用MATLAB R2009a(我也有最新版本,R2012b,但我不使用那个)我将LibSVM软件包libsvm-3.14下载到我的Windows 7 PC,MATLAB和OCTAVE接口汇集在一起​​。

I extracted the folder I downloaded. 我解压缩了我下载的文件夹。 Which, below, you can see the printscreen of what the folder has in. 在下面,您可以看到该文件夹​​所包含的打印屏幕。 在此输入图像描述

Where should I put my libsvm-3.14 extracted folder ? 我应该把我的libsvm-3.14提取文件夹放在哪里? Should I put it under "bin" folder of my MATLAB installed in the directory? 我应该把它放在目录中安装的MATLAB的“bin”文件夹下吗?

C:\\Program Files\\MATLAB\\R2009a\\bin C:\\ Program Files \\ MATLAB \\ R2009a \\ bin

I did that, however, it didn't work out. 我做到了,然而,它没有成功。 I will be grateful if you help me clearly. 如果你帮我清楚,我将不胜感激。 I just read README file, but it's not clear to understand and there is no other instructions online on the internet. 我刚刚阅读了README文件,但目前还不清楚,互联网上没有其他在线说明。

For the time being, it does not matter where you put that folder. 目前,放置该文件夹的位置无关紧要。 You'll have to compile the Matlab-MEX files, from the source code that resides in the matlab subfolder of your extracted libsvm package. 您必须从驻留在提取的libsvm包的matlab子文件夹中的源代码编译Matlab-MEX文件。

Below, I will call the libsvm-3.14 (for example: C:\\libsvm-3.14) extracted folder ROOT (so replace ROOT wilth C:\\libsvm-3.14 below). 下面,我将调用libsvm-3.14(例如:C:\\ libsvm-3.14)提取的文件夹ROOT(所以在下面替换ROOT wilth C:\\ libsvm-3.14)。

So, fire up Matlab and, then, at its command prompt, type: 因此,启动Matlab,然后在其命令提示符下键入:

cd ROOT
cd matlab
make

Now, in the ROOT/matlab folder, you should have obtained two MEX files (with the .mexw32 or .mexw64 extension). 现在,在ROOT / matlab文件夹中,您应该已经获得了两个MEX文件(扩展名为.mexw32或.mexw64)。 These are the files that you will use from now on. 这些是您将从现在开始使用的文件。 You can discard the rest, except those files (and, maybe, some other generated libraries). 除了那些文件(以及其他一些生成的库)之外,你可以丢弃其余的文件。

According to the Makefile (that is ROOT/matlab/make.m), the MEX files are called svmtrain and svmpredic (+ the extension). 根据Makefile(即ROOT / matlab / make.m),MEX文件称为svmtrain和svmpredic(+扩展名)。

So, next step would be to create a subfolder called libsvm/ under your's Matlab/toolbox folder, copy the two MEX files therein and, then, add that libsvm/ folder to the Matlab Path (not the Path of your system, but of your Matlab installation). 因此,下一步是在你的Matlab / toolbox文件夹下创建一个名为libsvm /的子文件夹,将其中的两个MEX文件复制,然后将libsvm /文件夹添加到Matlab路径(不是系统的路径,而是你的Matlab安装)。

Then, by typing: 然后,键入:

svmtrain

and

svmpredict

you should have the help (usage) of these two functions. 你应该得到这两个功能的帮助(用法)。

With the aid of @axeoth, here is the solution. 在@axeoth的帮助下,这是解决方案。 I followed instruction files in matlab subfolder of extracted libsvm package. 我在提取的libsvm包的matlab子文件夹中跟踪了指令文件。 I downloaded and installed Microsoft Visual Studio 2010 and wrote 'mex -setup' on command window of MATLAB to choose a suitable compiler for mex (I use MATLAB R2012b in 32-bit PC, so I found supported compilers in this link http://www.mathworks.com/support/compilers/R2012b/win64.html ) After then, I followed @axeoth's instructions. 我下载并安装了Microsoft Visual Studio 2010,并在MATLAB的命令窗口中编写了'mex -setup',为mex选择合适的编译器(我在32位PC中使用MATLAB R2012b,所以我在这个链接中找到了支持的编译器http:// www.mathworks.com/support/compilers/R2012b/win64.html )之后,我按照@ axeoth的指示行事。 I changed the name of the folder to ROOT and moved it to Documents/MATLAB. 我将文件夹的名称更改为ROOT并将其移至Documents / MATLAB。 I started MATLAB and on command window, I wrote these below "one by one" 我启动了MATLAB并在命令窗口,我在下面“逐个”写下这些

>> cd C:\\Users\\HUstat\\Documents\\MATLAB\\ROOT\\matlab >> cd C:\\ Users \\ HUstat \\ Documents \\ MATLAB \\ ROOT \\ matlab
>> cd matlab >> cd matlab
>> make >>制作

then I copied everything obtained in ROOT/matlab subfolder. 然后我复制了在ROOT / matlab子文件夹中获得的所有内容。 I created a new folder named libsvm under MATLAB/toolbox folder and pasted everything there. 我在MATLAB / toolbox文件夹下创建了一个名为libsvm的新文件夹,并在那里粘贴了所有内容。 and then, I added that libsvm/ folder to the Matlab Path by using "Set Path" button on MATLAB R2012b. 然后,我使用MATLAB R2012b上的“Set Path”按钮将libsvm /文件夹添加到Matlab路径。 After then I wrote "svmtrain" and "svmpredict" so I got the helps of these two commands. 之后我写了“svmtrain”和“svmpredict”,所以我得到了这两个命令的帮助。

For those having major compiler problems I thought I'd leave some extra information on the subject of installing compilers. 对于那些有重大编译器问题的人,我想我会在安装编译器的主题上留下一些额外的信息。 This was a frustrating problem I had an ended up contacted MATLAB for help. 这是一个令人沮丧的问题,我最终联系了MATLAB寻求帮助。 I would have commented in the above posts but I do not have enough "rep" so here it is: 我会在上面的帖子中评论,但我没有足够的“代表”,所以这里是:

I was unable to install Microsoft Windows SDK 7.1, whether via Microsoft Visual Studio 2010 or otherwise. 我无法通过Microsoft Visual Studio 2010或其他方式安装Microsoft Windows SDK 7.1。 I found out that this was because I had a certain version of Microsoft Visual installed (version 10.0.04... was the cause of the problem for me). 我发现这是因为我安装了某个版本的Microsoft Visual(版本10.0.04 ......对我来说是问题的原因)。 The work around was to uninstall Visual, install SDK 7.1 independently and then re-install Visual after. 解决方法是卸载Visual,独立安装SDK 7.1,然后重新安装Visual。 The process is written up in greater detail in the link below: 该过程在以下链接中有更详细的说明:

http://www.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system http://www.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system

It may also be that you have the compiler installed but that it wasn't recognised until MATLAB "found" it. 也可能是你安装了编译器,但是在MATLAB“找到”之前它才被识别。 This happened to me after the re-install. 重新安装后,这发生在我身上。 To check if you have the correct compiler and "find" it run mex.getCompilerConfigurations('Any','Installed') to get a full list. 要检查您是否拥有正确的编译器并“查找”,请运行mex.getCompilerConfigurations('Any','Installed')以获取完整列表。 Then do mex -setup using the SDK 7.1 choosing the C/C++ version over FORTRAN. 然后使用SDK 7.1选择C / C ++版本而不是FORTRAN进行mex -setup。

I know the question is answered already but hopefully this may help someone the same predicament I had. 我知道这个问题已经得到了回答,但希望这可能会帮助我有同样的困境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM