@@ -72,9 +72,9 @@ def __call__(self, x):
7272 return value [0 ]
7373 return value
7474
75- def __repr__ (self ):
76- return "StepFunction(x=%r, y=%r, a=%r, b=%r)" % (
77- self .x , self .y , self .a , self .b )
75+ # def __repr__(self):
76+ # return "StepFunction(x=%r, y=%r, a=%r, b=%r)" % (
77+ # self.x, self.y, self.a, self.b)
7878
7979
8080class BreslowEstimator :
@@ -125,25 +125,25 @@ def fit(self, linear_predictor, event, time):
125125 np .exp (- self .cum_baseline_hazard_ .y ))
126126 return self
127127
128- def get_cumulative_hazard_function (self , linear_predictor ):
129- r"""Predict cumulative hazard function.
130- Parameters
131- ----------
132- linear_predictor : array-like, shape = (n_samples,)
133- Linear predictor of risk: `X @ coef`.
134- Returns
135- -------
136- cum_hazard : ndarray, shape = (n_samples,)
137- Predicted cumulative hazard functions.
138- """
139- risk_score = np .exp (linear_predictor )
140- n_samples = risk_score .shape [0 ]
141- funcs = np .empty (n_samples , dtype = object )
142- for i in range (n_samples ):
143- funcs [i ] = StepFunction (x = self .cum_baseline_hazard_ .x ,
144- y = self .cum_baseline_hazard_ .y ,
145- a = risk_score [i ])
146- return funcs
128+ # def get_cumulative_hazard_function(self, linear_predictor):
129+ # r"""Predict cumulative hazard function.
130+ # Parameters
131+ # ----------
132+ # linear_predictor : array-like, shape = (n_samples,)
133+ # Linear predictor of risk: `X @ coef`.
134+ # Returns
135+ # -------
136+ # cum_hazard : ndarray, shape = (n_samples,)
137+ # Predicted cumulative hazard functions.
138+ # """
139+ # risk_score = np.exp(linear_predictor)
140+ # n_samples = risk_score.shape[0]
141+ # funcs = np.empty(n_samples, dtype=object)
142+ # for i in range(n_samples):
143+ # funcs[i] = StepFunction(x=self.cum_baseline_hazard_.x,
144+ # y=self.cum_baseline_hazard_.y,
145+ # a=risk_score[i])
146+ # return funcs
147147
148148 def get_survival_function (self , linear_predictor ):
149149 r"""Predict survival function.
@@ -164,7 +164,8 @@ def get_survival_function(self, linear_predictor):
164164 y = np .power (self .baseline_survival_ .y , risk_score [i ]))
165165 return funcs
166166
167- def _compute_counts (self ,event , time , order = None ):
167+ @staticmethod
168+ def _compute_counts (event , time , order = None ):
168169 """Count right censored and uncensored samples at each unique time point.
169170
170171 Parameters
0 commit comments