Last answered:

22 Feb 2022

Posted on:

21 Feb 2022

0

kmeans.fit(x) does not have the same output

When I ran kmeans.fit(x), it only gives me KMeans(n_clusters=2) in the output, which differs from the output that is shown in the video. How do I fix this? Thanks.

1 answers ( 0 marked as helpful)
Instructor
Posted on:

22 Feb 2022

0

Hey Christine,

Thank you for your question!

A parameter will be present in the output only if you change its default value. For example, the default number of clusters in sklearn is 8. In your example, you have set the number of clusters to 2, which is different from the default value, so that parameter shows up in the output. The rest of the parameters have their default values. If you, for example, change the random_state, that parameter will show up:
image.png
If you wish to display the values of all parameters, then you need to apply the get_params() method in just the same way as for the other algorithms.
image.png

Kind regards,
365 Hristina

Submit an answer