I am using PyCharm to run Kmeans using Iris data.
JavaScript
x
9
1
from sklearn.datasets import load_iris
2
3
iris = load_iris()
4
5
from sklearn.cluster import KMeans
6
7
kmeans = KMeans()
8
print(kmeans)
9
When I run this, simply prints KMeans()
But I would like it to print the following:
JavaScript
1
2
1
KMeans(n_clusters=8, *, init='k-means++', n_init=10, max_iter=300, tol=0.0001, precompute_distances='deprecated', verbose=0, random_state=None, copy_x=True, n_jobs='deprecated', algorithm='auto')
2
How can this be accomplished?
Advertisement
Answer
Simply run kmeans.get_params()
. This will print out the parameters (default or custom) used while instantiating the function in a dictionary format.
Please refer this link for more information.