hi i got this error while writing this code
SSE = []
for cluster in range(1,20):
kmeans = KMeans(n_jobs = -1, n_clusters = cluster, init='k-means ')
kmeans.fit(data_scaled)
SSE.append(kmeans.inertia_)
TypeError: __init__() got an unexpected keyword argument 'n_jobs'
it also happen with n_clusters
CodePudding user response:
When you initialized the KMeans class with kmeans = KMeans(n_jobs = -1, n_clusters = cluster, init='k-means '), the KMeans class did not have n_jobs when it initialized. Look up the class to see what arguments it has in its def __init__() function. This error means that the argument n_jobs was not a parameter when KMeans was initialized.
CodePudding user response:
KMeans doesn't accept n_jobs as an argument, you may be able to just omit it (what do you expect n_jobs=-1 to do for you?)
https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html
