简体   繁体   English

Sklearn Model 的 method.fit()

[英]The method .fit() of a Sklearn Model

Does a Sklearn model's.fit () method reset the weights on each call? Sklearn 模型的.fit () 方法是否会重置每次调用的权重? 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()多次调用 fit() 将覆盖之前任何 fit() 学到的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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