svmtrain: how can I control plot color in svmtrain?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Takashi KOSHIMIZU
le 11 Fév 2019
Réponse apportée : Kenta
le 11 Fév 2019
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 commentaires
Réponse acceptée
Kenta
le 11 Fév 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 記述統計と可視化 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!