値の一般化

4 ビュー (過去 30 日間)
Naoki Ishibashi
Naoki Ishibashi 2016 年 10 月 28 日
編集済み: michio 2016 年 10 月 30 日
以下のプログラムで値を一般化しクラスに分類しプロットしたですが、一般化がうまくできていいないようなのですが何かアドバイス頂けると幸いです。
xfilename =('average.txt');
x = load(xfilename);
yfilename =('variarance.txt');
y = load(yfilename);
a=15;
rng default;
X = [x;y];
X = reshape(X,10368,2);
%NX = normc(X);
opts = statset('Display','final');
[idx,C] = kmeans(X,2,'Distance','cityblock','Replicates',5,'Options',opts);
plot(X(idx==1,1),X(idx==1,2),'r.','MarkerSize',12);
hold on;
plot(X(idx==2,1),X(idx==2,2),'b.','MarkerSize',12);
%plot(X(idx==3,1),X(idx==3,2),'g.','MarkerSize',12);
plot(C(:,1),C(:,2),'kx','MarkerSize',15,'LineWidth',3);
legend('Cluster 1','Cluster 2','Centroids','Location','NW');
title 'Cluster Assignments and Centroids';
hold off;
  2 件のコメント
Image Analyst
Image Analyst 2016 年 10 月 28 日
I don't know what the question is, but you forgot to attach 'average.txt' and 'variarance.txt' so we can't run your code.
michio
michio 2016 年 10 月 28 日
「一般化」とはどういう処理のことでしょうか。 できれば回答者が現象を再現できる形でのコード・ファイルを提供していただいて、具体的にどううまくできていないのか、どういう結果を求めていらっしゃるのかを指示頂けますと回答も得られやすいかと思います。 お手数かとは思いますがよろしくお願いします。

サインインしてコメントする。

採用された回答

michio
michio 2016 年 10 月 29 日
編集済み: michio 2016 年 10 月 29 日
平均を0、標準偏差を1に揃える処理でしたら、 normc 関数ではなくStatistics and Machine Learning Toolbox の関数 zscore を試してみてください。
NX = zscore(X);
X が行列の場合、Z は X と同じサイズの行列になり、Z の各列の平均が 0、標準偏差が 1 になります。
  2 件のコメント
Naoki Ishibashi
Naoki Ishibashi 2016 年 10 月 30 日
質問が明確でなく申し訳ありませんでした。 アドバイス頂いた関数でうまくいきました。ありがとうございます
michio
michio 2016 年 10 月 30 日
編集済み: michio 2016 年 10 月 30 日
細かいことを申しまして申し訳ございません。Accept頂きありがとうございます!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by