Association Analysis
Example 1
Summary: Associates product with customer ID using the Association Analysis platform, analyzing the relationship between these variables in a data table.
Code:
// Association Analysis of Product
// Open data table
dt = Open("data_table.jmp");
// Association Analysis of Product
Association Analysis(
Item( :Product ),
ID( :Customer ID )
);
Code Explanation:
- Open table.
- Perform association analysis.
- Use Product column.
- Use Customer ID column.
Example 2
Summary: Runs association analysis to identify rules between product and customer ID, with configurable minimum support and confidence thresholds.
Code:
dt = Open("data_table.jmp");
obj = dt << Association Analysis(
Item( :Product ),
ID( :Customer ID ),
Minimum Support( 0.119 ),
Minimum Confidence( 0.65 ),
Maximum Antecedents( 2 ),
Maximum Rule Size( 3 ),
);
rpt = obj << report;
left = rpt[Outline Box( "Rules" )][String Col Box( 1 )] << get;
right = rpt[Outline Box( "Rules" )][String Col Box( 2 )] << get;
conf = rpt[Outline Box( "Rules" )][Number Col Box( 1 )] << get as matrix;
lift = rpt[Outline Box( "Rules" )][Number Col Box( 2 )] << get as matrix;
Code Explanation:
- Open data table.
- Perform association analysis.
- Set item column.
- Set ID column.
- Define minimum support.
- Define minimum confidence.
- Limit antecedents.
- Limit rule size.
- Extract rules report.
- Retrieve rule details.
Example 3
Summary: Runs association analysis to identify relationships between product and customer ID, generating a report with rules outlined in the Bivariate platform.
Code:
dt = Open("data_table.jmp");
obj = dt << Association Analysis( Item( :Product ), ID( :Customer ID ), Minimum Confidence( 0.9 ), Maximum Antecedents( 2 ) );
rpt = obj << report;
condition = rpt[Outline Box( "Rules" )][Table Box( 1 )][String Col Box( 1 )] << get;
Code Explanation:
- Open data table;
- Perform association analysis.
- Set item variable.
- Set ID variable.
- Define minimum confidence.
- Limit maximum antecedents.
- Generate report object.
- Extract report content.
- Access rules outline box.
- Retrieve table box content.
Association Analysis using If
Example 1
Summary: Analyze customer data to identify frequent item sets and singular values, utilizing Association Analysis and Local Data Filter features in JMP Pro.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
subset1 = dt << Subset( All rows, Selected columns only( 0 ) );
s1 = subset1 << Select Where( :Customer ID > 500 );
s1 << Delete Rows( s1 );
s2 = dt << Select Where( :Customer ID > 500 );
s2 << Exclude( 1 );
obj1 = dt << Association Analysis(
Item( :Product ),
ID( :Customer ID ),
Minimum Confidence( 0.9 ),
Maximum Antecedents( 2 ),
Rules( 0 ),
Local Data Filter(
Add Filter(
columns( :Product ),
Where( :Product == {"Heineken", "herring"} ),
Display( :Product, Size( 160, 225 ), List Display )
)
),
SendToReport( Dispatch( {}, "Frequent Item Sets", OutlineBox, {Close( 0 )} ) )
);
newtable1 = Report( obj1 )[Outline Box( "Association Analysis" )][Outline Box( "Frequent Item Sets" )][Table Box( 1 )] <<
Make Into Data Table;
values1 = newtable1:Item Set << get stored values;
obj2 = dt << Association Analysis(
Item( :Product ),
ID( :Customer ID ),
Minimum Confidence( 0.9 ),
Maximum Antecedents( 2 ),
Frequent Item Sets( 0 ),
Rules( 0 ),
SVD( Number of Singular Vectors( 6 ) ),
Local Data Filter(
Add Filter(
columns( :Product ),
Where( :Product == {"olives", "peppers", "sardines", "soda", "steak", "turkey"} ),
Display( :Product, Size( 160, 225 ), List Display )
)
)
);
newtable2 = Report( obj2 )[Outline Box( "Association Analysis" )][Outline Box( "SVD" )][Outline Box( "Singular Values" )][
Table Box( 1 )] << Make Into Data Table;
values2 = newtable2:Cum Percent << get as matrix;
Close( newtable1, nosave );
Close( newtable2, nosave );
Close( dt, no save );
Close( subset1, no save );
);
Code Explanation:
- Check for JMP Pro.
- Open data table;
- Create subset of all rows.
- Select rows with Customer ID > 500.
- Delete selected rows.
- Select rows with Customer ID > 500 again.
- Exclude selected rows.
- Run Association Analysis.
- Create data table from report.
- Extract item set values.
- Run another Association Analysis.
- Create data table from report.
- Extract cumulative percent values.
- Close all data tables without saving.
Example 2
Summary: Runs association analysis and Singular Value Decomposition (SVD) on a data table, selecting the 'Product' column and deleting other columns, all within a JMP Pro environment.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
aa = dt << Association Analysis( Item( :Product ), ID( Name( "Customer ID" ) ) );
Column( dt, "Product" ) << Set Selected( 1 );
dt << Delete Columns;
aa << SVD( Number of Singular Vectors( 20 ) );
aa << close window;
Close( dt, nosave );
);
Code Explanation:
- Check if JMP version is Pro.
- Open data table.
- Perform association analysis.
- Select "Product" column.
- Delete columns from table.
- Apply SVD with 20 vectors.
- Close association analysis window.
- Close data table without saving.