필터 지우기
필터 지우기

Continuous loop in kmeans

조회 수: 2 (최근 30일)
Niraj Acharya
Niraj Acharya 2019년 9월 8일
댓글: Walter Roberson 2019년 9월 8일
I am trying to use kmeans for clustering and tried to run this code. But, my code goes on running continiously without giving output.
% As with previous examples, we will first read data from file.
data_train=readtable('household_power_consumption_2007.csv');
% However, we are considering data on sub meter readings only. So, we will select this information from the table.
data_to_cluster=[data_train.Sub_metering_1,data_train.Sub_metering_2,data_train.Sub_metering_3];
costs = [];
for i=1:100
rng(5);
[idx, C] = kmeans(data_to_cluster, i);
dist = 0;
for j=1:length(idx)
dist = dist + sum((C(idx(j), :) - data_to_cluster(j, :)).^2);
end
% dist = length(data_to_cluster)*log(dist/length(data_to_cluster)) + i*11*log(length(data_to_cluster));
% costs = [costs; dist];
end
  댓글 수: 3
Niraj Acharya
Niraj Acharya 2019년 9월 8일
Yeah it seems it is working. Thanks man. You are legend
Walter Roberson
Walter Roberson 2019년 9월 8일
So 100 is just taking a long time, rather than running without end. You might want to use waitbar() to show how far you have reached.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by