简体   繁体   中英

TypeError: __init__() got an unexpected keyword argument 'n_folds'

results = []    
names = []    
for name, model in models:    
    kfold = model_selection.KFold(n_splits=num_instances, n_folds=num_folds, random_state=seed)    
    cv_results = model_selection.cross_val_score(model, X_train, Y_train, cv=kfold, scoring=scoring)    
    results.append(cv_results)    
    names.append(name)    
    msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std())    
    print(msg) 

I guess with new update, n_folds is no longer in use in Kfold. Can anyone help me to overcome the issue?

In the updated library, the n_folds parameter was renamed to n_splits :

https://scikit-learn.org/0.18/whats_new.html#model-selection-enhancements-and-api-changes

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