Question

1. Implement the K-means algorithm using these two as a reference.

274 14 Unsupervised Lnn Fig. 14.1 A two-dimensional domain with clusters of examples weight bot

initial clustering in a wrong cluster .. examples centers in a wrong cluster now: all examples in correct clusters After the

2.Use Matlab’s implementation of kmeans to check your results on the fisheriris dataset (https://www.mathworks.com/help/stats/kmeans.html)

a. The fisheriris dataset is built into Matlab, and you can load it using ‘load fisheriris’.

b. Please note the labels are available for the dataset, so you can check the performance of the kmeans algorithm on the dataset.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

k-means clustering  :

Then plot the cluster regions.

Load Fisher's iris data set. Use the petal lengths and widths as predictors.

load fisher iris
X = meas(:,3:4);
plot(X(:,1),X(:,2),'k*','MATH SIZE',5);
title 'Fisher''s Iris Data';
X label Petal Lengths (cm); 
Y label Petal Widths (cm);

Fishers Iris Data 2.5 1.5 0.5 4 5 6 Petal Lengths (cm)

The larger cluster to be split into a lower variance region and a higher variance region. This might indicate that the larger cluster is two overlapping clusters.

Cluster k=3

k means (X,3);
  1.   k-means++ algorithm for centroid initialization
  2. squared Euclidean distance
  3. Local by setting the 'Replicates' name-value pair argument.
  4. means displays a warning stating that the algorithm did not converge, which you should expect since the software only implemented one iteration.

    Plot the cluster regions.

  5. gs catter(X Grid(:,1),X Grid(:,2),

  6. id x2 Region,... [0,0.75,0.75;0.75,0,0.75;0.75,0.75,0],'..');

  7. k*('Marker Size',5);

  8. title 'Fisher''s Iris Data'; X label Petal Lengths (cm);

  9. Y label Petal Widths (cm);

  10. legend('Region 1','Region 2','Region 3','Data','Location','South East')Fishers Iris Data 2.5 米米米 Ho 1.5 Region 1 Region 2 Region 3 0.5 Data 4 6 Petal Lengths (cm)

  11. randomly generate the sample data.

  12. % For reproducibility X = randn(100,2)*0.75+ones(100,2);

  13. randn(100,2)*0.5-ones(100,2)]; plot(X(:,1),X(:,2),'.');

    Randomly Generated Data 4 -2 -2 4

  14. plot(X(i dx==1,1),X(i dx==1,2),'r.','Marker Size',12)
    hold on
    plot(X(idx==2,1),X(idx==2,2),'b.','Marker Size',12)
    plot(C(:,1),C(:,2),'kx',...
         'Marker Size',15,'Line Width',3) 
    legend('Cluster 1','Cluster 2','Centroid',...
           'Location','NW')
    }
Add a comment
Know the answer?
Add Answer to:
1. Implement the K-means algorithm using these two as a reference. 2.Use Matlab’s implementation of kmeans...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT