値の一般化

8 次查看(过去 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 个)

Community Treasure Hunt

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

Start Hunting!

Translated by