svmtrain: how can I control plot color in svmtrain?
1 view (last 30 days)
Show older comments
svmtrainにより、サンプリングデータがグラフ表示されますが、
この際各データがプロットされる、色とマーカ種別を変更したいのですが、どの様にしたら良いでしょうか?
ご存知の方が一らっしゃいましたら、ご教授願いたいと存じます。ソース:svmtrain Matlab help
How can I change data plotting color and the marking type in the folloiwng svmtrain command?
------------------------------------------------------------------------------------------------------------------------
load fisheriris
xdata = meas(51:end,3:4);
group = species(51:end);
svmStruct = svmtrain(xdata,group,'ShowPlot',true);
------------------------------------------------------------------------------------------------------------------------
0 Comments
Accepted Answer
Kenta
on 11 Feb 2019
サンプルのデータをプロットしたい、ということで正しいでしょうか。gscatterという関数で、第一軸、第二軸、そのグループ名にそれぞれ相当する変数を入力していけば、添付のような図が得られます。groupのあとで、マーカーの色、その後で、マーカーのタイプを設定できます。色やマーカーはいろいろな種類があって、詳しくは、ここのページにあります。
なお、2018bなどの新しいバージョンでは、SVMの学習にはfitcsvm等を使わなければならず、私はsvmtrainを使用できませんでした。showplotをfalseにして、gscatterを使用すると、望む形のプロットが得られると思います。
clear;clc
load fisheriris
xdata = meas(51:end,3:4);
group = species(51:end);
figure
%'br'は色を表す、blueとred
%'xo'はマーカータイプを示す、x印と〇印
%数値ではなくグループ(カテゴリ)に関することはgscatterを使用
gscatter(xdata(:,1),xdata(:,2),group,'br','xo')
hold on
legend('versicolor','virginica')
%SVMの学習はfitcsvmなどが利用可能
svmStruct = fitcsvm(xdata,group);
0 Comments
More Answers (0)
See Also
Categories
Find more on 記述統計と可視化 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!