简体   繁体   中英

The method .fit() of a Sklearn Model

Does a Sklearn model's.fit () method reset the weights on each call? Does the pice of code below its all right? I saw it somewhere for cross validation and I dont know if it makes sense.

from sklearn.neural_network import MLPRegressor
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split

X, y = make_regression(n_samples=200)
regr = MLPRegressor(solver='sgd', max_iter=150)

for i in range(5):
    X_train, X_test, y_train, y_test = train_test_split(X, y)
    regr.fit(X_train, y_train)

Thank you.

Yes, it resets the weights, as you can see here on the documentation

Calling fit() more than once will overwrite what was learned by any previous fit()

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