MCPcopy Create free account
hub / github.com/AIRMEC/HECTOR / get_survival_data_for_BS

Function get_survival_data_for_BS

utils.py:185–196  ·  view source on GitHub ↗
(df, time_col_name, censorship_col_name='censorship')

Source from the content-addressed store, hash-verified

183 print(f"Model has {n_trainable_params} parameters")
184
185def get_survival_data_for_BS(df, time_col_name, censorship_col_name='censorship'):
186 # To compute one survival metric the Brier score (BS), you need a specific format of censorship and times
187 # This is to estimate the censoring distribution from.
188 # A structured array containing the binary event indicator as first field (1 event occured; 0 censored), and time of event or time of censoring as second field.
189
190 val = df[[censorship_col_name, time_col_name]].values
191 max_time = df[time_col_name].max()
192
193 y = np.empty(len(df), dtype=[('cens', '?'), ('time', '<f8')])
194 for i in range(len(df)):
195 y[i] = tuple((bool(1-val[i][0]),val[i][1])) # Note that we take the uncensorship status.
196 return max_time, y
197
198def get_bins_time_value(df, n_bins, time_col_name, label_time_col_name='disc_label', censorship_col_name='censorship'):
199 # Retrieve the values of each bin from the dataset.

Callers 1

prepare_datasetsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected