Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions cobra/evaluation/pigs_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,12 @@ def plot_incidence(pig_tables: pd.DataFrame,
'the same set of variables.')

df_plot['label'] = df_plot['label'].astype('category')
df_plot['label'].cat.reorder_categories(column_order,
inplace=True)
df_plot['label'] = df_plot['label'].cat.reorder_categories(column_order)

df_plot.sort_values(by=['label'], ascending=True, inplace=True)
df_plot.reset_index(inplace=True)
df_plot = df_plot.sort_values(by=['label'], ascending=True).reset_index()
else:
df_plot.sort_values(by=['avg_target'], ascending=False, inplace=True)
df_plot.reset_index(inplace=True)
df_plot = df_plot.sort_values(by=['avg_target'], ascending=False)
df_plot = df_plot.reset_index()

with plt.style.context("seaborn-ticks"):
fig, ax = plt.subplots(figsize=dim)
Expand Down
2 changes: 1 addition & 1 deletion cobra/preprocessing/kbins_discretizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _transform_column(self, data: pd.DataFrame,

# Replace NULL with "Missing"
# Otherwise these will be ignored in groupby
data[column_name_bin].fillna("Missing", inplace=True)
data[column_name_bin] = data[column_name_bin].fillna("Missing")

return data

Expand Down
12 changes: 4 additions & 8 deletions cobra/preprocessing/target_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,13 @@ def _transform_column(self, data: pd.DataFrame,
# configured imputation strategy:
if _data[new_column].isnull().sum() > 0:
if self.imputation_strategy == "mean":
_data[new_column].fillna(self._global_mean,
inplace=True)
_data[new_column] = _data[new_column].fillna(self._global_mean)
elif self.imputation_strategy == "min":
_data[new_column].fillna(_data[new_column].min(),
inplace=True)
_data[new_column] = _data[new_column].fillna(_data[new_column].min())
elif self.imputation_strategy == "max":
_data[new_column].fillna(_data[new_column].max(),
inplace=True)
_data[new_column] = _data[new_column].fillna(_data[new_column].max())
elif self.imputation_strategy == "median":
_data[new_column].fillna(_data[new_column].median(),
inplace=True)
_data[new_column] = _data[new_column].fillna(_data[new_column].median())

return _data

Expand Down
Loading