Number of elements of clusters from dbscan

조회 수: 5 (최근 30일)
BHAGYALAKSHMI M
BHAGYALAKSHMI M 2020년 3월 8일
댓글: BHAGYALAKSHMI M 2020년 3월 9일
How to get the elements of clusters from a dbscan clustering.Like,
Clust1=[1,2,0.3,0.1....]
Clust2=[4,.....]
etc. How can I do that? Please help me.
Thank you.
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 3월 8일
Do you have a sample dataset for clustering?
BHAGYALAKSHMI M
BHAGYALAKSHMI M 2020년 3월 8일
Yes Sir. I attached here.

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 3월 8일
This example code read data from the excel file. Change column two from text to numeric and then apply dbscan clustering.
data=readtable('Liverxl.xlsx', 'ReadVariableNames', false);
data.Var2 = findgroups(data.Var2); % convert column
data.Var10(isnan(data.Var10)) = 0; % place 0 in empty cells
minpts=3;
epsilon=30;
data = table2array(data);
[idx, corepts] = dbscan(data,epsilon,minpts);
number_of_clusters = sum(unique(idx)>0);
% remove ouliers
core_data = data(corepts, :);
core_idx = idx(corepts);
% Clusters are saved in a cell array
clusters = splitapply(@(x) {x}, core_data, core_idx);
Tune the value of parameters, minpts and epsilon to change the size and number of elements in clusters.
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 3월 9일
clusters is a cell array. You can get elements of a cluster using following syntax:
clusters{1} % it will show all the element of first cluster
clusters{2} % 2nd cluster
...
...
clusters{end} % last cluster
BHAGYALAKSHMI M
BHAGYALAKSHMI M 2020년 3월 9일
Thank you Sir.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics 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