Split
Split using Data Table
Example 1
Summary: Opens a data table, splits the data by Drug Type and Measurement, groups by Subject, and performs no further analysis.
Code:
// Split
// Open data table
dt = Open("data_table.jmp");
// Split
Data Table("data_table") <<
Split(
Split By( :Drug Type ),
Split( :Measurement ),
Group( :Subject )
);
Code Explanation:
- Open table.
- Split data by Drug Type.
- Split Measurement.
- Group by Subject.
Example 2
Summary: Runs data splitting and grouping operations on a data table, utilizing the Split By transformation to separate data by trial^3 and yield^3 transformations, and then sorting the resulting data by value order.
Code:
Open("data_table.jmp");
Data Table("data_table") << Split(
Split By( Transform Column( "trial^3", Formula( :trial ^ 3 ) ) ),
Split( Transform Column( "yield^3", Formula( :yield ^ 3 ) ) ),
Group( Transform Column( "Last[batch]", Character, Formula( Word( -1, :batch ) ) ) ),
Remaining Columns( Drop All ),
Sort by Value Order
);
Code Explanation:
- Open data_table data
- Access data_table data table.
- Split data table by trial^3 transformation.
- Split data table by yield^3 transformation.
- Group data by last batch character.
- Drop all remaining columns.
- Sort data by value order.
Split using Uplift
Example 1
Summary: Fits a nominal logistic regression model using the Uplift function in JMP, specifying predictor variables and treatment variable while handling informative missing data.
Code:
// Initial Uplift Report
// Open data table
dt = Open("data_table.jmp");
// Initial Uplift Report
Uplift(
Y( :Purchase ),
X(
:Gender, :Age, :Hair Color,
:U.S. Region, :Residence
),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Split History( 1 ),
Informative Missing( 1 )
);
Code Explanation:
- Open data table.
- Call Uplift function.
- Set response variable.
- Define predictor variables.
- Specify validation column.
- Set minimum split size.
- Identify treatment variable.
- Enable split history.
- Handle informative missing data.
Example 2
Summary: Fits a nominal logistic regression model to predict the probability of a purchase based on demographic and geographic variables, utilizing an uplift graph for visualization.
Code:
// Uplift
// Open data table
dt = Open("data_table.jmp");
// Uplift
Uplift(
Y( :Purchase ),
X(
:Gender, :Age, :Hair Color,
:U.S. Region, :Residence
),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Split History( 1 ),
Informative Missing( 1 ),
Uplift Graph( 1 ),
Split Best( 4 )
);
Code Explanation:
- Open table.
- Define response variable.
- Define predictor variables.
- Specify validation column.
- Set minimum split size.
- Identify treatment variable.
- Enable split history.
- Handle informative missing data.
- Generate uplift graph.
- Use best split method.
Example 3
Summary: Fits a nominal logistic regression model using Uplift analysis to predict the effect of promotion on purchase behavior, with interactive features for customizing report scales and frame sizes.
Code:
dt = Open("data_table.jmp");
obj = Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Show Points( 1 ),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Split History( 1 ),
Informative Missing( 1 ),
Uplift Graph( 1 ),
Initial Splits( :Age >= 42, {:Hair Color == {"Black", "Red", "Brown"}, {:Gender == {"Female"}}}, {:Gender == {"Female"}} ),
SendToReport(
Dispatch( {}, "2", ScaleBox, {Min( 0 ), Max( 0.03 ), Inc( 0.025 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} ),
Dispatch( {}, FrameBox, {Frame Size( 808, 255 )} ),
Dispatch( {}, FrameBox( 2 ), {Frame Size( 808, 182 )} ),
Dispatch( {"Split History"}, "1", ScaleBox, {Min( 0 ), Max( 14 ), Inc( 2 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} )
)
);
Code Explanation:
- Open data table.
- Run Uplift analysis.
- Set response variable.
- Define predictor variables.
- Display points.
- Use validation column.
- Set minimum split size.
- Identify treatment group.
- Include split history.
- Handle missing values informatively.
- Generate uplift graph.
- Specify initial splits.
- Customize report scale.
- Adjust frame size.
- Adjust second frame size.
- Customize split history scale.
Example 4
Summary: Fits a nominal logistic regression model using Uplift analysis to predict the likelihood of a customer purchasing a product based on demographic factors.
Code:
dt under test = Open("data_table.jmp");
obj = Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Show Points( 1 ),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Split History( 1 ),
Informative Missing( 1 ),
Uplift Graph( 1 ),
Initial Splits( :Age >= 42, {:Hair Color == {"Black", "Red", "Brown"}, {:Gender == {"Female"}}}, {:Gender == {"Female"}} ),
SendToReport(
Dispatch( {}, "2", ScaleBox, {Min( 0 ), Max( 0.03 ), Inc( 0.025 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} ),
Dispatch( {}, FrameBox, {Frame Size( 808, 255 )} ),
Dispatch( {}, FrameBox( 2 ), {Frame Size( 808, 182 )} ),
Dispatch( {"Split History"}, "1", ScaleBox, {Min( 0 ), Max( 14 ), Inc( 2 ), Minor Ticks( 0 ), Rotated Labels( "Horizontal" )} )
)
);
Code Explanation:
- Open data table.
- Run Uplift analysis.
- Specify response variable.
- Define predictor variables.
- Display points on graph.
- Use validation column.
- Set minimum split size.
- Identify treatment group.
- Include split history.
- Handle missing data informatively.
Split using Run Script
Example 1
Summary: Creates a bubble plot by region, with the Midwest region split for analysis.
Code:
dt = Open("data_table.jmp");
bp = dt << Run Script( "Bubble Plot by Region" );
bp << Split( "Midwest" );
Code Explanation:
- Open data table.
- Run bubble plot script.
- Split plot by Midwest.
Example 2
Summary: Creates a bubble plot by region, splitting data into Midwest and South regions using the Run Script function in JMP.
Code:
dt = Open("data_table.jmp");
bp = dt << Run Script( "Bubble Plot by Region" );
bp << Split( "Midwest" );
bp << Split( "South" );
Code Explanation:
- Open table.
- Run bubble plot script.
- Split by Midwest.
- Split by South.
Example 3
Summary: Creates a bubble plot by region, splitting and combining data for Midwest and South regions.
Code:
dt = Open("data_table.jmp");
bp = dt << Run Script( "Bubble Plot by Region" );
bp << Split( "Midwest" );
bp << Split( "South" );
bp << Combine( "Midwest" );
Code Explanation:
- Open table.
- Run script for bubble plot.
- Split bubble plot by Midwest.
- Split bubble plot by South.
- Combine bubble plot for Midwest.
Split using Stack
Summary: Runs data stacking and splitting operations to transform a raw data table into a stacked and split output table, utilizing the ID column for stacking and sex and ID columns for splitting.
Code:
dt = Open("data_table.jmp");
dt1 = dt << Stack( Stack( :height, :weight ), id( "ID" ), Stacked( "Y" ), Output table name( "stacked" ) );
dt2 = dt1 << Split( split( y, sex ), split by( ID ), output table name( "Split" ) );
Code Explanation:
- Open data table;
- Stack height and weight.
- Use ID for stacking.
- Name stacked column "Y".
- Output table named "stacked".
- Split stacked data.
- Split by sex.
- Split by ID.
- Output table named "Split".
Example 1
Summary: Creates a child table by splitting a data table based on age, sex, and including specific columns.
Code:
dt = Open("data_table.jmp");
dtchild = dt << Split( Split By( :age ), Split( :sex, :height, :weight ), Remaining Columns( Drop All ) );
Code Explanation:
- Open data table.
- Create child table from split.
- Split by age column.
- Further split by sex column.
- Include height and weight columns.
- Drop all remaining columns.
Example 2
Summary: Runs data splitting and grouping operations to analyze measurements by drug type, measurement, and subject, while setting value ordering for drug types.
Code:
dt = Open("data_table.jmp");
splitDt = dt << Split( Split By( :Drug Type ), Split( :Measurement ), Group( :Subject ), Sort by Value Order );
colnames = splitDt << get column names;
Close( splitDt, no save );
dt:drug type << Set Property( "Value Ordering", {"c", "b", "a"} );
splitDt = dt << Split( Split By( :Drug Type ), Split( :Measurement ), Group( :Subject ), Sort by Value Order );
colnames = splitDt << get column names;
Code Explanation:
- Open data table.
- Split data by drug type.
- Split data by measurement.
- Group data by subject.
- Sort by value order.
- Get column names.
- Close split table without saving.
- Set value ordering for drug type.
- Split data again by drug type.
- Split data again by measurement.
- Group data again by subject.
- Sort by value order again.
- Get column names again.
Example 3
Summary: Runs the splitting and subseting of a data table based on state and year, then saves the result to a temporary file.
Code:
dt = Open("data_table.jmp");
splitDt = dt << Split( Split By( :State ), Split( :Name( "1980" ) ), Output Table( "Test 1" ), Remaining Columns( Drop All ) );
subDt = splitDt << Subset( All rows, Selected columns only( 0 ) );
splitDt << Save( "$TEMP/test1.jmp" );
Code Explanation:
- Open data table.
- Split by state.
- Split by 1980 column.
- Name output table "Test 1".
- Drop all remaining columns.
- Create subset with selected columns.
- Save subset to temporary file.
Split using Log Capture
Summary: Runs data splitting and outputting a table named 'Yield column split by Trial Column' based on trial and oil amount, with the yield column also split.
Code:
Open("data_table.jmp");
logString = Log Capture(
dtSplit = dt << Split( Split By( :trial, :oil amt ), Split( :yield ), Output Table( "Yield column split by Trial Column" ) )
);
Code Explanation:
- Open data_table data
- Capture log output.
- Split data by trial and oil amt.
- Split yield column.
- Output split table named "Yield column split by Trial Column".
Split using Set Property
Example 1
Summary: Runs data splitting and ordering operations to create a new table with customized columns, utilizing the Split By and Set Property functions in JMP Scripting Language.
Code:
dt = Open("data_table.jmp");
dt:drug type << Set Property( "Value Ordering", {"c", "b", "a"} );
splitDt = dt << Split( Split By( :Drug Type ), Split( :Measurement ), Group( :Subject ) );
colnames = splitDt << get column names;
Close( dt, no save );
Close( splitDt, no save );
dt = New Table( "Ordering",
Add Rows( 21 ),
New Column( "Week Day",
Character,
Nominal,
Set Property( "Value Ordering", {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"} ),
Set Values(
{"Monday", "Monday", "Monday", "Tuesday", "Tuesday", "Tuesday", "Wednesday", "Wednesday", "Wednesday", "Thursday", "Thursday",
"Thursday", "Friday", "Friday", "Friday", "Saturday", "Saturday", "Saturday", "Sunday", "Sunday", "Sunday"}
)
),
New Column( "Data",
Numeric,
Continuous,
Format( "Best", 12 ),
Set Values( [111, 222, 333, 444, 555, 666, 777, 888, 999, 111, 222, 333, 444, 555, 666, 777, 888, 999, 111, 222, 333] )
)
);
splitDt = dt << Split( Split By( :Week Day ), Split( :Data ), Output Table( "Test" ), Sort by Value Order );
colnames = splitDt << Get Column Names;
Code Explanation:
- Open data table.
- Set value ordering for drug type.
- Split data by drug type and measurement.
- Get column names from split table.
- Close original data table without saving.
- Close split data table without saving.
- Create new table "Ordering".
- Add rows to new table.
- Add "Week Day" column with value ordering.
- Add "Data" column with numeric values.
Example 2
Summary: Prepares data by opening a table, setting drug type ordering, splitting data by drug type and measurement, grouping by subject, and retrieving column names.
Code:
dt = Open("data_table.jmp");
dt:drug type << Set Property( "Value Ordering", {"c", "b", "a"} );
splitDt = dt << Split( Split By( :Drug Type ), Split( :Measurement ), Group( :Subject ) );
colnames = splitDt << get column names;
Code Explanation:
- Open table.
- Set drug type ordering.
- Split data by drug type.
- Split data by measurement.
- Group data by subject.
- Retrieve column names.
Split using Expr
Example 1
Summary: Process of splitting a data table by sex, age, and country, allowing users to select columns for grouping and aggregation.
Code:
Open("data_table.jmp");
split = Expr(
dt << Split( Split By( :sex ), Split( :age ), Group( ::b << Get Items, :country ) )
);
New Window( "Pick 'Type'",
Text Box( "Select the Type column, click >>, and then click OK." ),
H List Box(
::a = Col List Box( all ),
Button Box( ">>", ::b << Append( ::a << GetSelected ) ),
::b = Col List Box()
),
Button Box( "OK", split )
);
::a << close window;
Delete Symbols( ::a, ::b );
Code Explanation:
- Open data table;
- Define
splitexpression for splitting data. - Create new window titled "Pick 'Type'".
- Display instruction text box.
- Initialize horizontal list box.
- Add source column list box.
- Add ">>" button to move selected columns.
- Add destination column list box.
- Add "OK" button to execute split operation.
- Close source column list box.
- Delete symbols
::aand::b.
Example 2
Summary: Runs the splitting of a data table by sex, age, and country, allowing users to select the Type column and execute the split operation.
Code:
Open("data_table.jmp");
split = Expr(
dt << Split( Split By( :sex ), Split( :age ), Group( ::b << Get Items, :country ) )
);
New Window( "Pick 'Type'",
Text Box( "Select the Type column, click >>, and then click OK." ),
H List Box( ::a = Col List Box( all ), Button Box( ">>", ::b << Append( ::a << GetSelected ) ), ::b = Col List Box() ),
Button Box( "OK", split )
);
Code Explanation:
- Open data table;
- Define
splitexpression. - Create new window titled "Pick 'Type'".
- Add text box instruction.
- Create horizontal list box.
- Add "Type" column list box.
- Add ">>" button.
- Add second column list box.
- Add "OK" button.
- Execute
spliton button click.
Split using If
Example 1
Summary: Runs uplift analysis and prediction formula generation for a given dataset, utilizing the JMP Pro platform to extract probabilities, most likely purchases, and difference formulas.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
n1 = N Items( dt << get column names( string ) );
obj = dt << Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Treatment( :Promotion ),
Split Best( 1 )
);
obj << Save Prediction Formula( 1 );
prob1 = (dt:Name( "Prob(Purchase==Yes)" ) << get values) || (dt:Name( "Prob(Purchase==No)" ) << get values);
pred1 = dt:Most Likely Purchase << get values( 1 );
obj << Save Difference Formula( 1 );
diff1 = dt:Name( "Difference Prob(Purchase==Yes)" ) << get values;
dt << Delete Columns( n1 + 1 :: N Cols( dt ) );
depot1 = obj << Publish Prediction Formula( 1 );
depot1 << Run Script( 1 );
prob2 = (dt:Name( "Prob(Purchase==Yes)" ) << get values) || (dt:Name( "Prob(Purchase==No)" ) << get values);
pred2 = dt:Most Likely Purchase << get values( 1 );
depot2 = obj << Publish Difference Formula( 1 );
depot2 << Run Script( 1 );
diff2 = dt:Name( "Difference Prob(Purchase==Yes)" ) << get values;
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
obj = dt << Uplift( Y( :Y ), X( :F, :Ct, :A, :Cn ), Minimum Size Split( 2 ), Treatment( :T ), Split Best( 2 ) );
obj << Save Prediction Formula( 1 );
pred1 = dt:Y Predictor << get values( 1 );
obj << Save Difference Formula( 1 );
diff1 = dt:Name( "Y Difference Formula" ) << get values;
dt << Delete Columns( n1 + 1 :: N Cols( dt ) );
depot3 = obj << Publish Prediction Formula( 1 );
depot3 << Run Script( 1 );
pred2 = dt:Y Predictor << get values( 1 );
depot4 = obj << Publish Difference Formula( 1 );
depot4 << Run Script( 1 );
diff2 = dt:Name( "Y Difference Formula" ) << get values;
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
Code Explanation:
- Check if JMP is Pro version.
- Open data table;
- Count initial columns.
- Perform uplift analysis.
- Save prediction formula.
- Extract probabilities.
- Extract most likely purchase.
- Save difference formula.
- Extract difference probabilities.
- Delete new columns.
- Publish prediction formula.
- Run published script.
- Extract updated probabilities.
- Extract updated most likely purchase.
- Publish difference formula.
- Run published script.
- Extract updated difference probabilities.
- Close dataset without saving.
- Close Formula Depot window.
- Repeat for Reactor.jmp dataset.
Example 2
Summary: Runs Uplift analysis with predictors F, Ct, A, Cn and treatment variable T to generate reports and extract column uplift contributions matrices.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
obj1 = dt << Uplift(
Y( :Y ),
X( :F, :Ct, :A, :Cn ),
Treatment( :T ),
Minimum Size Split( 2 ),
Informative Missing( 1 ),
Split Best( 1 )
);
rpt1 = Report( obj1 );
obj1 << Column Contributions( 1 );
cc1 = rpt1[Outline Box( "Column Uplift Contributions" )][Table Box( 1 )] << get as matrix;
root lw1 = Matrix( rpt1[Table Box( 3 )][Number Col Box( 3 )] << get );
leaf1 lw1 = Matrix( rpt1[Outline Box( 2 )][Number Col Box( 1 )] << get );
obj2 = dt << Uplift(
Y( :Y ),
X( :F, :Ct, :A, :Cn ),
Treatment( :T ),
Minimum Size Split( 2 ),
Informative Missing( 1 ),
Initial Splits( :Ct < 1 ),
);
rpt2 = Report( obj2 );
obj2 << Column Contributions( 1 );
cc2 = rpt2[Outline Box( "Column Uplift Contributions" )][Table Box( 1 )] << get as matrix;
root lw2 = Matrix( rpt2[Table Box( 3 )][Number Col Box( 3 )] << get );
leaf1 lw2 = Matrix( rpt2[Outline Box( 2 )][Number Col Box( 1 )] << get );
obj1 << Prune Worst( 1 );
obj2 << Prune Worst( 1 );
rmse1 = Matrix( rpt1[Table Box( 1 )][Number Col Box( 2 )] << get );
rmse2 = Matrix( rpt2[Table Box( 1 )][Number Col Box( 2 )] << get );
Close( dt, no save );
);
Code Explanation:
- Check for JMP Pro.
- Open data table.
- Perform Uplift analysis on Y with predictors F, Ct, A, Cn.
- Set treatment variable T.
- Define minimum size split as 2.
- Enable informative missing data.
- Use split best method.
- Generate report from Uplift analysis.
- Enable column contributions.
- Extract column uplift contributions matrix.
- Retrieve root lift weights.
- Retrieve leaf lift weights.
- Repeat Uplift analysis with initial split on Ct < 1.
- Generate second report.
- Enable column contributions again.
- Extract second column uplift contributions matrix.
- Retrieve second root lift weights.
- Retrieve second leaf lift weights.
- Prune worst contribution from first analysis.
- Prune worst contribution from second analysis.
- Extract RMSE from first analysis.
- Extract RMSE from second analysis.
- Close data table without saving.
Example 3
Summary: Executes two Uplift analyses with customized settings, generating reports and extracting column contributions and formats.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
obj1 = Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Informative Missing( 1 ),
Split Best( 2 )
);
obj1 << Column Contributions( 1 );
rpt1 = Report( obj1 );
contrib1 = rpt1[Outline Box( "Column Uplift Contributions" )][Table Box( 1 )] << get as matrix;
fmt1 = rpt1[Outline Box( "Column Uplift Contributions" )][Number Col Box( 2 )] << get format;
obj2 = Uplift(
Y( :Purchase ),
X( :Gender, :Age, :Hair Color, :U.S. Region, :Residence ),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Informative Missing( 1 ),
Column Contributions( 1 )
);
obj2 << Split Best( 2 );
rpt2 = Report( obj2 );
contrib2 = rpt2[Outline Box( "Column Uplift Contributions" )][Table Box( 1 )] << get as matrix;
fmt2 = rpt2[Outline Box( "Column Uplift Contributions" )][Number Col Box( 2 )] << get format;
Close( dt, no save );
);
Code Explanation:
- Check if JMP version is Pro.
- Open data table;
- Run first Uplift analysis.
- Set column contributions.
- Generate first report.
- Extract column contributions from first report.
- Extract format from first report.
- Run second Uplift analysis.
- Set split best to 2.
- Close dataset without saving.
Example 4
Summary: Creates and analyzes an uplift report in JMP Pro, utilizing data table manipulation and prediction formula saving.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
obj = dt << Run Script( "Initial Uplift Report" );
obj << Save Prediction Formula;
prop1 = Char( dt:Name( "Prob(Purchase==Yes)" ) << get property( Response Probability ) );
prop2 = Char( dt:Name( "Prob(Purchase==No)" ) << get property( Response Probability ) );
obj2 = dt << Uplift(
Y( :Age ),
X( :Gender, :Hair Color, :U.S. Region, :Residence ),
Validation( :Validation ),
Minimum Size Split( 63 ),
Treatment( :Promotion ),
Split Best( 2 )
);
obj2 << Save Prediction Formula;
prop3 = Char( dt:Age Predictor << get property( Predicting ) );
Close( dt, no save );
);
Code Explanation:
- Check for JMP Pro version.
- Open data_table data
- Run "Initial Uplift Report" script.
- Save prediction formula from report.
- Get "Prob(Purchase==Yes)" property.
- Get "Prob(Purchase==No)" property.
- Create uplift analysis object.
- Save prediction formula from uplift analysis.
- Get "Age Predictor" property.
- Close data table without saving.
Example 5
Summary: Runs the uplift analysis process by opening a data table, performing an uplift model, and generating a report with extracted text.
Code:
If( Contains( JMP Product Name(), "Pro" ),
dt = Open("data_table.jmp");
obj = dt << Uplift( Y( :Y ), X( :F, :Ct, :A, :Cn ), Treatment( :T ), Informative Missing( 1 ), Minimum Size Split( 5 ) );
obj << Save Script to Report;
rpt = Report( obj );
saved1 = rpt[Outline Box( "Uplift Model for Y" )][Text Box( 1 )] << get text;
Close( dt, no save );
);
Code Explanation:
- Check if JMP is Pro.
- Open data table;
- Perform Uplift analysis.
- Save script to report.
- Generate report from object.
- Extract text from report.
- Close dataset without saving.