当前位置:网站首页>Matlab r2021b installing libsvm
Matlab r2021b installing libsvm
2022-07-08 01:49:00 【dgdqqxxx】
MATLAB R2021b install libsvm
Preface
processor :AMD Ryzen 9 5950X 16-Core Processor 3.40 GHz
operating system :Windows 10 pro
Version number :21H1
Internal version :19043.1645
MATLAB edition :2021b
One 、 Download and install libsvm
1、 download libsvm
libsvm Official website :https://www.csie.ntu.edu.tw/~cjlin/libsvm
I clicked the first two download links and didn't respond , Last of all github Connect downloaded
2、 decompression libsvm
Unzip the downloaded compressed package and copy it to MATLAB Installation directory toolbox Next
3、 Set up MATLAB route
Click Add and include subfolders , Choose the libsvm-master Folder , Click OK to automatically add the following subfolders
4、 Possible problems with compilation
stay matlab Enter... On the command line mex -setup -v Check the compiler in your computer
There was nothing
According to humble blog :https://blog.csdn.net/github_35807147/article/details/80725642
Install to MinGW64 Compiler (C++) For example :
1. First download and install TDM-GCC:
http://tdm-gcc.tdragon.net/download
2. It's better to install it in C Under the root directory , There should be no spaces in the directory , During installation, check Add to PATH, You don't need to configure environment variables later
3. stay MATLAB In the command line of :
setenv(‘MW_MINGW64_LOC’,‘C:\TDM-GCC-64’)
Then run the previous sentence
mex -setup -v
You can see the results in the figure below , Compilers already exist
5、 compile
take MATLAB Switch the current folder of to libsvm-master/matlab Catalog :
Input make And run
There are many warnings, but there are also four more files , It should be compiled successfully
Two 、 test
take Libsvm-master Test data set under folder heart_scale Copied to the Libsvm\matlab Next , Subsequent operations will be carried out under this folder , At the same time MATLAB The working path goes to the file
Then input :
[heart_scale_label,heart_scale_inst]=libsvmread('heart_scale');
model = svmtrain(heart_scale_label,heart_scale_inst) ;
[predict_label,accuracy,dec_values] = svmpredict(heart_scale_label,heart_scale_inst,model);
The results are as follows , The installation should have been successful
3、 ... and 、 Use tips
1、libsvm Standard format conversion tool
libsvm The data set format of is :
label 1: The eigenvalue 1 2: The eigenvalue 2…
Can use excel Realize standard format conversion , Baidu network disk link is as follows :
http://pan.baidu.com/s/1eSKebYU
DADADA Flying an airplane DATA Short book address of :LIBSVM And svm-train
excel Click menu bar view , macro —— View macro
Click on FormatDataFromLibsvm, perform , The data will be converted into the format of the label in the last column , As shown in the figure below :
Click on FormatDataToLibsvm Will convert the data into libsvm Standard format , As shown in the figure below :
After conversion, you can convert excel Save the contents of as txt file (excel There are two ways to save as txt Format , Text files are recommended ( System table segmentation ))
2、 Data normalization
SVM It is sensitive to data size , Generally, we need to normalize the features first , Such as shrinking to (0,1) Section , stay libsvm-3.23\windows Folder has one svm-scale.exe Implementation procedure of , The exe Double click file cannot be used . Need to be in windows cmd Running in ( Hold down windows+R, Input cmd that will do )
Will convert the good txt Copy the text to the directory , take cmd Adjust the inner path to this folder ( You can drag the folder directly cmd, Manual input too xxx It's long );
Also available at windows Press and hold under folder shift, Right click , Open here powershell window , Then the path is automatically in the current directory :
Input .\svm-scale.exe .\a.txt > a1.txt
There are spaces before and after the greater than sign
It can be seen that the default is normalized to (0,1) Section
3、 Training and forecasting
Normalize the good a1.txt File copy to libsvm-3.23\matlab Under the table of contents :
[lable,im]=libsvmread('a1.txt'); % Read the file
model=svmtrain(lable(1:8754),im(1:8754,:),'-s 4 -t 2 -c 1 -g 0.125'); % Training ( common 12505 Samples , Before the election 70% As a training set , namely 8754)
[prelabel,accuracy,decision_values]=svmpredict(lable(8755:12505),im(8755:12505,:),model); % forecast ( after 30% As test set , namely 8755-12505 strip )
The above is svm Simple use
4、 Find the best parameters
Need to install python and gnuplot; my python The version is 3.10;gnuplot Download the latest version gp543-win64-mingw.exe
gnuplot Official website address : http://www.gnuplot.info/ ( It's a tool for drawing , draw c and g Graph of automatic parameter seeking , The next installation is OK by default , After installation, check and easy.py Lidi 25 Whether the call path of the line is consistent )
Official website :
download :
Check whether the installation path is consistent
Open the command line , Input
python .\easy.py .\train.txt .\test.txt
train.txt and test.txt Training sets and test sets are stored separately ,easy.py Followed by the original test set and training set , I will normalize myself ; Running it will automatically call svmscale.exe grid.py svmtrain.exe svmpredict.exe , One simple step ; Will be output bestc and bestg and accuracy etc.
It will open automatically gnuplot drawing , Lycra , Close yourself after painting , Generate some intermediate files, as shown in the figure below .
The process of finding the best parameters is shown in the figure below :
Reference resources
MATLAB libsvm Installation and use
MATLAB Installation configuration libsvm( attach MinGW64 To configure )
LIBSVM And svm-train
边栏推荐
猜你喜欢
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
Remote Sensing投稿经验分享
About snake equation (2)
快速熟知XML解析
MATLAB R2021b 安装libsvm
能力贡献 GBASE三大解决方案入选“金融信创生态实验室-金融信创解决方案(第一批)”
From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
About snake equation (1)
Sword finger offer II 041 Average value of sliding window
Version 2.0 of tapdata, the open source live data platform, has been released
随机推荐
微软 AD 超基础入门
QT -- package the program -- don't install qt- you can run it directly
DataWorks值班表
ROS 问题(topic types do not match、topic datatype/md5sum not match、msg xxx have changed. rerun cmake)
The function of carbon brush slip ring in generator
Voice of users | winter goes and spring comes, waiting for flowers to bloom -- on gbase 8A learning comprehension
静态路由配置全面详解,静态路由快速入门指南
nacos-微服务网关Gateway组件 +Swagger2接口生成
About snake equation (3)
城市土地利用分布数据/城市功能区划分布数据/城市poi感兴趣点/植被类型分布
node js 保持长连接
Anaconda3 tutorial on installing and adding Tsinghua image files
Qt - - Packaging Programs - - Don't install Qt - can run directly
common commands
项目经理有必要考NPDP吗?我告诉你答案
php 获取音频时长等信息
powerbuilder 中使用线程的方法
break net
mysql/mariadb怎样生成core文件
Break algorithm --- map