A simple tutorial on the Quick start of SVM Toolbox _matlab

Source: Internet
Author: User
Tags rar svm

SVM Toolbox Quick Start Easy Tutorial (by Faruto)
Matlab with the function (Matlab Help file in the example) [only newer version of the MATLAB in the two SVM function]
=====
Svmtrain svmclassify
===== Brief grammar Rules = =
Svmtrain

Train Support Vector Machine classifier
Syntax

Svmstruct = Svmtrain (training, Group)

Svmstruct = Svmtrain (..., ' kernel_function ', Kernel_functionvalue, ...)
Svmstruct = Svmtrain (..., ' rbf_sigma ', Rbfsigmavalue, ...)
Svmstruct = Svmtrain (..., ' Polyorder ', Polyordervalue, ...)
Svmstruct = Svmtrain (..., ' mlp_params ', Mlp_paramsvalue, ...)
Svmstruct = Svmtrain (..., ' method ', Methodvalue, ...)
Svmstruct = Svmtrain (..., ' quadprog_opts ', Quadprog_optsvalue, ...)
Svmstruct = Svmtrain (..., ' smo_opts ', Smo_optsvalue, ...)
Svmstruct = Svmtrain (..., ' boxconstraint ', Boxconstraintvalue, ...)
Svmstruct = Svmtrain (..., ' Autoscale ', Autoscalevalue, ...)
Svmstruct = Svmtrain (..., ' showplot ', Showplotvalue, ...)
---------------------
Svmclassify

Classify data using support vector machine
Syntax

Group = Svmclassify (svmstruct, Sample)

Group = Svmclassify (svmstruct, Sample, ' Showplot ', showplotvalue)

============================ Case Study ====================
Load Fisheriris

% load of data from Matlab [information about the data can own to the UCI search, which is one of UCI's classic data], the data obtained are as follows:
Tu1

1.jpg (7.94 KB)

2009-5-12 19:50


Where MEAs is a 150*4 matrix representing 150 samples with 4 attribute descriptions per sample, species represents the classification of these 150 samples.

data = [MEAs (:, 1), MEAs (:, 2)];

% here only take the first and second columns of MEAs, that is, only the first two properties are selected.

Groups = IsMember (species, ' setosa ');

% because there are three categories in the species classification: Setosa,versicolor,virginica, in order to make the problem simple, we turn it into the two classification problem: Setosa and Non-setosa.

[Train, Test] = crossvalind (' holdout ', groups);
CP = Classperf (groups);

% randomly selected training set test set [about Crossvalind use please help yourself.]
The CP function was later used to evaluate the classifier.

Svmstruct = Svmtrain (data (train,:), groups (train), ' Showplot ', true);

% use Svmtrain for training, get the SVMSTRUCT structure after training, and use it when predicting.

Training results as shown:
Tu2

2.jpg (26.86 KB)

2009-5-12 19:50



Classes = svmclassify (svmstruct,data (test,:), ' Showplot ', true);

% for unknown test sets to predict, the result is as shown in figure:
Tu3

3.jpg (37.34 KB)

2009-5-12 19:50



Classperf (cp,classes,test);
Cp. Correctrate

Ans =

0.9867

% classifier effect evaluation, is to see the accuracy of the classification of test sets.


Two. LIBSVM Toolkit for Taiwan Lin Zhiren
The Toolbox downloads [libsvm-mat-2.86-1]: Libsvm-mat-2.86-1.rar (73.75 KB)

Libsvm-mat-2.86-1.rar (73.75 KB)
Download number of times: 373

2009-5-12 20:02


The installation method is also very simple, unzip the file, adjust the current working directory to the LIBSVM folder, and then add the LIBSVM folder to the set path. and then
Enter in the command line
Mex-setup% Select compiler
Make
That's it.
We recommend that you use the LIBSVM Toolbox, which is better with some. can be categorized [multiple categories], forecast ....
=========
Svmtrain
Svmpredict
================
Brief syntax:

Usage
=====

Matlab> model = Svmtrain (Training_label_vector, Training_instance_matrix [, ' libsvm_options ']);

-training_label_vector:
An m by 1 vector oftraining labels (type must is double).
-training_instance_matrix:
An m by n matrix of mtraining instances with n features.
It can be dense or sparse (type must is double).
-libsvm_options:
A string of trainingoptions in the same format as that of LIBSVM.

matlab> [Predicted_label, accuracy, decision_values/prob_estimates] =svmpredict (Testing_label_vector, Testing_ Instance_matrix, model [, ' libsvm_options ']);

-testing_label_vector:
An m by 1 vector ofprediction labels. If Labels of test
Data are unknown, simplyuse any random values. (Type must be double)
-testing_instance_matrix:
An m by n matrix of mtesting instances with n features.
It can be dense or sparse. (Type must be double)
-model:
The output of Svmtrain.
-libsvm_options:
A string of testing Optionsin the same format as that of LIBSVM.

Returned Model Structure
========================

Case study:

Load Heart_scale.mat

Data from the% Toolbox

As shown in figure:
Tu4

4.jpg (9.36 KB)

2009-5-12 20:08


Where Heart_scale_inst is a sample, Heart_scale_label is a sample label.

Model = Svmtrain (Heart_scale_label, Heart_scale_inst, '-C 1-g 0.07 ');

% training samples, specific parameters of the adjustment please see the Help file

[Predict_label, accuracy, dec_values] = svmpredict (heart_scale_label,heart_scale_inst, model);

% classification prediction, where the training set as a test set, the validation effect is as follows:
>> [Predict_label, accuracy, dec_values] = svmpredict (heart_scale_label,heart_scale_inst, model); % test the training data
accuracy = 86.6667% (234/270) (classification)


==============
This time I'm done with all the things that get me started with SVM, we can refer to the start, about the principle of SVM I have a simple ppt, is before the project I do [at that time I was responsible for the SVM code to achieve the explanation of what], interested in you can see, are used faster things, Want to learn more about SVM, your study of statistical learning theory or something .... Quite a lot of it.
Svm.ppt (391 KB)

Svm.ppt (391 KB)
Download number of times: 429

2009-5-12 20:18



-----------very good information about SVM and LIBSVM, want to study the SVM in detail to see this------
Libsvm_guide.pdf (194.53 KB)

Libsvm_guide.pdf (194.53 KB)
Download number of times: 186

2009-8-19 14:58


Libsvm_library.pdf (316.82 KB)

Libsvm_library.pdf (316.82 KB)
Download number of times: 137

2009-8-19 14:58


Optimizationsupportvectormachinesandmachine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.