How to get DBSCAN to assign the items to the clusters found

I have used DBSCAN on MATLAB R2021 to cluster my data into 3 groups. I want to be able to get DBSCAN to actually assign and name the clusters based on the items. I am not sure how this is done. Can anyone help please?
Thank You

5 commentaires

Can you elaborate on the issue you are facing? what property of the items do you want to be assigned as name for the cluster? Is it same for all the items belonging to a cluster?
Hi, thanks for responding to my question. I have discoverd 4 clusters within my data via dbscan clustering. I am not sure how to write a code to get the 4 clusters assigned to the groups. In the groups, I am supposed to have (Low Sulphur, High Sulphur, Very Low Sulphur, etc).
The data I used to generate my clusters was the spectra data from an NIR machine. I also have further information as regards the distribution of the data based on the sulphur content in an excel format elsewhere(this was not used in dbscan analysis)
I tried using a 'for loop' as shown below but the code does not seem to recognise the 'Spectra_50_1.spc' or any other 'Spectra...........' even though they were used without problems in the dbscan analysis ............ after normalizaton and with PCA (principal comp analysis) carried out on it.
for i=1:numel(data)
%if data{i}.Header.Filename == 'Spectra_50_1.spc'
gscatter(x(:,1),x(:,2),idx,'r','.','HighSulfur',10);
%hold on;
%else
%if data{i}.Header.Filename == 'Spectra_85_1.spc'
gscatter(x(:,1),x(:,2),idx,'g','.','Lowsulfur',10);
% end
%end
%end
So I have no clue on how to assign these groups based on the sulphur content.
Thanks a lot for your help.
Please attach your data.
Do not use == to compare character vectors. You can use == to compare string() objects, or to compare a string object and a character vector, but using == to compare character vectors only works if the two are compatible sizes (taking into account implicit expansion)
Character vectors are vectors -- for example 'abc' is the vector ['a', 'b', 'c'] . And when you compare vectors they need to be the same (or compatible) size. You should think of character vectors as being collections of character codes with an internal flag set that says to represent them specially on output. 'A1' is char([65 49]) and should be treated as if it is [65 49] (numeric) rather than being a phrase.
String objects on the other hand, treat entries as collections. ["abc", "hello"] is a 1 x 2 string object that internally is fairly similar to {'abc', 'hello'} in representation, but with added useful behaviour . String objects know that == means to compare the strings rather than the character codes.
To compare character vectors use strcmp() or strcmpi() or isequal() or (in some useful ways) ismember()
Thanks a lot for the detailed response,it was really helpful although they only seem to compare two objects while I have many signals within the file to compare to help dbscan algorithm to assign them into the clusters found.

Connectez-vous pour commenter.

 Réponse acceptée

Aditya Patil
Aditya Patil le 15 Juil 2021
As per my understanding, you have some data that you use for clustering, and some other corresponding data that you want to match to this data. For doing this, you rely on the data.Header.Filename attribute.
The likely issue here is that you need to use strcmp instead of “==”. Another issue might be that Filename has different values than you expect. For example, there might be case difference.

Plus de réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by