Example: For a number of students, given the specified height and weight and whether the makeup and hair length standard (0 for no make-up, make-up 1), which now gives a person the four indicators, allowing you to judge is male or female;
a1 matrix is given an initial value of the four indicators boys a1 = [178 60 4 0; 175 62 5 0; 168 60 3 0; 182 68 2 0];
a2 matrix is given an initial value of the four indicators girls a2 = [160 50 14 1; 162 52 15 1; 158 45 13 1; 155 40 12 1];
The first step: Merge matrix;
First obtains the number of rows of the two matrices: [m1, n1] = size (a1); [m2 n2] = size (a2);% m1, n1, m2, n2 are the number of rows of the matrix a1, the number of columns, m2, n2 are the number of lines a2 matrix, the number of columns.
data = [a1; a2]; data for the combined two matrices
Part II: Creating a sample labels;
lable = [zeros (m1,1); ones (m2,1)]; label tag for everyone, male is 0, 1 for girls.
The third step: machine learning;
xuexi = svmstrain (data, label);
This sentence is the machine learning law known data in order to determine the test data.
Step four: Test;
text data = [175 66 6 0; 32 12 162 1];
Step five: Print results;
[Jieguo jingdu] = svmclassify (xuexi, textdata);