値の一般化

9 visualizzazioni (ultimi 30 giorni)
Naoki Ishibashi
Naoki Ishibashi il 28 Ott 2016
Modificato: michio il 30 Ott 2016
以下のプログラムで値を一般化しクラスに分類しプロットしたですが、一般化がうまくできていいないようなのですが何かアドバイス頂けると幸いです。
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 Commenti
Image Analyst
Image Analyst il 28 Ott 2016
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 il 28 Ott 2016
「一般化」とはどういう処理のことでしょうか。 できれば回答者が現象を再現できる形でのコード・ファイルを提供していただいて、具体的にどううまくできていないのか、どういう結果を求めていらっしゃるのかを指示頂けますと回答も得られやすいかと思います。 お手数かとは思いますがよろしくお願いします。

Accedi per commentare.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by