In the xgboost
documentation they refer to a copy()
method, but I can't figure out how to use it since if foo
is my model, neither bar = foo.copy()
nor bar=xgb.copy(foo)
works ( xgboost
can't find a copy()
attribute of either the module or the model). Any suggestions?
It turns out that copy()
is a method of the Booster
object, but a (say) XGBClassifier
is not one, so if using the sklearn
front end, you do bar = foo.get_booster().copy()
sklearn.base.clone()
will make a deep copy of a model without copying attached data. It may be what you are looking for. Just remember, it's a function , not a method, so don't make the mistake I did of sticking .clone
after my identifier:-)
Usage:
## assume e as an estimator is defined and sklearn is already imported.
e = sklearn.base.clone(estimator)
e is estimator ## should return False
HTH
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.