How can the data be accurately clustered?

Greetings, I possess a dataset labeled as "Data," which encompasses four columns. Following this, I have employed the K-means algorithm to generate clusters, assigning the Cluster Value 6 to the variable "clusters" in the respective cells. Nevertheless, it has come to my attention that certain values within these clusters are inaccurately assigned to other clusters.
I am in need of guidance regarding the reassignment of clusters utilizing a specific algorithm. The ground truth is depicted in the attached image. I would greatly appreciate assistance with this endeavor.
disp('Calculating Centroid')
K=6;
[idx,C,sumdist] = kmeans(Data,K,'Display','final');
dataset=Data;
dataset_idx=zeros(length(dataset),5);
dataset_idx=dataset(:,1:4);
dataset_idx(:,5)=idx;
clusters = cell(K,1);
for i = 1:K
clusters{i} = dataset_idx(dataset_idx(:,5) == i,:);
end
cluster_assignments=idx;

7 Comments

I don't understand your ground truth image.
@Image Analyst Let me clarify the situation. In my original dataset, there is overlap. Specifically, in columns 2 and 4, I have different time values. For instance, in Cluster 1, I have times in Column 2, such as 1200e+03 and 1250e+03. Corresponding to these times in Column 4, I have a value of 30, which indicates that these times belong to Cluster 1. Similarly, each cluster has its own distinct time values. The values in columns 1 and 3 are dependent on the values in columns 2 and 4, and this dependency helps to form the clusters.
So cluster 1 can have times ranging from 30 to 1,250,000?
@Image Analyst Cluster 1 includes times ranging from 1,200,000 and 1,250,000 in Column 2. Corresponding to these times, Column 4 contains the value 30.
I'm sorry but this is just getting so confusing to me. You may have to wait for someone else who understands your problem better. How many actual features are there? Four? Three? Can't you just use masking to classify your observations based on known values? Like
class1Indexes = (data(:, 1) > 1200000) & (data(:, 1) < 1250000) & (data(:, 2) > 1200000) & (data(:, 2) < 1250000) & data(:, 4) == 30
@Image Analyst I believe I may not have communicated my requirement clearly earlier. Let me provide more detail:
I have four features in columns 1, 2, 3, and 4. My goal is to use machine learning or deep learning methods to cluster these values. For instance, I know that the ground truth of Cluster 1 has feature values of 1,200,000 and 1,250,000 in Column 2. Corresponding to these values, Column 4 contains the value 30.
The issue arises when using K-means clustering, as it often misclusters the results, as shown in the cluster cell. In such cases, we need to be able to reassign the clusters based on the feature values.
I have attached the file name clusters. in which each clusters is attached with specific value. Also you can see the groundTruth Image I am getting the following problem.
- Cluster 1:
- Represents correctly clustered values
- Cluster 2:
- Missing values: 1360, 1380
- Contains some values from Cluster 5 with column 4 values of 10, 20, 30, 40
- Cluster 3:
- Should only include values of 1250
- Includes values from Cluster 4 and Cluster 6 with values of 1200
- Values of 1230 with corresponding column 4 value of 20 are moved to Cluster 4
- Cluster 4:
- Contains values of 1230 with corresponding column 4 value of 20 from Cluster 3
- Cluster 5:
- Includes values from Cluster 2 with column 4 values of 10, 20, 30, 40
- Cluster 6:
- Contains only the 2nd column value of 1210
- Corresponding column 4 value of 10
As attached Image below. Please help me to solve this issue.
Ground Truth Image

Sign in to comment.

Answers (1)

Maybe clusterdata would be useful. It has lots of different algorithmic options you could try.

1 Comment

@Catalytic However, when using this clustering method, there are instances where it misclusters the results. In such cases, it becomes necessary to reassign the clusters based on the feature values. Could you assist me with this?

Sign in to comment.

Categories

Asked:

on 17 Feb 2024

Commented:

on 19 Feb 2024

Community Treasure Hunt

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

Start Hunting!