Skip to content

Commit

Permalink
finished of testing auc and ibs from sksurv.
Browse files Browse the repository at this point in the history
stacked Weibull seems to be the best model
  • Loading branch information
Raul Casaña Eslava committed Jul 12, 2022
1 parent c56b4ba commit b2c742a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xgbse/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def concordance_index(y_true, survival, risk_strategy="mean", which_window=None)

# counting total, concordant and tied pairs
count_pairs += samples_after_i.shape[0]
concordant_pairs += (samples_after_i["r"] < row["r"]).sum()
tied_pairs += (samples_after_i["r"] == row["r"]).sum()
concordant_pairs += np.sum(samples_after_i["r"] < row["r"])
tied_pairs += np.sum(samples_after_i["r"] == row["r"])

return (concordant_pairs + tied_pairs / 2) / count_pairs

Expand Down Expand Up @@ -181,7 +181,11 @@ def approx_brier_score(y_true, survival, aggregate="mean"):
# result = (first_term + second_term).sum() / scoring_df.shape[0]

added_terms = (first_term + second_term)
result = np.nanmean(added_terms[np.isfinite(added_terms)])
added_terms = added_terms[np.isfinite(added_terms)]
if len(added_terms) > 0:
result = np.nanmean(added_terms)
else:
result = np.nan
window_results.append(result)

if aggregate == "mean":
Expand Down

0 comments on commit b2c742a

Please sign in to comment.