Skip to content

Commit 4e3f468

Browse files
committed
📝 Add comments
1 parent c1160e4 commit 4e3f468

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sklift/metrics/metrics.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ def perfect_uplift_curve(y_true, treatment):
8787
check_consistent_length(y_true, treatment)
8888
y_true, treatment = np.array(y_true), np.array(treatment)
8989

90-
CR_num = np.sum((y_true == 1) & (treatment == 0)) # Control Responders
91-
TN_num = np.sum((y_true == 0) & (treatment == 1)) # Treated Non-Responders
90+
cr_num = np.sum((y_true == 1) & (treatment == 0)) # Control Responders
91+
tn_num = np.sum((y_true == 0) & (treatment == 1)) # Treated Non-Responders
9292

93-
summand = y_true if CR_num > TN_num else treatment
93+
# express an ideal uplift curve through y_true and treatment
94+
summand = y_true if cr_num > tn_num else treatment
9495
perfect_uplift = 2 * (y_true == treatment) + summand
9596

9697
return uplift_curve(y_true, perfect_uplift, treatment)
@@ -227,6 +228,7 @@ def perfect_qini_curve(y_true, treatment, negative_effect=True):
227228
if not isinstance(negative_effect, bool):
228229
raise TypeError(f'Negative_effects flag should be bool, got: {type(negative_effect)}')
229230

231+
# express an ideal uplift curve through y_true and treatment
230232
if negative_effect:
231233
x_perfect, y_perfect = qini_curve(
232234
y_true, y_true * treatment - y_true * (1 - treatment), treatment

0 commit comments

Comments
 (0)