Uplift
Example 1
Summary: Creates an uplift model to analyze the impact of a promotion on purchase behavior, utilizing predictor variables such as gender, age, hair color, U.S. region, and residence.
Code:
dt under test = Open("data_table.jmp");
obj = Uplift(
Treatment( :Promotion ),
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Informative Missing( 1 ),
SendToReport(
Dispatch( {}, "2", ScaleBox, {Min( 0 ), Max( 0.03 ), Inc( 0.025 ), Minor Ticks( 0 ), Add Ref Line( 0.025, "Solid", "Black", 1 )} )
)
);
Code Explanation:
- Open data table.
- Create uplift object.
- Define treatment variable.
- Set response variable.
- Specify predictor variables.
- Handle missing data.
- Customize report settings.
- Set axis minimum value.
- Set axis maximum value.
- Set axis increment value.
Example 2
Summary: Fits a nominal logistic regression model using JMP's Uplift function, specifying treatment and response variables, predictor variables, validation variable, and initial splits.
Code:
dt = Open("data_table.jmp");
Uplift(
Treatment( :Promotion ),
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Validation( :Validation ),
Split History( 1 ),
Informative Missing( 1 ),
Uplift Graph( 1 ),
Initial Splits( :Gender == {"Female"}, {:Hair Color == {"Brown", "Black", "Red"}, {}, {:Age >= 42}}, {:Residence == {"Rural"}} ),
SendToReport(
Dispatch( {}, "2", ScaleBox, {Format( "Custom", Formula( Round( Normal Density( value ), 2 ) ), 12 )} ),
Dispatch( {"Uplift Graph"}, "2", ScaleBox,
{Format( "Custom", Formula( Char( value * 100 ) || "/100" ), 12 ), Min( -0.01 ), Max( 0.0225 ), Inc( 0.005 ), Minor Ticks( 1 )}
)
)
);
Code Explanation:
- Open data table.
- Call Uplift function.
- Define treatment variable.
- Define response variable.
- Specify predictor variables.
- Define validation variable.
- Set split history option.
- Enable informative missing values.
- Enable uplift graph.
- Define initial splits.
Example 3
Summary: Fits a nominal logistic regression model to predict Purchase based on Gender, Age, Hair Color, U.S. Region, and Residence, with Promotion as the treatment variable.
Code:
dt under test = Open("data_table.jmp");
obj = Uplift(
Treatment( :Promotion ),
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Validation( :Validation ),
Leaf Report( 1 ),
Show Fit Details( 1 ),
Informative Missing( 1 ),
Column Contributions( 1 ),
Initial Splits( :Age >= 42, {:Hair Color == {"Black", "Red", "Brown"}, {:Gender == {"Female"}}}, {:Gender == {"Female"}} ),
SendToReport(
Dispatch( {}, "Uplift Model for Purchase", OutlineBox,
{Set Title( "Leaf Report, Column Contributions, Show Fit Details, Do not points" )}
),
Dispatch( {}, "2", ScaleBox, {Min( 0 ), Max( 0.03 ), Inc( 0.025 ), Minor Ticks( 0 )} )
)
);
Code Explanation:
- Open data table;
- Run Uplift analysis.
- Set Promotion as treatment.
- Set Purchase as outcome.
- Include Gender, Age, Hair Color, U.S. Region, Residence as predictors.
- Use Validation column for validation.
- Enable leaf report.
- Show fit details.
- Handle informative missing data.
- Display column contributions.
If
Summary: Executes Uplift analysis with varying treatment and validation settings, iterating four times to generate distinct results.
Code:
If( Contains( JMP Product Name(), "Pro" ),
For( i = 1, i <= 4, i++,
dt = Open("data_table.jmp");
win lst1 = Associative Array( Window() << get window title );
Match( i,
1, obj = dt << Uplift( Y( :Purchase ), X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ), Treatment( :Promotion ) ),
2,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Split Best( 1 )
),
3,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Validation( :Validation ),
),
4,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Validation( :Validation ),
Split Best( 1 )
)
);
win lst2 = Associative Array( Window() << get window title );
win lst2 << Remove( win lst1 );
aftlst = win lst2 << get keys;
Close( dt, no save );
)
);
Code Explanation:
- Check if JMP version is Pro.
- Loop 4 times.
- Open data table;
- Get current window titles.
- Run Uplift analysis based on loop index.
- Get new window titles.
- Remove old window titles from new list.
- Get remaining window titles.
- Close data table without saving.
- Repeat loop.
Uplift using Associative Array
Summary: Executes Uplift analysis with varying treatment and validation settings, generating a series of windows for data exploration.
Code:
dt = Open("data_table.jmp");
win lst1 = Associative Array( Window() << get window title );
i = 1;
Match( i,
1, obj = dt << Uplift( Y( :Purchase ), X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ), Treatment( :Promotion ) ),
2,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Split Best( 1 )
),
3,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Validation( :Validation ),
),
4,
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Validation( :Validation ),
Split Best( 1 )
)
);
win lst2 = Associative Array( Window() << get window title );
win lst2 << Remove( win lst1 );
aftlst = win lst2 << get keys;
Code Explanation:
- Open data table.
- Create associative array of windows.
- Initialize counter variable.
- Match counter value to execute Uplift analysis.
- Assign Uplift object to variable.
- Create another associative array of windows.
- Remove initial windows from new array.
- Get remaining window keys.
- Store result in variable.