I'd like to deepcopy a fitted h2o.sklearn.H2OAutoMLRegressor object. I can deepcopy prior to calling fit but not after.
Using H2O version 3.44.0.3, the following results in an error for the deepcopy of the fitted model.
import copy
import numpy as np
import h2o
from h2o.sklearn import H2OAutoMLRegressor
print(f"H2O version: {h2o.__version__}")
X = np.random.rand(1000)
y = np.random.rand(1000)
m = H2OAutoMLRegressor(max_models=5, max_runtime_secs_per_model=30);
print(copy.deepcopy(m))
m.fit(X,y)
print(copy.deepcopy(m))
I cannot post the full trace because of StackOverflow code limits, but it looks like:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[7], line 17
13 print(copy.deepcopy(m))
15 m.fit(X,y)
---> 17 print(copy.deepcopy(m))
File ~/.pyenv/versions/3.11.7/lib/python3.11/copy.py:172, in deepcopy(x, memo, _nil)
170 y = x
171 else:
--> 172 y = _reconstruct(x, memo, *rv)
174 # If is its own copy, don't memoize.
175 if y is not x:
File ~/.pyenv/versions/3.11.7/lib/python3.11/copy.py:271, in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
269 if state is not None:
270 if deep:
--> 271 state = deepcopy(state, memo)
272 if hasattr(y, '__setstate__'):
273 y.__setstate__(state)
...
File ~/.pyenv/versions/3.11.7/lib/python3.11/copy.py:231, in _deepcopy_dict(x, memo, deepcopy)
229 memo[id(x)] = y
230 for key, value in x.items():
--> 231 y[deepcopy(key, memo)] = deepcopy(value, memo)
232 return y
File ~/.pyenv/versions/3.11.7/lib/python3.11/copy.py:172, in deepcopy(x, memo, _nil)
170 y = x
171 else:
--> 172 y = _reconstruct(x, memo, *rv)
174 # If is its own copy, don't memoize.
175 if y is not x:
File ~/.pyenv/versions/3.11.7/lib/python3.11/copy.py:265, in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
263 if deep and args:
264 args = (deepcopy(arg, memo) for arg in args)
--> 265 y = func(*args)
266 if deep:
267 memo[id(x)] = y
File ~/.pyenv/versions/3.11.7/lib/python3.11/copyreg.py:105, in __newobj__(cls, *args)
104 def __newobj__(cls, *args):
--> 105 return cls.__new__(cls, *args)
TypeError: H2OResponse.__new__() missing 1 required positional argument: 'keyvals'