Skip to content

Commit

Permalink
Fix pd.cut to take list as input instead of tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
1pha committed Feb 13, 2024
1 parent 742f4d5 commit cee8d68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sage/trainer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def finalize_inference(prediction: list,
# 1. Sort Prediction
prediction = _sort_outputs(prediction)

# 2. Save PRediction
# 2. Save Prediction
save_name = f"{name}.pkl"
logger.info("Save prediction as %s", save_name)
with open(root_dir / save_name, "wb") as f:
Expand Down Expand Up @@ -167,8 +167,8 @@ def _get_norm_cf_reg(preds, target, root_dir, run_name) -> None:
labels = [f"{left}-{right - 1}" for left, right in zip(bins, bins[1:])]

cut_kwargs = dict(bins=bins, labels=labels, include_lowest=True)
_preds = pd.cut(x=preds, **cut_kwargs)
_target = pd.cut(x=target, **cut_kwargs)
_preds = pd.cut(x=preds.tolist(), **cut_kwargs)
_target = pd.cut(x=target.tolist(), **cut_kwargs)
if (_preds.isna().sum() + _target.isna().sum()) == 0:
fig, ax = plt.subplots(figsize=(13, 6), ncols=2)
labelsize = "large"
Expand Down

0 comments on commit cee8d68

Please sign in to comment.