Skip to content

Commit e1cd53f

Browse files
committed
revert import changes in survival example
1 parent c08b6ac commit e1cd53f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

examples/plot_survival_analysis.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,7 @@
1515
# Let's first generate synthetic data on which to run the Cox estimator,
1616
# using ``skglm`` data utils.
1717
#
18-
import warnings
19-
import time
20-
from lifelines import CoxPHFitter
21-
import pandas as pd
22-
import numpy as np
23-
from skglm.solvers import ProxNewton
24-
from skglm.penalties import L1
25-
from skglm.datafits import Cox
26-
import matplotlib.pyplot as plt
18+
2719
from skglm.utils.data import make_dummy_survival_data
2820

2921
n_samples, n_features = 500, 100
@@ -43,6 +35,7 @@
4335
# * ``s`` indicates the observations censorship and follows a Bernoulli(0.5) distribution
4436
#
4537
# Let's inspect the data quickly:
38+
import matplotlib.pyplot as plt
4639

4740
fig, axes = plt.subplots(
4841
1, 3,
@@ -67,7 +60,9 @@
6760
# Todo so, we need to combine a Cox datafit and a :math:`\ell_1` penalty
6861
# and solve the resulting problem using skglm Proximal Newton solver ``ProxNewton``.
6962
# We set the intensity of the :math:`\ell_1` regularization to ``alpha=1e-2``.
70-
63+
from skglm.penalties import L1
64+
from skglm.datafits import Cox
65+
from skglm.solvers import ProxNewton
7166

7267
# regularization intensity
7368
alpha = 1e-2
@@ -94,6 +89,9 @@
9489
# %%
9590
# Let's solve the problem with ``lifelines`` through its ``CoxPHFitter``
9691
# estimator and compare the objectives found by the two packages.
92+
import numpy as np
93+
import pandas as pd
94+
from lifelines import CoxPHFitter
9795

9896
# format data
9997
stacked_y_X = np.hstack((y, X))
@@ -127,6 +125,8 @@
127125
# let's compare their execution time. To get the evolution of the suboptimality
128126
# (objective - optimal objective) we run both estimators with increasing number of
129127
# iterations.
128+
import time
129+
import warnings
130130

131131
warnings.filterwarnings('ignore')
132132

0 commit comments

Comments
 (0)