Skip to content

Commit

Permalink
ENH improve y_obs and marginal in decompose (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
lorentzenchr authored Sep 15, 2023
1 parent ceee1db commit 5721560
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/model_diagnostics/scoring/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def decompose(
if weights is None:
w = None
else:
validate_same_first_dimension(weights, y_obs)
validate_same_first_dimension(weights, y_o)
w = np.asarray(weights) # needed to satisfy mypy
if w.ndim > 1:
msg = f"The array weights must be 1-dimensional, got weights.ndim={w.ndim}."
Expand Down Expand Up @@ -856,18 +856,17 @@ def decompose(
)
raise ValueError(msg) from exc

marginal = np.full_like(y_o, fill_value=marginal, dtype=float)
score_marginal = scoring_function(y_o, marginal, w)

df_list = []
for i in range(len(pred_names)):
# Loop over columns of y_pred.
x = y_pred if n_pred == 0 else get_second_dimension(y_pred, i)
iso.fit(x, y_o, sample_weight=w)

marginal = np.full_like(y_o, fill_value=marginal, dtype=float)
recalibrated = np.squeeze(iso.predict(x))

score = scoring_function(y_obs, x, w)
score_recalibrated = scoring_function(y_obs, recalibrated, w)
score_marginal = scoring_function(y_obs, marginal, w)
score = scoring_function(y_o, x, w)
score_recalibrated = scoring_function(y_o, recalibrated, w)

df = pl.DataFrame(
{
Expand Down

0 comments on commit 5721560

Please sign in to comment.