Constraint Satisfaction Matcher
The ConstraintSatisfactionMatcher can be used to optimize any linear function of the baseline covariates. We support constraints on the size of the subset populations and the allowed mismatch.
Here, we demonstrate the optimization of balance subject to size constraints only. Namely, we solve:
\begin{equation} \begin{aligned} & \underset{\hat{P}}{\text{minimize}} & & \sum_k |\mu_{\hat{P}k} - \mu_{Tk}| \\ & \text{subject to} & & |\hat{P}| = P^* \\ & & & |\hat{T}| = T^* \\ \end{aligned} \end{equation}
where \(P\) and \(T\) refer to two populations we are trying to match, \(\hat{P}\) and \(\hat{T}\) are the subsets of \(P\) and \(T\) we are seeking, \(P^*\) and \(T^*\) are fixed integers, and \(k\) indexes the covariates of \(P\) and \(T\).
[1]:
import logging
logging.basicConfig(
format="%(levelname)-4s [%(filename)s:%(lineno)d] %(message)s",
level='INFO',
)
from pybalance.utils import (
BetaBalance,
BetaXBalance,
GammaBalance,
GammaXBalance,
GammaXTreeBalance
)
from pybalance.sim import generate_toy_dataset
from pybalance.lp import ConstraintSatisfactionMatcher
from pybalance.visualization import (
plot_numeric_features,
plot_categoric_features,
plot_binary_features,
plot_per_feature_loss,
)
[2]:
time_limit = 60
[3]:
m = generate_toy_dataset()
m
[3]:
['age', 'height', 'weight']
Headers Categoric:
['gender', 'haircolor', 'country', 'binary_0', 'binary_1', 'binary_2', 'binary_3']
Populations
['pool', 'target']
| age | height | weight | gender | haircolor | country | population | binary_0 | binary_1 | binary_2 | binary_3 | patient_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 62.511573 | 190.229250 | 105.165097 | 0.0 | 2 | 3 | pool | 0 | 0 | 0 | 0 | 0 |
| 1 | 68.505065 | 161.121236 | 95.001474 | 0.0 | 1 | 1 | pool | 1 | 0 | 1 | 0 | 1 |
| 2 | 50.071384 | 162.325356 | 84.290576 | 1.0 | 0 | 5 | pool | 0 | 0 | 1 | 1 | 2 |
| 3 | 44.423692 | 150.948096 | 82.031381 | 1.0 | 2 | 2 | pool | 0 | 0 | 0 | 1 | 3 |
| 4 | 41.695052 | 132.952651 | 54.857540 | 0.0 | 1 | 3 | pool | 0 | 0 | 1 | 1 | 4 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 995 | 21.474205 | 168.602546 | 70.342128 | 0.0 | 2 | 5 | target | 0 | 0 | 0 | 1 | 10995 |
| 996 | 40.643320 | 188.188724 | 61.611744 | 0.0 | 2 | 4 | target | 1 | 0 | 0 | 1 | 10996 |
| 997 | 29.472765 | 161.408162 | 57.214095 | 0.0 | 0 | 1 | target | 0 | 1 | 1 | 1 | 10997 |
| 998 | 41.291949 | 150.968833 | 91.270798 | 0.0 | 0 | 3 | target | 0 | 0 | 0 | 0 | 10998 |
| 999 | 67.530294 | 155.124741 | 56.196505 | 1.0 | 0 | 1 | target | 1 | 0 | 0 | 0 | 10999 |
11000 rows × 12 columns
Optimize Beta (Mean Absolute SMD)
[4]:
objective = beta = BetaBalance(m)
matcher = matcher_beta = ConstraintSatisfactionMatcher(
m,
time_limit=time_limit,
objective=objective,
ps_hinting=False,
num_workers=4)
matcher.get_params()
INFO [matcher.py:66] Scaling features by factor 240.00 in order to use integer solver with <= 0.2841% loss.
[4]:
{'objective': 'beta',
'pool_size': 1000,
'target_size': 1000,
'max_mismatch': None,
'time_limit': 60,
'num_workers': 4,
'ps_hinting': False,
'verbose': True}
[5]:
matcher.match()
INFO [matcher.py:473] Solving for match population with pool size = 1000 and target size = 1000, optimizing balance (no max_mismatch cap).
INFO [matcher.py:477] Matching on 15 dimensions ...
INFO [matcher.py:484] Building model variables and constraints ...
INFO [matcher.py:493] Calculating bounds on feature variables ...
INFO [matcher.py:583] Applying size constraints on pool and target ...
INFO [matcher.py:239] Solving with 4 workers ...
INFO [matcher.py:91] Initial balance score: 0.2328
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 1, time = 1.1 s
INFO [matcher.py:102] Objective: 452948000.0
INFO [matcher.py:123] Balance (beta): 0.2298
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 2, time = 1.6 s
INFO [matcher.py:102] Objective: 452876000.0
INFO [matcher.py:123] Balance (beta): 0.2297
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 3, time = 1.9 s
INFO [matcher.py:102] Objective: 452777000.0
INFO [matcher.py:123] Balance (beta): 0.2297
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 4, time = 2.0 s
INFO [matcher.py:102] Objective: 452736000.0
INFO [matcher.py:123] Balance (beta): 0.2296
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 5, time = 2.0 s
INFO [matcher.py:102] Objective: 452730000.0
INFO [matcher.py:123] Balance (beta): 0.2296
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 6, time = 2.3 s
INFO [matcher.py:102] Objective: 452596000.0
INFO [matcher.py:123] Balance (beta): 0.2295
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 7, time = 2.5 s
INFO [matcher.py:102] Objective: 452537000.0
INFO [matcher.py:123] Balance (beta): 0.2294
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 8, time = 2.6 s
INFO [matcher.py:102] Objective: 452040000.0
INFO [matcher.py:123] Balance (beta): 0.2291
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 9, time = 3.4 s
INFO [matcher.py:102] Objective: 22270000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 10, time = 4.4 s
INFO [matcher.py:102] Objective: 22153000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 11, time = 5.2 s
INFO [matcher.py:102] Objective: 22119000.0
INFO [matcher.py:123] Balance (beta): 0.0104
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 12, time = 5.7 s
INFO [matcher.py:102] Objective: 22114000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 13, time = 8.3 s
INFO [matcher.py:102] Objective: 22111000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 14, time = 9.4 s
INFO [matcher.py:102] Objective: 22109000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 15, time = 15.5 s
INFO [matcher.py:102] Objective: 22105000.0
INFO [matcher.py:123] Balance (beta): 0.0123
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 16, time = 17.5 s
INFO [matcher.py:102] Objective: 22104000.0
INFO [matcher.py:123] Balance (beta): 0.0102
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 17, time = 18.2 s
INFO [matcher.py:102] Objective: 22088000.0
INFO [matcher.py:123] Balance (beta): 0.0122
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 18, time = 39.9 s
INFO [matcher.py:102] Objective: 22087000.0
INFO [matcher.py:123] Balance (beta): 0.0122
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:252] Status = FEASIBLE
INFO [matcher.py:253] Number of solutions found: 18
[5]:
['age', 'height', 'weight']
Headers Categoric:
['gender', 'haircolor', 'country', 'binary_0', 'binary_1', 'binary_2', 'binary_3']
Populations
['pool', 'target']
| age | height | weight | gender | haircolor | country | population | binary_0 | binary_1 | binary_2 | binary_3 | patient_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 55.261578 | 139.396134 | 94.438359 | 0.0 | 2 | 2 | target | 0 | 0 | 1 | 1 | 10000 |
| 1 | 63.113091 | 165.563337 | 67.433016 | 1.0 | 2 | 2 | target | 0 | 1 | 1 | 0 | 10001 |
| 2 | 58.232216 | 160.859857 | 71.915385 | 1.0 | 0 | 2 | target | 0 | 0 | 0 | 0 | 10002 |
| 3 | 58.996941 | 140.357415 | 115.606615 | 1.0 | 0 | 3 | target | 1 | 1 | 0 | 0 | 10003 |
| 4 | 36.850195 | 189.983706 | 53.000581 | 0.0 | 2 | 5 | target | 0 | 0 | 0 | 0 | 10004 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 9874 | 71.869788 | 176.988908 | 108.680876 | 0.0 | 2 | 5 | pool | 0 | 0 | 0 | 0 | 9874 |
| 9875 | 61.252012 | 125.610654 | 76.982561 | 0.0 | 2 | 1 | pool | 1 | 0 | 0 | 1 | 9875 |
| 9932 | 72.514956 | 159.248205 | 118.505187 | 0.0 | 1 | 5 | pool | 1 | 1 | 0 | 1 | 9932 |
| 9981 | 39.006118 | 133.419182 | 71.135407 | 0.0 | 1 | 4 | pool | 0 | 0 | 0 | 0 | 9981 |
| 9987 | 46.229664 | 160.430436 | 91.821367 | 0.0 | 1 | 2 | pool | 0 | 0 | 0 | 1 | 9987 |
2000 rows × 12 columns
Note that it is possible for the “balance” value to go up (hopefully only slightly) as the solver progresses. This behavior is due to rounding errors incurred when casting a continuous problem into the discrete space understood by the solver. The “balance” reported here is the actual balance computed to full accuracy on the original dataset; the “objective” value here is the actual quantity being optimized and should never increase.
[6]:
matcher.get_best_match()
[6]:
['age', 'height', 'weight']
Headers Categoric:
['gender', 'haircolor', 'country', 'binary_0', 'binary_1', 'binary_2', 'binary_3']
Populations
['pool', 'target']
| age | height | weight | gender | haircolor | country | population | binary_0 | binary_1 | binary_2 | binary_3 | patient_id | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 55.261578 | 139.396134 | 94.438359 | 0.0 | 2 | 2 | target | 0 | 0 | 1 | 1 | 10000 |
| 1 | 63.113091 | 165.563337 | 67.433016 | 1.0 | 2 | 2 | target | 0 | 1 | 1 | 0 | 10001 |
| 2 | 58.232216 | 160.859857 | 71.915385 | 1.0 | 0 | 2 | target | 0 | 0 | 0 | 0 | 10002 |
| 3 | 58.996941 | 140.357415 | 115.606615 | 1.0 | 0 | 3 | target | 1 | 1 | 0 | 0 | 10003 |
| 4 | 36.850195 | 189.983706 | 53.000581 | 0.0 | 2 | 5 | target | 0 | 0 | 0 | 0 | 10004 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 9874 | 71.869788 | 176.988908 | 108.680876 | 0.0 | 2 | 5 | pool | 0 | 0 | 0 | 0 | 9874 |
| 9875 | 61.252012 | 125.610654 | 76.982561 | 0.0 | 2 | 1 | pool | 1 | 0 | 0 | 1 | 9875 |
| 9932 | 72.514956 | 159.248205 | 118.505187 | 0.0 | 1 | 5 | pool | 1 | 1 | 0 | 1 | 9932 |
| 9981 | 39.006118 | 133.419182 | 71.135407 | 0.0 | 1 | 4 | pool | 0 | 0 | 0 | 0 | 9981 |
| 9987 | 46.229664 | 160.430436 | 91.821367 | 0.0 | 1 | 2 | pool | 0 | 0 | 0 | 1 | 9987 |
2000 rows × 12 columns
[7]:
%matplotlib inline
match = matcher.get_best_match()
m_data = m.copy().get_population('pool')
m_data.loc[:, 'population'] = m_data['population'] + ' (prematch)'
match.append(m_data)
# fig = plot_per_feature_loss(match, beta, 'target', debin=False)
fig = plot_numeric_features(match, hue_order=['pool (prematch)', 'pool', 'target', ])
fig = plot_categoric_features(match, hue_order=['pool (prematch)', 'pool', 'target'])
Optimize Beta With Cross Terms Added
Sometimes it helps to add a known (non-optimal) solution as a hint to the solver. A natural choice for hinting the solver is to take a solution from PS matching. We can choose to use the PS as a hint to the solver by passing ps_hinting=True. See the final section for a direct comparison against the propensity score solution.
[8]:
objective = beta_x = BetaXBalance(m)
matcher = matcher_betax = ConstraintSatisfactionMatcher(
m,
time_limit=time_limit,
objective=objective,
ps_hinting=True,
num_workers=4)
matcher.get_params()
INFO [preprocess.py:546] Added cross term height * weight to matching features.
INFO [preprocess.py:546] Added cross term gender * age to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * age to matching features.
INFO [preprocess.py:546] Added cross term binary_3 * weight to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * weight to matching features.
INFO [preprocess.py:546] Added cross term binary_1 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * height to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * binary_2 to matching features.
INFO [matcher.py:66] Scaling features by factor 240.00 in order to use integer solver with <= 0.3751% loss.
[8]:
{'objective': 'beta_x',
'pool_size': 1000,
'target_size': 1000,
'max_mismatch': None,
'time_limit': 60,
'num_workers': 4,
'ps_hinting': True,
'verbose': True}
[ ]:
matcher.match()
INFO [matcher.py:473] Solving for match population with pool size = 1000 and target size = 1000, optimizing balance (no max_mismatch cap).
INFO [matcher.py:477] Matching on 25 dimensions ...
INFO [matcher.py:484] Building model variables and constraints ...
INFO [matcher.py:493] Calculating bounds on feature variables ...
INFO [matcher.py:583] Applying size constraints on pool and target ...
INFO [matcher.py:589] Applying hint ...
INFO [matcher.py:596] Training PS model as guide for solver ...
INFO [preprocess.py:546] Added cross term height * weight to matching features.
INFO [preprocess.py:546] Added cross term gender * age to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * age to matching features.
INFO [preprocess.py:546] Added cross term binary_3 * weight to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * weight to matching features.
INFO [preprocess.py:546] Added cross term binary_1 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * binary_3 to matching features.
INFO [preprocess.py:546] Added cross term binary_2 * height to matching features.
INFO [preprocess.py:546] Added cross term binary_0 * binary_2 to matching features.
INFO [matcher.py:259] Training model SGDClassifier (iter 1/50, 0.0 s) ...
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: SGDClassifier
INFO [matcher.py:222] * alpha: 6.767053110717301
INFO [matcher.py:222] * class_weight: balanced
INFO [matcher.py:222] * early_stopping: True
INFO [matcher.py:222] * fit_intercept: False
INFO [matcher.py:222] * loss: log_loss
INFO [matcher.py:222] * max_iter: 1500
INFO [matcher.py:222] * penalty: elasticnet
INFO [matcher.py:223] Score (beta_x): 0.2294
INFO [matcher.py:224] Solution time: 0.1 s
INFO [matcher.py:259] Training model SGDClassifier (iter 2/50, 0.1 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 3/50, 0.2 s) ...
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: SGDClassifier
INFO [matcher.py:222] * alpha: 0.040132592392892075
INFO [matcher.py:222] * class_weight: balanced
INFO [matcher.py:222] * early_stopping: False
INFO [matcher.py:222] * fit_intercept: False
INFO [matcher.py:222] * loss: modified_huber
INFO [matcher.py:222] * max_iter: 1500
INFO [matcher.py:222] * penalty: l1
INFO [matcher.py:223] Score (beta_x): 0.0760
INFO [matcher.py:224] Solution time: 0.3 s
INFO [matcher.py:259] Training model LogisticRegression (iter 4/50, 0.3 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: LogisticRegression
INFO [matcher.py:222] * C: 48.73768493589444
INFO [matcher.py:222] * fit_intercept: False
INFO [matcher.py:222] * max_iter: 500
INFO [matcher.py:222] * penalty: l1
INFO [matcher.py:222] * solver: saga
INFO [matcher.py:223] Score (beta_x): 0.0626
INFO [matcher.py:224] Solution time: 1.4 s
INFO [matcher.py:259] Training model LogisticRegression (iter 5/50, 1.4 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 6/50, 2.2 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 7/50, 2.3 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 8/50, 3.4 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 9/50, 3.5 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 10/50, 3.7 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 11/50, 4.4 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 12/50, 5.2 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 13/50, 5.3 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 14/50, 5.4 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 15/50, 5.4 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 16/50, 5.5 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 17/50, 5.6 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 18/50, 6.2 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 19/50, 6.7 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 20/50, 6.8 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 21/50, 7.9 s) ...
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: SGDClassifier
INFO [matcher.py:222] * alpha: 0.08294085369181486
INFO [matcher.py:222] * class_weight: balanced
INFO [matcher.py:222] * early_stopping: True
INFO [matcher.py:222] * fit_intercept: True
INFO [matcher.py:222] * loss: log_loss
INFO [matcher.py:222] * max_iter: 1500
INFO [matcher.py:222] * penalty: l2
INFO [matcher.py:223] Score (beta_x): 0.0623
INFO [matcher.py:224] Solution time: 8.0 s
INFO [matcher.py:259] Training model SGDClassifier (iter 22/50, 8.1 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 23/50, 8.2 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 24/50, 8.9 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 25/50, 9.9 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 26/50, 10.0 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 27/50, 10.7 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 28/50, 10.8 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 29/50, 10.8 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 30/50, 11.0 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: LogisticRegression
INFO [matcher.py:222] * C: 84.43061879823632
INFO [matcher.py:222] * fit_intercept: False
INFO [matcher.py:222] * max_iter: 500
INFO [matcher.py:222] * penalty: l1
INFO [matcher.py:222] * solver: saga
INFO [matcher.py:223] Score (beta_x): 0.0595
INFO [matcher.py:224] Solution time: 12.1 s
INFO [matcher.py:259] Training model LogisticRegression (iter 31/50, 12.1 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 32/50, 12.4 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 33/50, 12.5 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 34/50, 12.5 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 35/50, 13.6 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 36/50, 13.7 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 37/50, 13.7 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 38/50, 13.8 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 39/50, 13.9 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 40/50, 14.0 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 41/50, 14.1 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 42/50, 14.1 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 43/50, 15.2 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 44/50, 15.3 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 45/50, 16.4 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 46/50, 16.5 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_logistic.py:1407: UserWarning: Inconsistent values: penalty=l1 with l1_ratio=0.0. penalty is deprecated. Please use l1_ratio only.
warnings.warn(
INFO [matcher.py:259] Training model SGDClassifier (iter 47/50, 17.5 s) ...
INFO [matcher.py:259] Training model SGDClassifier (iter 48/50, 17.6 s) ...
INFO [matcher.py:259] Training model LogisticRegression (iter 49/50, 17.6 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
sklearn/linear_model/_sag.py:348: ConvergenceWarning: The max_iter was reached which means the coef_ did not converge
warnings.warn(
INFO [matcher.py:259] Training model LogisticRegression (iter 50/50, 18.4 s) ...
sklearn/linear_model/_logistic.py:1381: FutureWarning: 'penalty' was deprecated in version 1.8 and will be removed in 1.10. To avoid this warning, leave 'penalty' set to its default value and use 'l1_ratio' or 'C' instead. Use l1_ratio=0 instead of penalty='l2', l1_ratio=1 instead of penalty='l1', l1_ratio set to a float between 0 and 1 instead of penalty='elasticnet', and C=np.inf instead of penalty=None.
warnings.warn(
INFO [matcher.py:219] Best propensity score match found:
INFO [matcher.py:220] Model: LogisticRegression
INFO [matcher.py:222] * C: 84.43061879823632
INFO [matcher.py:222] * fit_intercept: False
INFO [matcher.py:222] * max_iter: 500
INFO [matcher.py:222] * penalty: l1
INFO [matcher.py:222] * solver: saga
INFO [matcher.py:223] Score (beta_x): 0.0595
INFO [matcher.py:224] Solution time: 12.1 s
INFO [matcher.py:633] Hint achieves objective value = 144327.
INFO [matcher.py:635] Applying hints ...
INFO [matcher.py:239] Solving with 4 workers ...
INFO [matcher.py:91] Initial balance score: 0.2324
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 1, time = 3.2 s
INFO [matcher.py:102] Objective: 144327000.0
INFO [matcher.py:123] Balance (beta_x): 0.0595
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 2, time = 3.4 s
INFO [matcher.py:102] Objective: 144201000.0
INFO [matcher.py:123] Balance (beta_x): 0.0594
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 3, time = 3.5 s
INFO [matcher.py:102] Objective: 144174000.0
INFO [matcher.py:123] Balance (beta_x): 0.0595
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 4, time = 3.6 s
INFO [matcher.py:102] Objective: 143874000.0
INFO [matcher.py:123] Balance (beta_x): 0.0594
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 5, time = 3.8 s
INFO [matcher.py:102] Objective: 143192000.0
INFO [matcher.py:123] Balance (beta_x): 0.0591
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 6, time = 4.3 s
INFO [matcher.py:102] Objective: 142961000.0
INFO [matcher.py:123] Balance (beta_x): 0.0591
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 7, time = 4.4 s
INFO [matcher.py:102] Objective: 142612000.0
INFO [matcher.py:123] Balance (beta_x): 0.0589
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 8, time = 6.1 s
INFO [matcher.py:102] Objective: 142586000.0
INFO [matcher.py:123] Balance (beta_x): 0.0589
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 9, time = 8.0 s
INFO [matcher.py:102] Objective: 142449000.0
INFO [matcher.py:123] Balance (beta_x): 0.0588
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 10, time = 8.1 s
INFO [matcher.py:102] Objective: 142430000.0
INFO [matcher.py:123] Balance (beta_x): 0.0589
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 11, time = 8.3 s
INFO [matcher.py:102] Objective: 141983000.0
INFO [matcher.py:123] Balance (beta_x): 0.0586
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 12, time = 8.5 s
INFO [matcher.py:102] Objective: 141813000.0
INFO [matcher.py:123] Balance (beta_x): 0.0586
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 13, time = 8.9 s
INFO [matcher.py:102] Objective: 141776000.0
INFO [matcher.py:123] Balance (beta_x): 0.0585
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 14, time = 10.1 s
INFO [matcher.py:102] Objective: 141575000.0
INFO [matcher.py:123] Balance (beta_x): 0.0585
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 15, time = 10.6 s
INFO [matcher.py:102] Objective: 141462000.0
INFO [matcher.py:123] Balance (beta_x): 0.0586
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 16, time = 11.2 s
INFO [matcher.py:102] Objective: 141360000.0
INFO [matcher.py:123] Balance (beta_x): 0.0584
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 17, time = 11.9 s
INFO [matcher.py:102] Objective: 141315000.0
INFO [matcher.py:123] Balance (beta_x): 0.0585
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 18, time = 12.3 s
INFO [matcher.py:102] Objective: 141278000.0
INFO [matcher.py:123] Balance (beta_x): 0.0584
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 19, time = 15.0 s
INFO [matcher.py:102] Objective: 141077000.0
INFO [matcher.py:123] Balance (beta_x): 0.0584
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 20, time = 16.1 s
INFO [matcher.py:102] Objective: 141002000.0
INFO [matcher.py:123] Balance (beta_x): 0.0586
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 21, time = 16.8 s
INFO [matcher.py:102] Objective: 140697000.0
INFO [matcher.py:123] Balance (beta_x): 0.0583
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 22, time = 17.3 s
INFO [matcher.py:102] Objective: 140696000.0
INFO [matcher.py:123] Balance (beta_x): 0.0585
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 23, time = 17.8 s
INFO [matcher.py:102] Objective: 140655000.0
INFO [matcher.py:123] Balance (beta_x): 0.0585
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 24, time = 18.0 s
INFO [matcher.py:102] Objective: 140583000.0
INFO [matcher.py:123] Balance (beta_x): 0.0584
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 25, time = 18.2 s
INFO [matcher.py:102] Objective: 140418000.0
INFO [matcher.py:123] Balance (beta_x): 0.0584
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 26, time = 19.0 s
INFO [matcher.py:102] Objective: 140316000.0
INFO [matcher.py:123] Balance (beta_x): 0.0582
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 27, time = 20.5 s
INFO [matcher.py:102] Objective: 140073000.0
INFO [matcher.py:123] Balance (beta_x): 0.0583
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 28, time = 22.3 s
INFO [matcher.py:102] Objective: 139993000.0
INFO [matcher.py:123] Balance (beta_x): 0.0581
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 29, time = 23.1 s
INFO [matcher.py:102] Objective: 139828000.0
INFO [matcher.py:123] Balance (beta_x): 0.0582
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 30, time = 23.4 s
INFO [matcher.py:102] Objective: 139775000.0
INFO [matcher.py:123] Balance (beta_x): 0.0581
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 31, time = 24.8 s
INFO [matcher.py:102] Objective: 139659000.0
INFO [matcher.py:123] Balance (beta_x): 0.0582
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 32, time = 25.7 s
INFO [matcher.py:102] Objective: 139455000.0
INFO [matcher.py:123] Balance (beta_x): 0.0581
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 33, time = 26.3 s
INFO [matcher.py:102] Objective: 139377000.0
INFO [matcher.py:123] Balance (beta_x): 0.0579
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 34, time = 28.3 s
INFO [matcher.py:102] Objective: 139180000.0
INFO [matcher.py:123] Balance (beta_x): 0.0579
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 35, time = 29.1 s
INFO [matcher.py:102] Objective: 138950000.0
INFO [matcher.py:123] Balance (beta_x): 0.0579
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 36, time = 31.2 s
INFO [matcher.py:102] Objective: 138906000.0
INFO [matcher.py:123] Balance (beta_x): 0.0581
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 37, time = 31.6 s
INFO [matcher.py:102] Objective: 138740000.0
INFO [matcher.py:123] Balance (beta_x): 0.0578
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 38, time = 31.8 s
INFO [matcher.py:102] Objective: 138699000.0
INFO [matcher.py:123] Balance (beta_x): 0.0580
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 39, time = 31.9 s
INFO [matcher.py:102] Objective: 138624000.0
INFO [matcher.py:123] Balance (beta_x): 0.0579
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 40, time = 32.5 s
INFO [matcher.py:102] Objective: 138389000.0
INFO [matcher.py:123] Balance (beta_x): 0.0577
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
INFO [matcher.py:97] =========================================
INFO [matcher.py:98] Solution 41, time = 32.6 s
INFO [matcher.py:102] Objective: 138348000.0
INFO [matcher.py:123] Balance (beta_x): 0.0579
INFO [matcher.py:128] Patients (pool): 1000
INFO [matcher.py:130] Patients (target): 1000
INFO [matcher.py:146]
[ ]:
%matplotlib inline
match = matcher.get_best_match()
m_data = m.copy().get_population('pool')
m_data.loc[:, 'population'] = m_data['population'] + ' (prematch)'
match.append(m_data)
fig = plot_per_feature_loss(match, objective, 'target', debin=False)
Optimize Gamma (Area Between CDFs)
[ ]:
objective = gamma = GammaBalance(m)
matcher = matcher_gamma = ConstraintSatisfactionMatcher(
m,
time_limit=time_limit,
objective=objective,
ps_hinting=True,
num_workers=4)
matcher.get_params()
[ ]:
matcher.match()
[ ]:
%matplotlib inline
match = matcher.get_best_match()
m_data = m.copy().get_population('pool')
m_data.loc[:, 'population'] = m_data['population'] + ' (prematch)'
match.append(m_data)
fig = plot_per_feature_loss(match, objective, 'target', debin=False)
fig = plot_numeric_features(match, hue_order=['pool (prematch)', 'pool', 'target', ])
fig = plot_categoric_features(match, hue_order=['pool (prematch)', 'pool', 'target'])
Improve Upon Propensity Score Matching
Because the PropensityScoreMatcher doesn’t directly optimize balance, it only achieves good balance when we find the right propensity score model. Depending on how we’ve parameterized the space of possible propensity score models, we may in fact never find the right model. This often leaves residual confounding that cannot be removed via propensity score matching.
Here we use the propensity score match as a seed (hint) for the ConstraintSatisfactionMatcher with ps_hinting=True, and optimize beta. The solver starts from the propensity score solution and can only improve upon it.
[ ]:
from pybalance.propensity import PropensityScoreMatcher
objective = beta = BetaBalance(m)
ps_matcher = PropensityScoreMatcher(
matching_data=m,
objective=objective,
time_limit=time_limit,
max_iter=100)
ps_matcher.match()
[ ]:
matcher = matcher_ps_seeded = ConstraintSatisfactionMatcher(
m,
time_limit=time_limit,
objective=objective,
ps_hinting=True,
num_workers=4)
matcher.get_params()
[ ]:
matcher.match()
The reported balance is much better than that of the propensity score solution that seeded the solver. We also confirm this result visually below.
[ ]:
%matplotlib inline
match = matcher.get_best_match()
m_data = m.copy().get_population('pool')
m_data.loc[:, 'population'] = m_data['population'] + ' (prematch)'
match.append(m_data)
fig = plot_per_feature_loss(match, beta, 'target', debin=False)
fig = plot_numeric_features(match, hue_order=['pool (prematch)', 'pool', 'target'])
fig = plot_categoric_features(match, hue_order=['pool (prematch)', 'pool', 'target'])