Skip to content

Commit

Permalink
fix numerical encoder sign none handling
Browse files Browse the repository at this point in the history
  • Loading branch information
paxcema committed Jun 13, 2023
1 parent 8c7b78f commit 7eaf17e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lightwood/encoder/numeric/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def encode(self, data: Union[np.ndarray, pd.Series]):
if isinstance(data, pd.Series):
data = data.values

inp_data = np.nan_to_num(data.astype(float), nan=0, posinf=np.finfo(np.float32).max, neginf=np.finfo(np.float32).min) # noqa
if not self.positive_domain:
sign_data = np.nan_to_num(data.astype(float), nan=0, posinf=0, neginf=0)
sign = np.vectorize(self._sign_fn, otypes=[float])(sign_data)
sign = np.vectorize(self._sign_fn, otypes=[float])(inp_data)
else:
sign = np.zeros(len(data))
log_value = np.vectorize(self._log_fn, otypes=[float])(data)
log_value = np.vectorize(self._log_fn, otypes=[float])(inp_data)
log_value = np.nan_to_num(log_value, nan=0, posinf=20, neginf=-20)

norm = np.vectorize(self._norm_fn, otypes=[float])(data)
norm = np.vectorize(self._norm_fn, otypes=[float])(inp_data)
norm = np.nan_to_num(norm, nan=0, posinf=20, neginf=-20)

if self.is_target:
Expand Down

0 comments on commit 7eaf17e

Please sign in to comment.