gpt4 book ai didi

machine-learning - 如何更新Logistic回归模型?

转载 作者:行者123 更新时间:2023-11-30 08:32:57 28 4
gpt4 key购买 nike

我已经训练了一个逻辑回归模型。现在我必须使用新的训练数据集更新(部分拟合)模型。这可能吗?

最佳答案

不能LogisticRegression上使用partial_fit

但是你可以:

  • 使用warm_start=True,重用之前调用的解来拟合作为初始化,以加快收敛速度​​。
  • SGDClassifierloss='log' 结合使用,相当于 LogisticRegression,并且支持 partial_fit

请注意 partial_fitwarm_start 之间的区别。两种方法都从先前的模型开始并对其进行更新,但是 partial_fit 仅稍微更新了模型,而 warm_start 则一直在新的训练数据上收敛,忘记了先前的模型模型。 warm_start仅用于加速收敛。

另请参阅the glossary :

warm_start

When fitting an estimator repeatedly on the same dataset, but for multiple parameter values (such as to find the value maximizing performance as in grid search), it may be possible to reuse aspects of the model learnt from the previous parameter value, saving time. When warm_start is true, the existing fitted model attributes an are used to initialise the new model in a subsequent call to fit.

Note that this is only applicable for some models and some parameters, and even some orders of parameter values. For example, warm_start may be used when building random forests to add more trees to the forest (increasing n_estimators) but not to reduce their number.

partial_fit also retains the model between calls, but differs: with warm_start the parameters change and the data is (more-or-less) constant across calls to fit; with partial_fit, the mini-batch of data changes and model parameters stay fixed.

There are cases where you want to use warm_start to fit on different, but closely related data. For example, one may initially fit to a subset of the data, then fine-tune the parameter search on the full dataset. For classification, all data in a sequence of warm_start calls to fit must include samples from each class.

__

partial_fit

Facilitates fitting an estimator in an online fashion. Unlike fit, repeatedly calling partial_fit does not clear the model, but updates it with respect to the data provided. The portion of data provided to partial_fit may be called a mini-batch. Each mini-batch must be of consistent shape, etc.

partial_fit may also be used for out-of-core learning, although usually limited to the case where learning can be performed online, i.e. the model is usable after each partial_fit and there is no separate processing needed to finalize the model. cluster.Birch introduces the convention that calling partial_fit(X) will produce a model that is not finalized, but the model can be finalized by calling partial_fit() i.e. without passing a further mini-batch.

Generally, estimator parameters should not be modified between calls to partial_fit, although partial_fit should validate them as well as the new mini-batch of data. In contrast, warm_start is used to repeatedly fit the same estimator with the same data but varying parameters.

关于machine-learning - 如何更新Logistic回归模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51595162/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com