Skip to content

Commit

Permalink
FIX bin_edges with Null values in compute_marginal (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr authored Nov 24, 2024
1 parent ab620c2 commit 0752de0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/model_diagnostics/calibration/identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,29 @@ def compute_marginal(
else [pl.col("bin_edges"), pl.col("__feature_std")]
),
)
).collect()
)

if not is_cat_or_string:
df = df.with_columns(
pl.col("bin_edges")
.arr.first()
.list.concat(pl.col("__feature_std"))
.list.concat(pl.col("bin_edges").arr.last())
pl.when(pl.col("bin_edges").is_null())
.then(
pl.concat_list(
pl.lit(None),
pl.col("__feature_std"),
pl.lit(None),
)
)
.otherwise(
pl.concat_list(
pl.col("bin_edges").arr.first(),
pl.col("__feature_std"),
pl.col("bin_edges").arr.last(),
)
)
.list.to_array(3)
.alias("bin_edges")
)
df = df.collect()

# Add column "model".
if n_pred > 0:
Expand Down

0 comments on commit 0752de0

Please sign in to comment.