xgbse.metrics¶
approx_brier_score(y_true, survival, aggregate='mean')
¶
Estimate brier score for all survival time windows. Aggregate scores for an approximate integrated brier score estimate.
Parameters:
Name  Type  Description  Default 

y_true 
structured array(numpy.bool_, numpy.number 
B inary event indicator as first field, and time of event or time of censoring as second field. 
required 
survival 
[pd.DataFrame, np.array] 
A dataframe of survival probabilities for all times (columns), from a time_bins array, for all samples of X (rows). If risk_strategy is 'precomputed', is an array with representing risks for each sample. 
required 
aggregate 
[string, None] 
How to aggregate brier scores from different time windows:

'mean' 
Returns:
Type  Description 

[Float, np.array] 
single value if aggregate is 'mean' np.array if aggregate is None 
concordance_index(y_true, survival, risk_strategy='mean', which_window=None)
¶
Compute the Cindex for a structured array of ground truth times and events and a predicted survival curve using different strategies for estimating risk from it.
Note
 Computation of the Cindex is \(\mathcal{O}(n^2)\).
Parameters:
Name  Type  Description  Default 

y_true 
structured array(numpy.bool_, numpy.number 
Binary event indicator as first field, and time of event or time of censoring as second field. 
required 
survival 
[pd.DataFrame, np.array] 
A dataframe of survival probabilities for all times (columns), from a time_bins array, for all samples of X (rows). If risk_strategy is 'precomputed', is an array with representing risks for each sample. 
required 
risk_strategy 
string 
Strategy to compute risks from the survival curve. For a given sample:

'mean' 
which_window 
object 
Which window to use when risk_strategy is 'window'. Should be one of the columns of the dataframe. Will raise ValueError if column is not present 
None 
Returns:
Type  Description 

Float 
Concordance index for y_true and survival 
dist_calibration_score(y_true, survival, n_bins=10, returns='pval')
¶
Estimate DCalibration for the survival predictions.
Parameters:
Name  Type  Description  Default 

y_true 
structured array(numpy.bool_, numpy.number 
Binary event indicator as first field, and time of event or time of censoring as second field. 
required 
survival 
[pd.DataFrame, np.array] 
A dataframe of survival probabilities for all times (columns), from a time_bins array, for all samples of X (rows). If risk_strategy is 'precomputed', is an array with representing risks for each sample. 
required 
n_bins 
Int 
Number of bins to equally divide the [0, 1] interval 
10 
returns 
string 
What information to return from the function:

'pval' 
Returns:
Type  Description 

[Float, np.array, Dict] 
