In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to achieve matlab binary support vector machine to find many kinds of boundaries of the relevant knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
Load Iris dataset
Use the length and width of the petals
Load fisheriris
X = meas (:, 3:4)
Y = species
Scatter plot of%% data
Figure
Gscatter (X (:, 1), X (:, 2), Y)
H = gca
Lims = [h.XLim h.YLim]
Title ('{\ bf Scatter Diagram of Iris Measurements}')
Xlabel ('Petal Length (cm)')
Ylabel ('Petal Width (cm)')
Legend ('Location','Northwest')
% has three classes, one of which is linearly separable
%%
% do the following for each category:
Create a logical vector to indicate whether you are a member of this class or not
Use processed data and logic vectors to train SVM classifiers
Store classifier in cell array
It is better to define the order of categories in advance
SVMModels = cell (3jue 1)
Classes = unique (Y)
Rng (1)
For j = 1:numel (classes)
Indx = strcmp (Y classes (j))
Create a binary classifier for each category
SVMModels {j} = fitcsvm, [false true], 'Standardize',true,...
'KernelFunction','rbf','BoxConstraint',1)
End
%%
% | SVMModels | it is a cell array of 3X1
% each cell is a classifier
% the positive values of each classifier are setosa,versicolor and virginica
%% divides the distribution coordinates of the training data into grids and regards them as new observations.
% use each classifier to estimate the score of new observations
D = 0.02
[x1GridJournal x2Grid] = meshgrid (min (X (:, 1)): d:max (X (:, 1)),...
Min (X (:, 2)): d:max (X (:, 2))
XGrid = [x1Grid (:), x2Grid (:)]
N = size (xGrid,1)
Scores = zeros (N _ numel (classes))
For j = 1:numel (classes)
[~, score] = predict (SVMModels {j}, xGrid)
Scores (:, j) = score (:, 2)
The second column contains a positive category score
End
%% there are three scores for each row, and the largest one is the category corresponding to this line.
[~, maxScore] = max (Scores, [], 2)
%% shows the grid corresponding to each category in the figure
Figure
H (1:3) = gscatter (xGrid (:, 1), xGrid (:, 2), maxScore,...
[0.1 0.5 0.5; 0.5 0.1 0.5; 0.5 0.5 0.1])
Hold on
H (4:6) = gscatter (X (:, 1), X (:, 2), Y)
Title ('{\ bf Iris Classification Regions}')
Xlabel ('Petal Length (cm)')
Ylabel ('Petal Width (cm)')
Legend (h, {'setosa region','versicolor region','virginica region',...)
'observed setosa','observed versicolor','observed virginica'},...
'Location','Northwest')
Axis tight
Hold off
These are all the contents of the article "how to realize matlab binary support vector machine to find multi-class boundaries". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.