def run_survival_curve(self, df): ''' used for testing only''' aaf = AalenAdditiveFitter() modelspec = 'YR_BRTH + AGE_DX + RADIATN + HISTREC + ERSTATUS + PRSTATUS + BEHANAL + HST_STGA + NUMPRIMS + RACE' X = pt.dmatrix(modelspec, df, return_type='dataframe') X = X.join(df[['SRV_TIME_MON', 'CENSORED']]) aaf.fit(X, 'SRV_TIME_MON', 'CENSORED') # INSERT VALUES TO TEST HERE test = np.array([[1., 1961., 52., 0, 0., 2., 1., 0., 4., 2.]]) aaf.predict_survival_function(test).plot() plt.show() exp = aaf.predict_expectation(test) print(exp) return
def run_survival_curve(self, df): ''' used for testing only''' aaf = AalenAdditiveFitter() modelspec = 'YR_BRTH + AGE_DX + RADIATN + HISTREC + ERSTATUS + PRSTATUS + BEHANAL + HST_STGA + NUMPRIMS + RACE' X = pt.dmatrix(modelspec, df, return_type='dataframe') X = X.join(df[['SRV_TIME_MON','CENSORED']]) aaf.fit(X, 'SRV_TIME_MON', 'CENSORED') # INSERT VALUES TO TEST HERE test = np.array([[ 1., 1961., 52., 0, 0., 2., 1., 0., 4., 2.]]) aaf.predict_survival_function(test).plot(); plt.show() exp = aaf.predict_expectation(test) print(exp) return
def predict(self, R, Thetas=dict(), _type='cumulative_hazards', **kwargs): """ Assuming that the type to refit is the first type of predictive_relationship """ if not self.regression_: raise Exception("No regression was fitted on the traning") X = self._modify_test_data(R, Thetas) if _type == 'cumulative_hazards': return AalenAdditiveFitter.predict_cumulative_hazard( self, X, id_col=kwargs.get('id_col', None)) elif _type == 'survival_function': return AalenAdditiveFitter.predict_survival_function(self, X) elif _type == 'percentile': return AalenAdditiveFitter.predict_percentile( self, X, kwargs.get('p', 0)) elif _type == 'median': return AalenAdditiveFitter.predict_median(self, X) elif _type == 'expectation': return AalenAdditiveFitter.predict_expectation(self, X) else: raise ValueError("Not avaialble type of prediction")