Skip to content

Commit

Permalink
Fix: rename self.history to self._history in KerasBaseEstimator
Browse files Browse the repository at this point in the history
  • Loading branch information
RollerKnobster committed Jun 24, 2024
1 parent eaf24b2 commit 757d207
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gordo/machine/model/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
"""
self.kind = self.load_kind(kind)
self.kwargs: Dict[str, Any] = kwargs
self.history = None
self._history = None

super().__init__(**kwargs)

Expand Down Expand Up @@ -186,9 +186,9 @@ def __getstate__(self):
from tensorflow.python.keras.callbacks import History

history = History()
history.history = self.history.history
history.params = self.history.params
history.epoch = self.history.epoch
history.history = self._history.history
history.params = self._history.params
history.epoch = self._history.epoch
state["history"] = history
return state

Expand Down Expand Up @@ -269,10 +269,11 @@ def fit(
y = y.values
kwargs.setdefault("verbose", 0)

self._prepare_model()
if self.model is None:
self._prepare_model()
history = super().fit(X, y, sample_weight=None, **kwargs)
if isinstance(history, KerasRegressor):
self.history = history.history_
self._history = history.history_
return self

def predict(self, X: np.ndarray, **kwargs) -> np.ndarray:
Expand Down Expand Up @@ -579,7 +580,6 @@ def fit( # type: ignore

primer_x, primer_y = tsg[0]

self._prepare_model()
super().fit(X=primer_x, y=primer_y, epochs=1, verbose=0)

tsg = create_keras_timeseriesgenerator(
Expand Down

0 comments on commit 757d207

Please sign in to comment.