Skip to content

Commit

Permalink
Changed the way printing is done through iterations by flushing stdout (
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinruk authored and CamDavidsonPilon committed May 16, 2019
1 parent bdf6be6 commit 85d1f2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lifelines/fitters/aalen_additive_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ def _fit_model_to_data_batch(self, X, T, E, weights, show_progress):
X[exits, :] = 0

if show_progress and i % int((n_deaths / 10)) == 0:
print("Iteration %d/%d, seconds_since_start = %.2f" % (i + 1, n_deaths, time.time() - start))
print("\rIteration %d/%d, seconds_since_start = %.2f" % (i + 1, n_deaths, time.time() - start),
end="")

last_iteration = i + 1
# terminate early when there are less than (3 * d) subjects left, where d does not include the intercept.
Expand Down
5 changes: 3 additions & 2 deletions lifelines/fitters/cox_time_varying_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,9 @@ def _newton_rhaphson(

if show_progress:
print(
"Iteration %d: norm_delta = %.5f, step_size = %.5f, ll = %.5f, newton_decrement = %.5f, seconds_since_start = %.1f"
% (i, norm_delta, step_size, ll, newton_decrement, time.time() - start_time)
"\rIteration %d: norm_delta = %.5f, step_size = %.5f, ll = %.5f, newton_decrement = %.5f, seconds_since_start = %.1f"
% (i, norm_delta, step_size, ll, newton_decrement, time.time() - start_time),
end=""
)

# convergence criteria
Expand Down
5 changes: 3 additions & 2 deletions lifelines/fitters/coxph_fitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ def _fit_model(

if show_progress:
print(
"Iteration %d: norm_delta = %.5f, step_size = %.4f, ll = %.5f, newton_decrement = %.5f, seconds_since_start = %.1f"
% (i, norm_delta, step_size, ll, newton_decrement, time.time() - start)
"\rIteration %d: norm_delta = %.5f, step_size = %.4f, ll = %.5f, newton_decrement = %.5f, seconds_since_start = %.1f"
% (i, norm_delta, step_size, ll, newton_decrement, time.time() - start),
end=""
)

# convergence criteria
Expand Down

0 comments on commit 85d1f2e

Please sign in to comment.