简体   繁体   中英

TypeError: __init__() got an unexpected keyword argument 'n_jobs' and n_clusters

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM