Skip to content

Commit

Permalink
just crank it up
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Jan 2, 2024
1 parent 95fc945 commit 4fcbff4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lifelines/fitters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def _fit_model(self, Ts, E, entry, weights, fit_options: dict, show_progress=Tru
minimizing_results, previous_results, minimizing_ll = None, None, np.inf
for method, option in zip(
["Nelder-Mead", self._scipy_fit_method],
[{"maxiter": 100}, {**{"disp": show_progress}, **self._scipy_fit_options, **fit_options}],
[{"maxiter": 200}, {**{"disp": show_progress}, **self._scipy_fit_options, **fit_options}],
):

initial_value = self._initial_values if previous_results is None else utils._to_1d_array(previous_results.x)
Expand Down
11 changes: 6 additions & 5 deletions lifelines/fitters/generalized_gamma_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class GeneralizedGammaFitter(KnownModelParametricUnivariateFitter):
"""

_scipy_fit_method = "SLSQP"
_scipy_fit_options = {"maxiter": 10_000, "maxfev": 10_000}
_fitted_parameter_names = ["mu_", "ln_sigma_", "lambda_"]
_bounds = [(None, None), (None, None), (None, None)]
_compare_to_values = np.array([0.0, 0.0, 1.0])
Expand All @@ -117,14 +118,14 @@ def _create_initial_point(self, Ts, E, *args):
elif CensoringType.is_interval_censoring(self):
# this fails if Ts[1] == Ts[0], so we add a some fudge factors.
log_data = log(Ts[1] - Ts[0] + 0.1)
return np.array([log_data.mean(), log(log_data.std() + 0.01), 0.1])
return np.array([log_data.mean() * 1.5, log(log_data.std() + 0.1), 1.0])

def _cumulative_hazard(self, params, times):
mu_, ln_sigma_, lambda_ = params

sigma_ = safe_exp(ln_sigma_)
Z = (log(times) - mu_) / sigma_
ilambda_2 = 1 / lambda_ ** 2
ilambda_2 = 1 / lambda_**2
clipped_exp = np.clip(safe_exp(lambda_ * Z) * ilambda_2, 1e-300, 1e20)

if lambda_ > 0:
Expand All @@ -137,7 +138,7 @@ def _cumulative_hazard(self, params, times):

def _log_hazard(self, params, times):
mu_, ln_sigma_, lambda_ = params
ilambda_2 = 1 / lambda_ ** 2
ilambda_2 = 1 / lambda_**2
Z = (log(times) - mu_) / safe_exp(ln_sigma_)
clipped_exp = np.clip(safe_exp(lambda_ * Z) * ilambda_2, 1e-300, 1e20)
if lambda_ > 0:
Expand Down Expand Up @@ -171,5 +172,5 @@ def percentile(self, p):
sigma_ = exp(self.ln_sigma_)

if lambda_ > 0:
return exp(sigma_ * log(gammainccinv(1 / lambda_ ** 2, p) * lambda_ ** 2) / lambda_) * exp(self.mu_)
return exp(sigma_ * log(gammaincinv(1 / lambda_ ** 2, p) * lambda_ ** 2) / lambda_) * exp(self.mu_)
return exp(sigma_ * log(gammainccinv(1 / lambda_**2, p) * lambda_**2) / lambda_) * exp(self.mu_)
return exp(sigma_ * log(gammaincinv(1 / lambda_**2, p) * lambda_**2) / lambda_) * exp(self.mu_)

0 comments on commit 4fcbff4

Please sign in to comment.