Skip to content

Commit b84e699

Browse files
committed
Rename verbose to display_progress
1 parent bf0e43b commit b84e699

5 files changed

Lines changed: 57 additions & 57 deletions

File tree

dte_adj/base.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def predict_dte(
2828
alpha: float = 0.05,
2929
variance_type="moment",
3030
n_bootstrap=500,
31-
verbose: bool = True,
31+
display_progress: bool = True,
3232
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
3333
"""
3434
Compute Distribution Treatment Effects (DTE) based on the estimator for the distribution function.
@@ -45,7 +45,7 @@ def predict_dte(
4545
variance_type (str, optional): Variance type to be used to compute confidence intervals.
4646
Available values are "moment", "simple", and "uniform". Defaults to "moment".
4747
n_bootstrap (int, optional): Number of bootstrap samples. Defaults to 500.
48-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
48+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
4949
5050
Returns:
5151
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -87,7 +87,7 @@ def predict_dte(
8787
alpha,
8888
variance_type,
8989
n_bootstrap,
90-
verbose,
90+
display_progress,
9191
)
9292

9393
def predict_pte(
@@ -98,7 +98,7 @@ def predict_pte(
9898
alpha: float = 0.05,
9999
variance_type="moment",
100100
n_bootstrap=500,
101-
verbose: bool = True,
101+
display_progress: bool = True,
102102
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
103103
"""
104104
Compute Probability Treatment Effects (PTE) based on the estimator for the distribution function.
@@ -116,7 +116,7 @@ def predict_pte(
116116
variance_type (str, optional): Variance type to be used to compute confidence intervals.
117117
Available values are "moment", "simple", and "uniform". Defaults to "moment".
118118
n_bootstrap (int, optional): Number of bootstrap samples. Defaults to 500.
119-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
119+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
120120
121121
Returns:
122122
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -161,7 +161,7 @@ def predict_pte(
161161
alpha,
162162
variance_type,
163163
n_bootstrap,
164-
verbose,
164+
display_progress,
165165
)
166166

167167
def predict_qte(
@@ -171,7 +171,7 @@ def predict_qte(
171171
quantiles: Optional[np.ndarray] = None,
172172
alpha: float = 0.05,
173173
n_bootstrap=500,
174-
verbose: bool = True,
174+
display_progress: bool = True,
175175
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
176176
"""
177177
Compute Quantile Treatment Effects (QTE) based on the estimator for the distribution function.
@@ -186,7 +186,7 @@ def predict_qte(
186186
quantiles (np.ndarray, optional): Quantiles used for QTE. Defaults to [0.1, 0.2, ..., 0.9].
187187
alpha (float, optional): Significance level of the confidence bound. Defaults to 0.05.
188188
n_bootstrap (int, optional): Number of bootstrap samples. Defaults to 500.
189-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
189+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
190190
191191
Returns:
192192
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -236,7 +236,7 @@ def predict_qte(
236236

237237
qtes = np.zeros((n_bootstrap, qte.shape[0]))
238238
bootstrap_iter = range(n_bootstrap)
239-
if verbose:
239+
if display_progress:
240240
bootstrap_iter = tqdm(bootstrap_iter, desc="Bootstrap QTE")
241241
for b in bootstrap_iter:
242242
bootstrap_indexes = np.random.choice(indexes, size=n_obs, replace=True)
@@ -266,7 +266,7 @@ def _compute_dtes(
266266
alpha: float,
267267
variance_type: str,
268268
n_bootstrap: int,
269-
verbose: bool = False,
269+
display_progress: bool = False,
270270
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
271271
"""Compute expected DTEs."""
272272
treatment_cdf, treatment_cdf_mat, _ = self._compute_cumulative_distribution(
@@ -275,15 +275,15 @@ def _compute_dtes(
275275
self.covariates,
276276
self.treatment_arms,
277277
self.outcomes,
278-
verbose=verbose,
278+
display_progress=display_progress,
279279
)
280280
control_cdf, control_cdf_mat, _ = self._compute_cumulative_distribution(
281281
control_treatment_arm,
282282
locations,
283283
self.covariates,
284284
self.treatment_arms,
285285
self.outcomes,
286-
verbose=verbose,
286+
display_progress=display_progress,
287287
)
288288

289289
dte = treatment_cdf - control_cdf
@@ -320,7 +320,7 @@ def _compute_ptes(
320320
alpha: float,
321321
variance_type: str,
322322
n_bootstrap: int,
323-
verbose: bool = False,
323+
display_progress: bool = False,
324324
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
325325
"""Compute expected PTEs."""
326326
treatment_pdf, treatment_pdf_mat, _ = self._compute_interval_probability(
@@ -329,15 +329,15 @@ def _compute_ptes(
329329
self.covariates,
330330
self.treatment_arms,
331331
self.outcomes,
332-
verbose=verbose,
332+
display_progress=display_progress,
333333
)
334334
control_pdf, control_pdf_mat, _ = self._compute_interval_probability(
335335
control_treatment_arm,
336336
locations,
337337
self.covariates,
338338
self.treatment_arms,
339339
self.outcomes,
340-
verbose=verbose,
340+
display_progress=display_progress,
341341
)
342342

343343
pte = treatment_pdf - control_pdf
@@ -417,15 +417,15 @@ def find_quantile(quantile, arm):
417417
return result
418418

419419
def predict(
420-
self, treatment_arm: int, locations: np.ndarray, verbose: bool = True
420+
self, treatment_arm: int, locations: np.ndarray, display_progress: bool = True
421421
) -> np.ndarray:
422422
"""
423423
Compute cumulative distribution values.
424424
425425
Args:
426426
treatment_arm (int): The index of the treatment arm.
427427
outcomes (np.ndarray): Scalar values to be used for computing the cumulative distribution.
428-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
428+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
429429
430430
Returns:
431431
np.ndarray: Estimated cumulative distribution values for the input.
@@ -446,7 +446,7 @@ def predict(
446446
self.covariates,
447447
self.treatment_arms,
448448
self.outcomes,
449-
verbose=verbose,
449+
display_progress=display_progress,
450450
)[0]
451451

452452
def _compute_cumulative_distribution(
@@ -456,7 +456,7 @@ def _compute_cumulative_distribution(
456456
covariates: np.ndarray,
457457
treatment_arms: np.ndarray,
458458
outcomes: np.array,
459-
verbose: bool = False,
459+
display_progress: bool = False,
460460
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
461461
"""
462462
Compute the cumulative distribution values.
@@ -467,7 +467,7 @@ def _compute_cumulative_distribution(
467467
covariates: (np.ndarray): An array of covariates variables in the observed data.
468468
treatment_arms (np.ndarray): An array of treatment arms in the observed data.
469469
outcomes (np.ndarray): An array of outcomes in the observed data.
470-
verbose (bool): Whether to display a progress bar.
470+
display_progress (bool): Whether to display a progress bar.
471471
472472
Returns:
473473
Tuple[np.ndarray, np.ndarray, np.ndarray]: Estimated cumulative distribution values, prediction for each observation, and superset prediction for each observation.

dte_adj/local.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def predict_ldte(
6161
control_treatment_arm: int,
6262
locations: np.ndarray,
6363
alpha: float = 0.05,
64-
verbose: bool = True,
64+
display_progress: bool = True,
6565
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
6666
"""
6767
Compute Local Distribution Treatment Effects (LDTE).
@@ -75,7 +75,7 @@ def predict_ldte(
7575
control_treatment_arm (int): The index of the treatment arm of the control group.
7676
locations (np.ndarray): Scalar values to be used for computing the cumulative distribution.
7777
alpha (float, optional): Significance level of the confidence bound. Defaults to 0.05.
78-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
78+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
7979
8080
Returns:
8181
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -119,7 +119,7 @@ def predict_ldte(
119119
control_treatment_arm,
120120
locations,
121121
alpha,
122-
verbose,
122+
display_progress,
123123
)
124124

125125
def predict_lpte(
@@ -128,7 +128,7 @@ def predict_lpte(
128128
control_treatment_arm: int,
129129
locations: np.ndarray,
130130
alpha: float = 0.05,
131-
verbose: bool = True,
131+
display_progress: bool = True,
132132
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
133133
"""
134134
Compute Local Probability Treatment Effects (LPTE).
@@ -143,7 +143,7 @@ def predict_lpte(
143143
locations (np.ndarray): Scalar values defining interval boundaries for probability computation.
144144
For each interval (locations[i], locations[i+1]], the LPTE is computed.
145145
alpha (float, optional): Significance level of the confidence bound. Defaults to 0.05.
146-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
146+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
147147
148148
Returns:
149149
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -189,7 +189,7 @@ def predict_lpte(
189189
control_treatment_arm,
190190
locations,
191191
alpha,
192-
verbose,
192+
display_progress,
193193
)
194194

195195

@@ -236,7 +236,7 @@ def predict_ldte(
236236
control_treatment_arm: int,
237237
locations: np.ndarray,
238238
alpha: float = 0.05,
239-
verbose: bool = True,
239+
display_progress: bool = True,
240240
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
241241
"""
242242
Compute Local Distribution Treatment Effects (LDTE) using ML adjustment.
@@ -249,7 +249,7 @@ def predict_ldte(
249249
control_treatment_arm (int): The index of the treatment arm of the control group.
250250
locations (np.ndarray): Scalar values to be used for computing the cumulative distribution.
251251
alpha (float, optional): Significance level of the confidence bound. Defaults to 0.05.
252-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
252+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
253253
254254
Returns:
255255
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -295,7 +295,7 @@ def predict_ldte(
295295
control_treatment_arm,
296296
locations,
297297
alpha,
298-
verbose,
298+
display_progress,
299299
)
300300

301301
def predict_lpte(
@@ -304,7 +304,7 @@ def predict_lpte(
304304
control_treatment_arm: int,
305305
locations: np.ndarray,
306306
alpha: float = 0.05,
307-
verbose: bool = True,
307+
display_progress: bool = True,
308308
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
309309
"""
310310
Compute Local Probability Treatment Effects (LPTE) using ML adjustment.
@@ -318,7 +318,7 @@ def predict_lpte(
318318
locations (np.ndarray): Scalar values defining interval boundaries for probability computation.
319319
For each interval (locations[i], locations[i+1]], the LPTE is computed.
320320
alpha (float, optional): Significance level of the confidence bound. Defaults to 0.05.
321-
verbose (bool, optional): Whether to display a progress bar. Defaults to True.
321+
display_progress (bool, optional): Whether to display a progress bar. Defaults to True.
322322
323323
Returns:
324324
Tuple[np.ndarray, np.ndarray, np.ndarray]: A tuple containing:
@@ -367,5 +367,5 @@ def predict_lpte(
367367
control_treatment_arm,
368368
locations,
369369
alpha,
370-
verbose,
370+
display_progress,
371371
)

dte_adj/stratified.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _compute_cumulative_distribution(
5555
covariates: np.ndarray,
5656
treatment_arms: np.ndarray,
5757
outcomes: np.array,
58-
verbose: bool = False,
58+
display_progress: bool = False,
5959
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
6060
"""
6161
Compute the cumulative distribution values.
@@ -66,7 +66,7 @@ def _compute_cumulative_distribution(
6666
covariates: (np.ndarray): An array of covariates variables in the observed data.
6767
treatment_arm (np.ndarray): An array of treatment arms in the observed data.
6868
outcomes (np.ndarray): An array of outcomes in the observed data
69-
verbose (bool): Whether to display a progress bar.
69+
display_progress (bool): Whether to display a progress bar.
7070
7171
Returns:
7272
Tuple of numpy arrays:
@@ -105,7 +105,7 @@ def _compute_interval_probability(
105105
covariates: np.ndarray,
106106
treatment_arms: np.ndarray,
107107
outcomes: np.array,
108-
verbose: bool = False,
108+
display_progress: bool = False,
109109
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
110110
"""Compute the interval probabilities.
111111
@@ -115,7 +115,7 @@ def _compute_interval_probability(
115115
covariates: (np.ndarray): An array of covariates variables in the observed data.
116116
treatment_arm (np.ndarray): An array of treatment arms in the observed data.
117117
outcomes (np.ndarray): An array of outcomes in the observed data
118-
verbose (bool): Whether to display a progress bar.
118+
display_progress (bool): Whether to display a progress bar.
119119
120120
Returns:
121121
Tuple of numpy arrays:
@@ -224,7 +224,7 @@ def _compute_cumulative_distribution(
224224
covariates: np.ndarray,
225225
treatment_arms: np.ndarray,
226226
outcomes: np.array,
227-
verbose: bool = False,
227+
display_progress: bool = False,
228228
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
229229
"""
230230
Compute the cumulative distribution values.
@@ -235,7 +235,7 @@ def _compute_cumulative_distribution(
235235
covariates: (np.ndarray): An array of covariates variables in the observed data.
236236
treatment_arm (np.ndarray): An array of treatment arms in the observed data.
237237
outcomes (np.ndarray): An array of outcomes in the observed data
238-
verbose (bool): Whether to display a progress bar.
238+
display_progress (bool): Whether to display a progress bar.
239239
240240
Returns:
241241
Tuple of numpy arrays:
@@ -254,7 +254,7 @@ def _compute_cumulative_distribution(
254254
if self.is_multi_task:
255255
binomial = (outcomes.reshape(-1, 1) <= locations) * 1 # (n_records, n_loc)
256256
fold_iter = range(self.folds)
257-
if verbose:
257+
if display_progress:
258258
fold_iter = tqdm(fold_iter, desc="Cross-fitting (multi-task)")
259259
for fold in fold_iter:
260260
fold_mask = (folds != fold) & treatment_mask
@@ -281,7 +281,7 @@ def _compute_cumulative_distribution(
281281
superset_prediction[superset_mask] = pred
282282
else:
283283
loc_iter = enumerate(locations)
284-
if verbose:
284+
if display_progress:
285285
loc_iter = tqdm(loc_iter, total=len(locations), desc="Computing CDF")
286286
for i, location in loc_iter:
287287
binomial = (outcomes <= location) * 1 # (n_records)
@@ -335,7 +335,7 @@ def _compute_interval_probability(
335335
covariates: np.ndarray,
336336
treatment_arms: np.ndarray,
337337
outcomes: np.array,
338-
verbose: bool = False,
338+
display_progress: bool = False,
339339
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
340340
"""
341341
Compute the interval probabilities.
@@ -346,7 +346,7 @@ def _compute_interval_probability(
346346
covariates: (np.ndarray): An array of covariates variables in the observed data.
347347
treatment_arm (np.ndarray): An array of treatment arms in the observed data.
348348
outcomes (np.ndarray): An array of outcomes in the observed data
349-
verbose (bool): Whether to display a progress bar.
349+
display_progress (bool): Whether to display a progress bar.
350350
351351
Returns:
352352
Tuple of numpy arrays:
@@ -364,7 +364,7 @@ def _compute_interval_probability(
364364
s_list = np.unique(strata)
365365
binominals = (outcomes[:, np.newaxis] <= locations) * 1 # (n_records, n_loc)
366366
interval_iter = range(len(locations) - 1)
367-
if verbose:
367+
if display_progress:
368368
interval_iter = tqdm(interval_iter, desc="Computing interval prob.")
369369
for i in interval_iter:
370370
binomial = binominals[:, i + 1] - binominals[:, i]

0 commit comments

Comments
 (0)