且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拟合同一个scikit-learn模型的多个实例

更新时间:2023-10-06 18:20:34

您可能对

You might be interested in the clone function.

sklearn.base.clone(estimator,*,safe = True)[源代码]

sklearn.base.clone(estimator, *, safe=True)[source]

使用相同的参数构造一个新的不拟合估计量.克隆可以在估算器中对模型进行深层复制,而无需实际复制附加数据.它会产生一个新的估计器,该估计器具有未在任何数据上拟合的相同参数.

Constructs a new unfitted estimator with the same parameters. Clone does a deep copy of the model in an estimator without actually copying attached data. It yields a new estimator with the same parameters that has not been fitted on any data.

sklearn.base导入克隆中的

from sklearn.base import clone

model = LogisticRegression()
new_model = clone(model)