Skip to content

Commit

Permalink
added fit to dfh
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Al-Saffar committed Dec 1, 2023
1 parent e80f50d commit 230ae95
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions myresources/crocodile/deeplearning_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ def impute_standardize(self, df: pd.DataFrame) -> pd.DataFrame:
# return pd.DataFrame(res, columns=columns)
return df

def fit(self, df: 'pd.DataFrame'):
self.clipper_categorical.fit(df=df.loc[:, self.cols_ordinal + self.cols_onehot])
self.encoder_onehot.fit(df[self.cols_onehot])
self.encoder_ordinal.fit(df[self.cols_ordinal])

onehot_names: list[str] = list(self.encoder_onehot.get_feature_names_out())
self.cols_x_encoded_float = onehot_names + self.cols_ordinal + self.cols_numerical
# all numerical columns to be used as inputs to the model. Used in getstate, setstate, design model, etc.

self.clipper_numerical.fit(df[self.cols_numerical])
self.imputer.fit(df[self.cols_numerical])
self.scaler.fit(df[self.cols_ordinal + self.cols_numerical])


def check_for_nan(ip: 'npt.NDArray[Any]') -> int:
assert len(ip.shape) == 2, f"Expected 2D array, but got {len(ip.shape)}D array"
Expand Down

0 comments on commit 230ae95

Please sign in to comment.