Cluster
Hierarchical Cluster
Example 1
Summary: Visualizes hierarchical clustering analysis on a data table, specifying columns for birth and death rates, color coding clusters, marking clusters, and setting the number of clusters to 14.
Code:
// Hierarchical Cluster
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster
Hierarchical Cluster(
Columns( :birth, :death ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Number of Clusters( 14 )
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify columns for analysis.
- Enable color coding clusters.
- Enable marking clusters.
- Set number of clusters to 14.
Example 2
Summary: Opens a data table, performs hierarchical clustering on columns S1 and S3, colors and marks clusters, and sets the number of clusters to 7.
Code:
// Hierarchical Cluster
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster
Hierarchical Cluster(
Columns( :S1, :S3 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Number of Clusters( 7 )
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Select columns S1 and S3.
- Color clusters enabled.
- Mark clusters enabled.
- Set number of clusters to 7.
Example 3
Summary: Performs hierarchical clustering on a data table, using the Ward method and standardizing data. It generates a dendrogram with 5 clusters and sends the output to a report.
Code:
// Hierarchical Cluster
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster
Hierarchical Cluster(
Y(
:ORE_FEMALE_WK1_1,
:ORE_FEMALE_WK1_2,
:ORE_FEMALE_WK1_11,
:ORE_FEMALE_WK1_12,
:ORE_FEMALE_WK1_21,
:ORE_FEMALE_WK1_24,
:ORE_FEMALE_WK6_1,
:ORE_FEMALE_WK6_2,
:ORE_FEMALE_WK6_11,
:ORE_FEMALE_WK6_12,
:ORE_FEMALE_WK6_21,
:ORE_FEMALE_WK6_24,
:ORE_MALE_WK1_3, :ORE_MALE_WK1_4,
:ORE_MALE_WK1_9, :ORE_MALE_WK1_10,
:ORE_MALE_WK1_19,
:ORE_MALE_WK1_20, :ORE_MALE_WK6_3,
:ORE_MALE_WK6_4, :ORE_MALE_WK6_9,
:ORE_MALE_WK6_10,
:ORE_MALE_WK6_19,
:ORE_MALE_WK6_20,
:SAM_FEMALE_WK1_7,
:SAM_FEMALE_WK1_8,
:SAM_FEMALE_WK1_15,
:SAM_FEMALE_WK1_16,
:SAM_FEMALE_WK1_22,
:SAM_FEMALE_WK1_23,
:SAM_FEMALE_WK6_7,
:SAM_FEMALE_WK6_8,
:SAM_FEMALE_WK6_15,
:SAM_FEMALE_WK6_16,
:SAM_FEMALE_WK6_22,
:SAM_FEMALE_WK6_23,
:SAM_MALE_WK1_5, :SAM_MALE_WK1_6,
:SAM_MALE_WK1_13,
:SAM_MALE_WK1_14,
:SAM_MALE_WK1_17,
:SAM_MALE_WK1_18, :SAM_MALE_WK6_5,
:SAM_MALE_WK6_6, :SAM_MALE_WK6_13,
:SAM_MALE_WK6_14,
:SAM_MALE_WK6_17,
:SAM_MALE_WK6_18
),
Label( :Observation ID ),
Method( "Ward" ),
Standardize Data( 0 ),
Distance Matrix( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 5 ),
SendToReport(
Dispatch( {}, "Dendrogram",
OutlineBox,
{SetHorizontal( 1 )}
)
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify response variables.
- Use observation ID for labels.
- Apply Ward method.
- Do not standardize data.
- Generate distance matrix.
- Use distance scale for dendrogram.
- Set number of clusters to 5.
- Adjust dendrogram orientation.
Example 4
Summary: Opens a data table, performs hierarchical clustering on the 'Cities' column using the Ward method, and generates a dendrogram with 10 clusters. The resulting chart is then sent to a report with a customized outline box.
Code:
// Hierarchical Cluster
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster
Hierarchical Cluster(
Y(
:Birmingham, :Boston, :Buffalo,
:Chicago, :Cleveland, :Dallas,
:Denver, :Detroit, :El Paso,
:Houston, :Indianapolis,
:Kansas City, :Los Angeles,
:Louisville, :Memphis, :Miami,
:Minneapolis, :New Orleans,
:New York, :Omaha, :Philadelphia,
:Phoenix, :Pittsburgh, :St. Louis,
:Salt Lake City, :San Francisco,
:Seattle, :Washington DC
),
Label( :Cities ),
Method( "Ward" ),
Standardize Data( 1 ),
Distance Matrix( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 10 ),
Color Clusters( 1 ),
SendToReport(
Dispatch( {}, "Dendrogram",
OutlineBox,
{SetHorizontal( 1 )}
)
)
);
Code Explanation:
- Open data table.
- Define variables.
- Start hierarchical clustering.
- Specify response columns.
- Label cities.
- Choose Ward method.
- Standardize data.
- Display distance matrix.
- Set dendrogram scale.
- Define number of clusters.
- Color clusters.
- Adjust dendrogram orientation.
Example 5
Summary: Generates a hierarchical cluster analysis on factor scores, using the Ward method and standardizing data. The resulting dendrogram is scaled by distance and includes a color map column for Internet Use.
Code:
// Hierarchical Cluster on Factor Scores
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster on Factor Scores
Hierarchical Cluster(
Y(
:Privacy, :Security, :Reputation,
:Trust, :Purchase Int
),
Method( "Ward" ),
Standardize Data( 1 ),
Cluster Summary( 1 ),
Two Way Clustering,
Number of Clusters( 4 ),
Dendrogram Scale( "Distance Scale" ),
More Color Map Columns(
:Internet Use
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify cluster variables.
- Choose Ward method.
- Standardize data.
- Enable cluster summary.
- Apply two-way clustering.
- Set number of clusters to 4.
- Use distance scale for dendrogram.
- Add color map column for Internet Use.
Example 6
Summary: Performs hierarchical clustering on a dataset, using the centroid method and standardizing data. It labels clusters by species and creates a constellation plot.
Code:
// Hierarchical Clustering
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Clustering
Hierarchical Cluster(
Y(
:Culmen Length, :Culmen Depth,
:Flipper Length, :Body Mass,
:Delta 15 N, :Delta 13 C
),
Label( :Species ),
Method( "Centroid" ),
Standardize Data( 1 ),
Color Clusters( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
Constellation Plot( 1 )
);
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Use specified variables.
- Label clusters by species.
- Use centroid method.
- Standardize data.
- Color clusters.
- Use distance scale.
- Set number of clusters to 4.
- Create constellation plot.
Example 7
Summary: Generates a spatial cluster of defects by performing hierarchical clustering on the 'Defects' response variable, using lot and wafer as object IDs, X and Y die positions as attribute IDs, and the Ward method for clustering. The resulting dendrogram is scaled by distance and includes 7 clusters.
Code:
// Spatial Cluster of Defects
// Open data table
dt = Open("data_table.jmp");
// Spatial Cluster of Defects
Hierarchical Cluster(
Y( :Defects ),
Object ID( :Lot, :Wafer ),
Attribute ID( :X_Die, :Y_Die ),
Method( "Ward" ),
Standardize Data( 0 ),
Cluster Summary( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 7 ),
Add Spatial Measures(
Attributes( 1 ),
Angle( 1 ),
Radius( 1 ),
Streak Angle( 1 ),
Streak Distance( 1 )
),
SendToReport(
Dispatch( {}, "Dendrogram",
OutlineBox,
{Close( 1 ),
SetHorizontal( 1 )}
),
Dispatch( {"Dendrogram"},
"Clust Dendro", FrameBox,
{Frame Size( 35, 700 )}
)
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Use defects as response variable.
- Define object ID for lots and wafers.
- Specify attribute ID for X and Y die positions.
- Choose Ward method for clustering.
- Do not standardize data.
- Generate cluster summary report.
- Scale dendrogram by distance.
- Set number of clusters to 7.
Example 8
Summary: Generates a hierarchical cluster analysis using the Ward method to group data based on Crude Death Rate and Crude Birth Rate, with standardized values and color-coded clusters.
Code:
// Hierarchical Cluster: Crude Death Rate and Crude Birth Rate
// Open data table
dt = Open("data_table.jmp");
// Hierarchical Cluster: Crude Death Rate and Crude Birth Rate
Hierarchical Cluster(
Y(
:"Crude Death Rate (1000)"n,
:"Crude Birth Rate (1000)"n
),
Method( "Ward" ),
Standardize( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Dendrogram Scale(
"Geometric Spacing"
),
Number of Clusters( 14 )
);
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Select variables.
- Use Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Set dendrogram scale.
- Specify number of clusters.
Example 9
Summary: Performs hierarchical clustering analysis on sales data, grouping outlets by pie type and ordering by outlets, with a focus on visualizing the dendrogram using a customized report.
Code:
Open( “$SAMPLE_DATA/data_table.jmp” );
Hierarchical Cluster(
Y( :"Sales (K)"n ),
Label( :Pie Type ),
Ordering( :Outlets ),
Method( "Ward" ),
Standardize By( "Columns" ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 2 ),
SendToReport(
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox,
{Frame Size( 71, 200 ), DispatchSeg( DendroLabelSeg( 1 ), {Font( Font( "Showcard Gothic" ) )} )}
)
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use sales data for analysis.
- Label pies by type.
- Order by outlets.
- Apply Ward method.
- Standardize by columns.
- Use distance scale.
- Set number of clusters to 2.
- Adjust dendrogram appearance.
Example 10
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and standardizing by columns, to identify 5 clusters with distinct characteristics.
Code:
dt = Open("data_table.jmp");
dt << Hierarchical Cluster(
Y( :name, :age, :sex, :height, :weight ),
Method( "Ward" ),
Standardize By( "Columns" ),
Distance Graph( 0 ),
Clustering History( 0 ),
Dendrogram Scale( "Distance Scale" ),
Two Way Clustering,
Number of Clusters( 5 ),
Color Map( "Blue to Gray to Red"(1) ),
SendToReport( Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {Frame Size( 73, 610 )} ) )
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify variables for clustering.
- Use Ward method.
- Standardize by columns.
- Disable distance graph.
- Disable clustering history.
- Set dendrogram scale.
- Enable two-way clustering.
- Define number of clusters.
Example 11
Summary: Performs hierarchical clustering analysis on a data table, utilizing the Ward method and standardizing by columns, with interactive features for two-way clustering and color mapping.
Code:
dt = Open("data_table.jmp");
dt << Hierarchical Cluster(
Y( :name, :age, :sex, :height, :weight ),
Method( "Ward" ),
Standardize By( "Columns" ),
Distance Graph( 0 ),
Clustering History( 0 ),
Dendrogram Scale( "Distance Scale" ),
Two Way Clustering,
Number of Clusters( 5 ),
Color Map( "Blue to Gray to Red"(1) ),
SendToReport( Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {Frame Size( 73, 610 )} ) )
);
Open("data_table.jmp") << Cluster Variables(
Y( :Al, :Mn, :Na, :Br, :Ce, :Co, :Cr, :Cs, :Eu, :Fe, :Hf, :La, :Sc, :Sm, :U ),
Cluster Summary( 0 ),
Cluster Members( 0 ),
Cluster Components( 0 )
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use Ward method for clustering.
- Standardize data by columns.
- Disable distance graph.
- Disable clustering history.
- Set dendrogram scale to distance.
- Enable two-way clustering.
- Specify 5 clusters.
- Apply color map from blue to gray to red.
- Adjust dendrogram frame size.
- Open data table;
- Cluster variables based on specified elements.
- Disable cluster summary.
- Disable cluster members.
- Disable cluster components.
Example 12
Summary: Performs hierarchical clustering analysis on birth and death variables, generating a constellation plot with customized appearance.
Code:
Open("data_table.jmp");
Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize Data( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 14 ),
Constellation Plot( 1 ),
SendToReport(
Dispatch( {"Constellation Plot"}, "Clust Hier", FrameBox,
{DispatchSeg(
Node Graph Seg( 1 ),
{Line Color( "Medium Dark Green" ), Line Style( "DashDot" ), Line Width( 2 ), Marker( "Filled Diamond" ),
Transparency( 0.5 )}
)}
)
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use birth and death variables.
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Use distance scale for dendrogram.
- Set number of clusters to 14.
- Generate constellation plot.
- Customize constellation plot appearance.
- Set line color to green.
- Set line style to dash-dot.
- Set line width to 2.
- Use filled diamond marker.
- Set transparency to 0.5.
Example 13
Summary: Performs hierarchical clustering analysis on the 'birth' and 'death' variables, utilizing the Ward method and standardizing data for 30 clusters.
Code:
dt = Open("data_table.jmp");
Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize Data( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Cluster Criterion( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 30 ),
Constellation Plot( 1 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {Frame Size( 35, 700 )} ),
Dispatch( {"Constellation Plot"}, "1", ScaleBox,
{Format( "Custom", Formula( Round( Normal Density( value, mu = 0, sigma = 10 ), 2 ) ), 12 )}
),
Dispatch( {"Constellation Plot"}, "2", ScaleBox, {Format( "Custom", Formula( Round( Ln( Abs( value ) ), 2 ) ), 12 )} )
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use variables "birth" and "death".
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Set cluster criterion.
- Use distance scale for dendrogram.
- Specify 30 clusters.
Example 14
Summary: Performs hierarchical clustering analysis on a data table, using height and weight variables, Ward method, and distance scale for dendrogram, with 5 clusters and cluster summary.
Code:
dt = Open("data_table.jmp");
hc = dt << Hierarchical Cluster(
Y( :height, :weight ),
Label( :name ),
Method( "Ward" ),
Standardize Data( 0 ),
Cluster Summary( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 5 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {Close( 1 ), SetHorizontal( 1 )} ),
Dispatch( {"Cluster Summary"}, "Cluster Means", OutlineBox, {Close( 1 )} )
)
);
hc << Save Clusters;
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Use height and weight as variables.
- Label clusters by name.
- Apply Ward method.
- Do not standardize data.
- Show cluster summary.
- Use distance scale for dendrogram.
- Specify 5 clusters.
- Close dendrogram outline.
- Close cluster means outline.
- Save cluster results.
Example 15
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and specifying variables for clustering, with cluster summary and parallel coordinate plots.
Code:
dt = Open("data_table.jmp");
hc = dt << Hierarchical Cluster(
Y( :height, :weight ),
Label( :name ),
Method( "Ward" ),
Standardize Data( 0 ),
Cluster Summary( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 5 ),
SendToReport(
Dispatch( {}, "Dendrogram", OutlineBox, {Close( 1 ), SetHorizontal( 1 )} ),
Dispatch( {"Cluster Summary"}, "Cluster Means", OutlineBox, {Close( 1 )} )
)
);
hc << Save Clusters;
hc << Parallel Coord Plots;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify variables for clustering.
- Use names as labels.
- Choose Ward method.
- Do not standardize data.
- Show cluster summary.
- Use distance scale for dendrogram.
- Set number of clusters to 5.
- Close unnecessary reports.
- Save cluster results.
- Create parallel coordinate plots.
Example 16
Summary: Performs hierarchical clustering analysis on data table variables S1 and S3, using the Ward method, standardization, and color marking to identify 7 clusters.
Code:
Open("data_table.jmp");
Hierarchical Cluster(
Y( :S1, :S3 ),
Method( "Ward" ),
Standardize( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Show Dendrogram( 0 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 7 ),
Constellation Plot( 1 ),
SendToReport(
Dispatch( {}, "Hierarchical Clustering", OutlineBox, {Set Title( "Constellation Plot, No Show Dendrogram" )} ),
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch( {"Constellation Plot"}, "Clust Hier", FrameBox, {Marker Size( 4 )} )
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use variables S1 and S3.
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Hide dendrogram.
- Set dendrogram scale.
- Specify 7 clusters.
Example 17
Summary: Performs hierarchical clustering analysis to group countries based on birth and death rates, labeling clusters by country.
Code:
dt = Open("data_table.jmp");
obj = Hierarchical Cluster( Y( :birth, :death ), Label( :country ) );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Use birth and death columns.
- Label clusters by country.
Example 18
Summary: Creates a hierarchical cluster object using birth and death variables, with country labels, and generates a constellation plot.
Code:
Names Default To Here( 1 );
dt = Open("data_table.jmp");
obj = Hierarchical Cluster( Y( :birth, :death ), Label( :country ) );
obj << Constellation Plot();
Code Explanation:
- Set default names.
- Open data table.
- Create hierarchical cluster object.
- Specify birth and death variables.
- Use country for labeling.
- Generate constellation plot.
Example 19
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and standardizing input data to visualize clusters in a dendrogram.
Code:
Open("data_table.jmp");
Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize Data( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 2 ),
SendToReport( Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ) )
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Set variables for clustering.
- Use Ward method for clustering.
- Standardize input data.
- Use distance scale for dendrogram.
- Specify number of clusters.
- Adjust dendrogram orientation.
Example 20
Summary: Performs hierarchical clustering analysis on a data table, using age, sex, height, and weight variables to identify 5 clusters with Ward's method, and visualizes the results in a dendrogram with blue-to-gray-to-red color mapping.
Code:
Open("data_table.jmp");
Hierarchical Cluster(
Y( :age, :sex, :height, :weight ),
Label( :name ),
Method( "Ward" ),
Standardize By( "Columns" ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 5 ),
Color Map( "Blue to Gray to Red" ),
Two Way Clustering,
SendToReport(
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {Frame Size( 86, 700 )} ),
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox( 4 ), {Frame Size( 72, 60 )} )
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use age, sex, height, weight variables.
- Label using name variable.
- Apply Ward method.
- Standardize by columns.
- Use distance scale for dendrogram.
- Specify 5 clusters.
- Use blue to gray to red color map.
- Enable two-way clustering.
Example 21
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and standardizing by columns, to identify patterns in pH, specific gravity, temperature, sediment, and alcohol levels across different tanks.
Code:
Open("data_table.jmp");
Hierarchical Cluster(
Y( :pH, :Specific gravity, :"Temperature, degrees C"n, :"Sediment, ppb"n, :Alcohol ),
Label( :Tank ),
Method( "Ward" ),
Standardize By( "Columns" ),
Color Clusters( 1 ),
Dendrogram Scale( "Distance Scale" ),
Row Label Position( "Right" ),
Number of Clusters( 3 ),
SendToReport(
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {DispatchSeg( DendroSeg( 1 ), {Line Color( "Orange" ), Line Width( 3 )} )} ),
Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox( 2 ), {Frame Size( 35, 385 )} )
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify response variables.
- Use Tank for labeling.
- Apply Ward method.
- Standardize by columns.
- Color clusters.
- Set dendrogram scale.
- Position row labels.
- Define number of clusters.
- Customize dendrogram appearance.
- Adjust frame size.
Example 22
Summary: Performs hierarchical clustering analysis using variables S1 and S3, with Ward method, standardization, and color marking of clusters.
Code:
dt under test = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :S1, :S3 ),
Method( "Ward" ),
Standardize( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Distance Graph( 0 ),
Show NCluster Handle( 0 ),
Cluster Criterion( 1 ),
Dendrogram Scale( "Distance Scale" ),
Two Way Clustering,
Number of Clusters( 29 ),
Color Map( "Blue to Gray to Red" ),
SendToReport(
Dispatch( {}, "Hierarchical Clustering", OutlineBox, {Set Title( "Cluster Criterion, No Distance Graph, Two Way Clustering" )} ),
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} )
)
);
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Use variables S1, S3.
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Hide distance graph.
- Disable NCluster handle.
- Set cluster criterion.
Example 23
Summary: Performs hierarchical clustering analysis using the Ward method, standardizing data and color-marking clusters, with a constellation plot and customized report title.
Code:
dt under test = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :S1, :S3 ),
Method( "Ward" ),
Standardize( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Show Dendrogram( 0 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 7 ),
Constellation Plot( 1 ),
SendToReport(
Dispatch( {}, "Hierarchical Clustering", OutlineBox, {Set Title( "Constellation Plot, No Show Dendrogram" )} ),
Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ),
Dispatch( {"Constellation Plot"}, "Clust Hier", FrameBox, {Marker Size( 4 )} )
)
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use S1 and S3 columns.
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Hide dendrogram.
- Set dendrogram scale.
- Specify 7 clusters.
- Create constellation plot.
- Customize report title.
- Set dendrogram horizontal.
- Adjust marker size.
Example 24
Summary: Performs hierarchical clustering analysis on columns S1 and S3, with color coding and marking enabled for 7 clusters.
Code:
dt under test = Open("data_table.jmp");
obj = Hierarchical Cluster( Columns( :S1, :S3 ), Color Clusters( 1 ), Mark Clusters( 1 ), Number of Clusters( 7 ) );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Select columns S1 and S3.
- Enable color coding for clusters.
- Enable cluster marking.
- Specify number of clusters as 7.
Example 25
Summary: Performs hierarchical clustering analysis to group countries based on birth and death rates, using the Ward method and standardizing data for visualization.
Code:
dt under test = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Cluster Criterion( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 8 ),
SendToReport( Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ) )
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use birth and death variables.
- Label clusters by country.
- Apply Ward method.
- Standardize data.
- Color clusters.
- Mark clusters.
- Set cluster criterion.
- Configure dendrogram scale.
Example 26
Summary: Performs hierarchical clustering analysis on a data table, generating two separate cluster hierarchies and saving the distance matrices, display orders, and clusters for further exploration.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster(
Y( :State Since, :Capital Since ),
Method( "Ward" ),
Standardize By( "Columns" ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 6 ),
SendToReport( Dispatch( {"Dendrogram"}, "Clust Dendro", FrameBox, {Frame Size( 35, 700 )} ) )
);
dt2 = obj << Save Distance Matrix;
dt2 = Current Data Table();
obj2 = dt2 << Hierarchical Cluster( Label( :Name ), Distance Matrix( 1 ), );
obj << Save Clusters;
obj2 << Save Clusters;
obj << Save Display Order;
obj2 << Save Display Order;
dt3 = obj << Save Cluster Hierarchy;
dt4 = obj2 << Save Cluster Hierarchy;
benchHMat = dt3 << Get All Columns As Matrix;
benchHMat = benchHMat[0, 1 :: 7];
validHMat = dt4 << Get All Columns As Matrix;
Close( dt3, No Save );
Close( dt4, No Save );
obj << Two Way Clustering;
obj << Legend( 1 );
obj2 << Two Way Clustering;
obj2 << Legend( 1 );
rpt = obj << report;
rpt2 = obj2 << report;
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Save distance matrix.
- Switch to distance matrix table.
- Perform hierarchical clustering on labels.
- Save clusters from first analysis.
- Save clusters from second analysis.
- Save display order from first analysis.
- Save display order from second analysis.
- Save cluster hierarchy from both analyses.
Example 27
Summary: Performs hierarchical clustering analysis on a dataset with 8 clusters, utilizing the Ward method and standardizing variables, followed by local data filtering for specific conditions.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
clus = dt << Hierarchical Cluster(
Y( :Saturated fat g, :Cholesterol g, :Sodium mg, :Carbohydrate g, :Dietary fiber g, :Sugars g, :Protein g, :Vitamin A %RDI ),
Method( "Ward" ),
Standardize( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 8 )
);
ldf = clus << Local Data Filter(
Location( {451, 116} ),
Add Filter( columns( :Calories, :Brand ), Where( :Brand == "M&M/Mars" ), Display( :Brand, Size( 204, 259 ), Check Box Display ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use Ward method.
- Standardize variables.
- Set dendrogram scale.
- Specify 8 clusters.
- Create local data filter.
- Position filter at (451, 116).
- Add filter for "Calories" and "Brand".
- Set filter condition for "M&M/Mars".
Example 28
Summary: Performs hierarchical clustering analysis on a dataset, identifying 8 clusters based on multiple variables and visualizing the results with a dendrogram scale.
Code:
dt = Open("data_table.jmp");
clus = dt << Hierarchical Cluster(
Y( :Saturated fat g, :Cholesterol g, :Sodium mg, :Carbohydrate g, :Dietary fiber g, :Sugars g, :Protein g, :Vitamin A %RDI ),
Method( "Ward" ),
Standardize( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 8 )
);
ldf = clus << Local Data Filter(
Location( {451, 116} ),
Add Filter( columns( :Calories, :Brand ), Where( :Brand == "M&M/Mars" ), Display( :Brand, Size( 204, 259 ), List Display ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify variables for clustering.
- Choose Ward method.
- Standardize data.
- Set dendrogram scale.
- Define number of clusters.
- Create local data filter.
- Set filter location.
- Add filter criteria and display settings.
Example 29
Summary: Performs hierarchical clustering analysis on a dataset, using the Ward method and standardizing data for 8 clusters, and then filters local data to display specific brand information.
Code:
dt = Open("data_table.jmp");
clus = dt << Hierarchical Cluster(
Y( :Saturated fat g, :Cholesterol g, :Sodium mg, :Carbohydrate g, :Dietary fiber g, :Sugars g, :Protein g, :Vitamin A %RDI ),
Method( "Ward" ),
Standardize( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 8 )
);
ldf = clus << Local Data Filter(
Location( {451, 116} ),
Add Filter(
columns( :Calories, :Brand ),
Where( :Brand == "M&M/Mars" ),
Display( :Brand, Size( 204, 259 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
)
);
ldf << Display( :brand, Check box Display );
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Set clustering method to "Ward".
- Standardize data.
- Use "Distance Scale" for dendrogram.
- Specify 8 clusters.
- Create local data filter.
- Position filter at (451, 116).
- Add filter for "Calories" and "Brand".
- Filter where "Brand" equals "M&M/Mars".
Example 30
Summary: Performs hierarchical clustering analysis on a subset of data, using the Ward method and standardizing values, with interactive filtering capabilities.
Code:
dt = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize( Yes ),
Number of Clusters( 4 ),
Local Data Filter(
Location( {985, 3} ),
Add Filter( columns( :birth ), Where( :birth >= 15 & :birth <= 35 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
),
);
obj << Automatic Recalc( 0 );
dt << Select Rows( 1 :: 10 );
dt << Exclude();
rpt = Report( obj );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Use Ward method.
- Standardize data.
- Set number of clusters to 4.
- Enable local data filter.
- Position filter at (985, 3).
- Add filter for birth column.
- Set filter range 15 to 35.
- Disable automatic recalculation.
Example 31
Summary: Performs hierarchical clustering analysis on a data table, filtering birth column between 15 and 35, and generating reports with interactive features.
Code:
dt = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize( Yes ),
Number of Clusters( 4 ),
Automatic Recalc( 1 ),
Local Data Filter(
Location( {985, 3} ),
Add Filter( columns( :birth ), Where( :birth >= 15 & :birth <= 35 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
),
);
dt << Select Rows( 1 :: 10 );
dt << Exclude();
rpt = Report( obj );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize( Yes ),
Number of Clusters( 4 ),
Local Data Filter(
Location( {985, 3} ),
Add Filter( columns( :birth ), Where( :birth >= 15 & :birth <= 35 ) ),
Mode( Select( 0 ), Show( 1 ), Include( 1 ) )
),
);
obj << Automatic Recalc( 0 );
dt << Select Rows( 1 :: 10 );
dt << Exclude();
rpt = Report( obj );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Set cluster method to Ward.
- Standardize variables.
- Define 4 clusters.
- Enable automatic recalculation.
- Add local data filter.
- Filter birth column between 15 and 35.
- Select first 10 rows.
- Exclude selected rows.
- Generate report.
- Close data table without saving.
- Reopen data table.
- Repeat clustering process.
- Disable automatic recalculation.
- Select first 10 rows.
- Exclude selected rows.
- Generate report.
Example 32
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and standardizing data for visualization in a dendrogram report.
Code:
dt = Open("data_table.jmp");
obj = Hierarchical Cluster(
Y( :birth, :death ),
Method( "Ward" ),
Standardize Data( 1 ),
Color Clusters( 1 ),
Mark Clusters( 1 ),
Cluster Criterion( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 30 ),
Constellation Plot( 1 ),
SendToReport( Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ) )
);
rpt1 = obj << Report;
actN1 = (rpt1[Number Col Box( 4 )][5]);
:birth << Set Property( "Missing Value Codes", 0 );
:birth << Set Values( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] );
obj2 = obj << Redo Analysis;
rpt2 = obj2 << Report;
actN2 = (rpt2[Number Col Box( 4 )][5]);
ans = Equal( actN1, actN2 );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Set cluster method to Ward.
- Standardize data.
- Color clusters.
- Mark clusters.
- Set cluster criterion.
- Use distance scale.
- Specify number of clusters.
- Generate constellation plot.
Example 33
Summary: Performs hierarchical clustering analysis on a data table, retrieving distance matrices for standardized and non-standardized data, and visualizing the results in reports.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( Yes ), Number of Clusters( 4 ) );
rpt = obj << report;
distYes = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( 1 ), Number of Clusters( 4 ) );
rpt = obj << report;
dist1 = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( No ), Number of Clusters( 4 ) );
rpt = obj << report;
distNo = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( 0 ), Number of Clusters( 4 ) );
rpt = obj << report;
dist0 = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Retrieve distance matrix.
- Close cluster window.
- Repeat steps 2-4 without standardizing data.
- Retrieve distance matrix.
- Close cluster window.
- Repeat steps 2-4 with standardization off.
- Retrieve distance matrix.
- Close cluster window.
Example 34
Summary: Performs hierarchical clustering and K-means clustering analysis on a data table, with options for standardization and SOM enablement, and generates reports and biplots.
Code:
ut relative epsilon = 1e-10;
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( Yes ), Number of Clusters( 4 ) );
rpt = obj << report;
distYes = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( 1 ), Number of Clusters( 4 ) );
rpt = obj << report;
dist1 = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( No ), Number of Clusters( 4 ) );
rpt = obj << report;
distNo = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Method( "Ward" ), Standardize Data( 0 ), Number of Clusters( 4 ) );
rpt = obj << report;
dist0 = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << close window;
Close( dt, no save );
dt = Open("data_table.jmp");
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( 1 ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( Yes ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( 0 ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( No ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster(
Y( :Sepal length, :Sepal width, :Petal length, :Petal width ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go}
);
obj << Biplot 3D( 1 );
obj << Biplot 3D( 0 );
Code Explanation:
- Set relative epsilon.
- Open data table;
- Perform hierarchical clustering.
- Extract distance matrix.
- Close cluster window.
- Repeat steps 3-5 for standardized data.
- Repeat steps 3-5 for unstandardized data.
- Close birth death dataset.
- Open data table;
- Perform K-means clustering without SOM.
- Close K-means window.
- Repeat steps 10-11 for SOM enabled.
- Repeat steps 10-11 for SOM disabled.
- Perform K-means clustering.
- Create 3D biplot.
- Create 2D biplot.
Example 35
Summary: Performs hierarchical clustering and K-means clustering operations on a data table, saving distance matrices and closing reports as needed.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
dtDist = obj << Save Distance Matrix;
Close( dt, No Save );
check = Function( {},
cnt = 0;
For( i = N Items( Window() ), i >= 1, i--,
lnchWin = (Window()[i]);
winTtl = lnchWin << get window title;
If( winTtl == "Hierarchical Cluster" | winTtl == "K Means Cluster",
cnt = 1;
lnchWin[Button Box( 6 )] << Click;
Break();
);
);
);
Cluster();
check();
Hierarchical Cluster();
check();
K Means Cluster();
check();
Cluster( Y( 2 :: 11 ) );
check();
Hierarchical Cluster( Distance Matrix( 1 ) );
check();
KMeans Cluster( Centers( :To John ) );
check();
Cluster( Y( 2 :: 11 ), Type( "Hierarchical" ) );
Current Report() << Close Window( 1 );
Hierarchical Cluster( Y( 2 :: 11 ) );
Current Report() << Close Window( 1 );
Cluster( Y( 2 :: 11 ), Type( "K Means" ) );
Current Report() << Close Window( 1 );
KMeans Cluster( Y( 2 :: 11 ) );
Current Report() << Close Window( 1 );
Hierarchical Cluster( Distance Matrix( 1 ), Label( :Name ) );
Current Report() << Close Window( 1 );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save distance matrix.
- Close data table without saving.
- Define check function.
- Call cluster function.
- Execute check function.
- Perform hierarchical clustering again.
- Execute check function.
- Perform K-means clustering.
- Execute check function.
- Perform clustering on selected columns.
- Execute check function.
- Perform hierarchical clustering using distance matrix.
- Execute check function.
- Perform K-means clustering with specified centers.
- Execute check function.
- Perform hierarchical clustering on selected columns.
- Close first report window.
- Perform hierarchical clustering on selected columns.
- Close first report window.
- Perform K-means clustering on selected columns.
- Close first report window.
- Perform K-means clustering on selected columns.
- Close first report window.
- Perform hierarchical clustering with labeling.
- Close first report window.
Example 36
Summary: Process of launching hierarchical clustering, retrieving combo box items and options, setting combo boxes, and closing data tables without saving.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster();
launchWin = Window()[N Items( Window() )];
cItems = launchWin[Combo Box( 1 )] << Get Items;
hcOptions = launchWin[Combo Box( 1 )] << Get Selected;
hcLbl = launchWin[Button Box( 3 )] << Get Button Name;
launchWin[Combo Box( 1 )] << Set( 2 );
kcOptions = launchWin[Combo Box( 1 )] << Get Selected;
kcLbL = launchWin[Button Box( 4 )] << Get Button Name;
Close( dt, No Save );
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
dtDist = obj << Save Distance Matrix;
Close( dt, No Save );
check = Function( {},
cnt = 0;
For( i = N Items( Window() ), i >= 1, i--,
lnchWin = (Window()[i]);
winTtl = lnchWin << get window title;
If( winTtl == "Hierarchical Cluster" | winTtl == "K Means Cluster",
cnt = 1;
lnchWin[Button Box( 6 )] << Click;
Break();
);
);
);
Cluster();
check();
Hierarchical Cluster();
check();
K Means Cluster();
check();
Cluster( Y( 2 :: 11 ) );
check();
Hierarchical Cluster( Distance Matrix( 1 ) );
check();
KMeans Cluster( Centers( :To John ) );
check();
Cluster( Y( 2 :: 11 ), Type( "Hierarchical" ) );
Current Report() << Close Window( 1 );
Hierarchical Cluster( Y( 2 :: 11 ) );
Current Report() << Close Window( 1 );
Cluster( Y( 2 :: 11 ), Type( "K Means" ) );
Current Report() << Close Window( 1 );
KMeans Cluster( Y( 2 :: 11 ) );
Current Report() << Close Window( 1 );
Hierarchical Cluster( Distance Matrix( 1 ), Label( :Name ) );
Current Report() << Close Window( 1 );
Code Explanation:
- Open data table.
- Launch hierarchical clustering.
- Retrieve combo box items.
- Get selected hierarchical options.
- Get hierarchical button label.
- Set combo box to second option.
- Get selected K-means options.
- Get K-means button label.
- Close data table without saving.
- Reopen data table.
Example 37
Summary: Performs hierarchical clustering analysis on a data table, generating a distance matrix and visualizing the results.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
dtDist = obj << Save Distance Matrix;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save distance matrix.
Example 38
Summary: Performs hierarchical clustering analysis on a data table, saving the distance matrix and generating a cluster summary.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
dt1 = obj << Save Distance Matrix;
obj1 = dt1 << Hierarchical Cluster( Y, Label( :Name ), Distance Matrix( 1 ), );
obj1 << Cluster Summary( 1 );
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save distance matrix.
- Open distance matrix table.
- Perform hierarchical clustering on matrix.
- Generate cluster summary.
Example 39
Summary: Performs hierarchical clustering analysis to identify patterns in age and sex variables, utilizing the Fast Ward method and standardizing data for optimal results.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster(
Y( :age, :sex ),
Method( "Fast Ward" ),
Standardize( 1 ),
Dendrogram Scale( "Even Spacing" ),
Number of Clusters( 5 )
);
obj << Save Clusters;
obj << Save Display Order;
myClusterID = dt << Get As Matrix( Column( "Cluster" ) );
myClusterOrder = dt << Get As Matrix( Column( "Cluster Order" ) );
rpt = Report( obj );
rpt1 = rpt << parent;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Specify clustering variables.
- Choose Fast Ward method.
- Standardize variables.
- Set dendrogram spacing.
- Define number of clusters.
- Save cluster assignments.
- Save display order.
- Extract cluster IDs.
- Extract cluster order.
- Generate report object.
- Navigate to parent report.
Example 40
Summary: Performs hierarchical clustering analysis to identify patterns in the Weight and Weight 2 variables, utilizing the Hierarchical Cluster platform.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :Weight, :Weight 2 ) );
Code Explanation:
- Open data table;
- Perform hierarchical clustering analysis.
- Use Weight and Weight 2 variables.
Example 41
Summary: Performs hierarchical clustering on columns c1, c2, and c3 in a data table, generating an initial report object and extracting the dendrogram data.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
rpt = obj << report;
dendro1 = rpt[Outline Box( "Hierarchical Clustering" )][If Box( 1 )] << get;
obj << Show Dendrogram( 0 );
rpt = obj << report;
dendro2 = rpt[Outline Box( "Hierarchical Clustering" )][If Box( 1 )] << get;
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns c1, c2, c3.
- Retrieve initial report object.
- Hide dendrogram display.
- Generate new report object.
- Extract updated dendrogram data.
Example 42
Summary: Performs hierarchical clustering analysis on a subset of data, saving cluster assignments and retrieving cluster details.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Where( :Species == "setosa" ), Y( :Sepal Length, :Sepal Width, :Petal Length, :Petal Width ) );
obj << Save Clusters;
clustCol = Column( dt, "Cluster Where" ) << get as matrix;
clust = obj << Get Clusters;
obj << Data Table Window;
dt1 = Current Data Table();
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Save cluster assignments.
- Retrieve cluster column.
- Get cluster details.
- Display data table window.
- Assign current data table.
Example 43
Summary: Performs hierarchical clustering analysis on columns c1, c2, and c3 in a data table, generating cluster summary without standardization.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Standardize( 0 ), Cluster Summary( 1 ), );
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use columns c1, c2, c3.
- Do not standardize data.
- Generate cluster summary.
Example 44
Summary: Performs hierarchical clustering analysis to identify patterns in the relationship between height and weight, generating a cluster summary report.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :height, :weight ), Cluster Summary( 1 ) );
Code Explanation:
- Open data table;
- Assign data table to variable.
- Perform hierarchical clustering analysis.
- Specify variables for clustering.
- Generate cluster summary report.
Example 45
Summary: Performs hierarchical clustering and cluster assignment for a dataset, generating a report with cluster summary and calculating population standard deviations.
Code:
dt = Open("data_table.jmp");
_mat = dt << get as matrix();
obj = dt << Hierarchical Cluster( Y( 1 :: 4 ), Number of Clusters( 4 ) );
obj << Cluster Summary( 1 );
rpt = obj << report;
clustMeans = (rpt[Outline Box( "Cluster Means" )][Table Box( 1 )] << get as matrix)[0, 3 :: 6];
popStdDev = Std Dev( _mat[0, 1] ) |/ Std Dev( _mat[0, 2] ) |/ Std Dev( _mat[0, 3] ) |/ Std Dev( _mat[0, 4] );
obj << Save Formula for Closest Cluster;
dt << New Column( "Clust Formula",
Formula(
IfMin(
((:Sepal length - clustMeans[1, 1]) / popStdDev[1]) ^ 2 + ((:Sepal width - clustMeans[1, 2]) / popStdDev[2]) ^ 2 + ((
:Petal length - clustMeans[1, 3]) / popStdDev[3]) ^ 2 + ((:Petal width - clustMeans[1, 4]) / popStdDev[4]) ^ 2,
1,
((:Sepal length - clustMeans[2, 1]) / popStdDev[1]) ^ 2 + ((:Sepal width - clustMeans[2, 2]) / popStdDev[2]) ^ 2 + ((
:Petal length - clustMeans[2, 3]) / popStdDev[3]) ^ 2 + ((:Petal width - clustMeans[2, 4]) / popStdDev[4]) ^ 2,
2,
((:Sepal length - clustMeans[3, 1]) / popStdDev[1]) ^ 2 + ((:Sepal width - clustMeans[3, 2]) / popStdDev[2]) ^ 2 + ((
:Petal length - clustMeans[3, 3]) / popStdDev[3]) ^ 2 + ((:Petal width - clustMeans[3, 4]) / popStdDev[4]) ^ 2,
3,
((:Sepal length - clustMeans[4, 1]) / popStdDev[1]) ^ 2 + ((:Sepal width - clustMeans[4, 2]) / popStdDev[2]) ^ 2 + ((
:Petal length - clustMeans[4, 3]) / popStdDev[3]) ^ 2 + ((:Petal width - clustMeans[4, 4]) / popStdDev[4]) ^ 2,
4
)
)
);
Code Explanation:
- Open data table;
- Convert data to matrix.
- Perform hierarchical clustering.
- Display cluster summary.
- Extract cluster means.
- Calculate population standard deviations.
- Save formula for closest cluster.
- Create new column for cluster formula.
- Define formula for cluster assignment.
- Assign cluster based on minimum distance.
Example 46
Summary: Performs hierarchical clustering analysis on a specified data table, saving the script to the Script Window and relaunching the analysis.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( 2 :: 4 ) );
obj << Save Script to Script Window;
For( ii = 1, ii <= N Items( Window() ), ii++,
If( (Window()[ii] << get Window title) == "Script Window",
scptStdData = Words( Trim( Window()[ii][Script Box( 1 )] << Get Line Text( 5 ) ), "," )[1];
Window()[ii] << Close Window;
Break();
)
);
obj << Relaunch Analysis;
For( ii = 1, ii <= N Items( Window() ), ii++,
If( (Window()[ii] << get Window title) == "Hierarchical Cluster",
clusterLnc = Window()[ii] << get journal;
Break();
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save script to window.
- Iterate through windows.
- Find script window.
- Extract script line.
- Close script window.
- Relaunch analysis.
- Iterate through windows again.
- Capture cluster journal.
Example 47
Summary: Performs hierarchical clustering analysis on a data table, generating a cluster summary report and extracting journal content from the axis box.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Two Way Clustering );
obj << Cluster Summary( 1 );
rpt = obj << report;
tmp = rpt[Outline Box( "Cluster Summary" )][AxisBox( 1 )] << get journal;
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Set two-way clustering.
- Generate cluster summary.
- Retrieve report object.
- Access cluster summary outline.
- Get axis box content.
- Extract journal from axis box.
Example 48
Summary: Performs hierarchical clustering analysis on multiple columns, generating a scatterplot matrix and parallel coordinate plots for visualization.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Standardize( 0 ), Cluster Summary( 1 ), );
Log Capture( obj << Scatterplot Matrix );
rptScatterPlotMat = Current Report();
obj << Parallel Coord Plots;
Close( dt, No Save );
dt = New Table( "Test", New Column( "Y1", Values( J( 10, 1, 0.45 ) ) ), New Column( "Y2", Values( J( 3, 1, 1 ) |/ J( 7, 1, 2 ) ) ) );
obj = dt << Hierarchical Cluster( Y( :Y1, :Y2 ), Cluster Summary( 1 ), Number of Clusters( 2 ), );
rpt = obj << report;
rSq = rpt[Outline Box( "Column Summary" )][Number Col Box( 1 )] << get as matrix;
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns c1, c2, c3.
- Log capture scatterplot matrix.
- Get current report.
- Create parallel coordinate plots.
- Close table without saving.
- Create new table "Test".
- Add column "Y1" with 10 values of 0.45.
- Add column "Y2" with 3 values of 1 and 7 values of 2.
- Perform hierarchical clustering on columns Y1, Y2 with 2 clusters.
Example 49
Summary: Performs hierarchical clustering analysis and extracts cluster method and distance matrix, then relaunches the analysis with a specified number of clusters.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize By( "Columns" ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
);
rpt = obj << report;
meth = rpt[Text Box( 1 )] << get text;
dist = rpt[Number Col Box( "Distance" )] << get as matrix;
obj << Relaunch Analysis;
For( i = 1, i <= N Items( Window() ), i++,
If( Window()[i] << get window title == "Hierarchical Cluster",
Window()[i][Radio Box( 1 )] << Set( 4 );
Window()[i][Button Box( 5 )] << Click();
rpt1 = Current Report();
Break();
)
);
meth1 = rpt1[Text Box( 1 )] << get text;
dist1 = rpt1[Number Col Box( "Distance" )] << get as matrix;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Extract cluster method.
- Extract distance matrix.
- Relaunch analysis.
- Loop through windows.
- Find hierarchical cluster window.
- Set number of clusters to 4.
- Click apply button.
- Extract new cluster method.
- Extract new distance matrix.
Example 50
Summary: Process of performing hierarchical clustering on a data table, enabling automatic recalculation and saving the script to the Script Window.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Label( :country ) );
obj << Automatic Recalc( 1 );
obj << Save Script to Script Window;
For( i = 1, i <= N Items( Window() ), i++,
If( Window()[i] << get window title == "Script Window",
lc = ((Window()[i][Script Box( 1 )] << Get Text()));
Window()[i] << Close Window();
Break();
)
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Enable automatic recalculation.
- Save script to script window.
- Loop through all windows.
- Find script window.
- Extract script text.
- Close script window.
- Break loop.
- End script.
Example 51
Summary: Process of creating a hierarchical cluster object from a data table, selecting all rows, and deleting selected rows.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( 2 :: 21 ) );
dt << Select All Rows << Delete Rows;
Code Explanation:
- Open data table.
- Create hierarchical cluster object.
- Select all rows.
- Delete selected rows.
Example 52
Summary: Performs hierarchical clustering on columns 2-21 of a data table, followed by deleting all selected rows and displaying the cluster summary.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( 2 :: 21 ) );
dt << Select All Rows << Delete Rows;
obj << Cluster Summary;
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns 2-21.
- Select all rows in the dataset.
- Delete all selected rows.
- Display cluster summary.
Example 53
Summary: Performs hierarchical clustering and two-way clustering on a subset of data columns, followed by cluster summary and deletion of selected rows.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( 2 :: 21 ) );
dt << Select All Rows << Delete Rows;
obj << Cluster Summary;
obj << Two Way Clustering;
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns 2-21.
- Select all rows in the table.
- Delete all selected rows.
- Display cluster summary.
- Perform two-way clustering.
Example 54
Summary: Performs hierarchical clustering analysis on a data table, saving cluster results and retrieving modeling type.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Label( :country ) );
obj << Save Clusters;
type = dt:Cluster << Get Modeling Type;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save cluster results.
- Retrieve modeling type.
Example 55
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and standardizing variables for optimal grouping.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster(
Y( :Sex, :Age, :Weight, :Oxy, :Runtime, :RunPulse, :RstPulse, :MaxPulse ),
Method( "Ward" ),
Standardize( 1 ),
);
Code Explanation:
- Open data table;
- Assign data table to variable.
- Perform hierarchical clustering.
- Specify variables for clustering.
- Choose Ward method.
- Standardize data.
Example 56
Summary: Performs hierarchical clustering analysis on columns 3 to 8 of a data table, generating parallel coordinate plots and labeling clusters by model.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( 3 :: 8 ), Label( :Model ), Number of Clusters( 3 ) );
obj << Parallel Coord Plots;
obj1 = Current Report();
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Use columns 3 to 8 for analysis.
- Label clusters by model.
- Specify 3 clusters.
- Generate parallel coordinate plots.
- Retrieve current report object.
Example 57
Summary: Performs hierarchical clustering analysis on columns 'birth' and 'death', extracting the number of clusters, and updating the missing value code for 'birth'.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :birth, :death ), Standardize Data( 1 ), );
rpt = obj << report;
nClust = (rpt[Outline Box( "Clustering History" )][Number Col Box( "Number of Clusters" )] << get)[1];
:birth << Set Property( "Missing Value Codes", 0 );
:birth << Set Values( [0, 0] );
obj2 = obj << Redo Analysis;
rpt2 = obj2 << Report;
nClust2 = (rpt2[Outline Box( "Clustering History" )][Number Col Box( "Number of Clusters" )] << get)[1];
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns "birth" and "death".
- Get report from clustering analysis.
- Extract number of clusters from report.
- Set missing value code for "birth" to 0.
- Modify values of "birth" to [0, 0].
- Redo the clustering analysis.
- Get report from new clustering analysis.
- Extract number of clusters from new report.
- Store both cluster counts in variables.
Example 58
Summary: Performs hierarchical clustering on columns c1, c2, and c3 in a data table, generating cluster summary reports and scatterplot matrices.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Standardize( 0 ), Cluster Summary( 1 ), );
Log Capture( obj << Scatterplot Matrix );
rptScatterPlotMat = Current Report();
obj << Parallel Coord Plots;
Code Explanation:
- Open data table;
- Perform hierarchical clustering on columns c1, c2, c3.
- Do not standardize data.
- Generate cluster summary report.
- Capture log output.
- Create scatterplot matrix.
- Save current report.
- Generate parallel coordinate plots.
Example 59
Summary: Calculates distances and cluster counts for hierarchical clustering analysis, utilizing data from a JMP data table.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( "Centroid" ), Standardize( 0 ) );
rpt = obj << report;
distances = Matrix( rpt[String Col Box( "Distance" )] << get );
leader = rpt[String Col Box( "Leader" )] << get;
joiner = rpt[String Col Box( "Joiner" )] << get;
_mat = dt << get as matrix( {2, 3, 4} );
distanceToFrom = J( N Rows( distances ), 1, 0 );
numClusters = J( N Rows( dt ), 1, 1 );
meanVector = J( N Rows( dt ), 3, 0 );
For( i = 1, i <= N Rows( distances ), i++,
rowNoLeader = (dt << Get Rows Where( :Name( "To/From" ) == leader[i] ))[1];
rowNoJoiner = (dt << Get Rows Where( :Name( "To/From" ) == joiner[i] ))[1];
FromLeader = _mat[rowNoLeader, 0];
ToJoiner = _mat[rowNoJoiner, 0];
If( numClusters[rowNoLeader] > 1,
FromLeader = meanVector[rowNoLeader, 0]
);
If( numClusters[rowNoJoiner] > 1,
ToJoiner = meanVector[rowNoJoiner, 0]
);
meanVector[rowNoLeader, 0] = (numClusters[rowNoLeader] * FromLeader + numClusters[rowNoJoiner] * ToJoiner) / (numClusters[rowNoLeader]
+ numClusters[rowNoJoiner]);
distanceToFrom[i] = Sqrt( Distance( FromLeader, ToJoiner ) )[1];
numClusters[rowNoLeader] += numClusters[rowNoJoiner];
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Extract cluster report.
- Retrieve distance data.
- Retrieve leader data.
- Retrieve joiner data.
- Convert data table to matrix.
- Initialize distance vector.
- Initialize cluster count vector.
- Initialize mean vector.
Example 60
Summary: Performs hierarchical clustering analysis to identify patterns in a dataset, retrieving cluster reports and extracting distance data for further processing.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( "Ward" ), Standardize( 0 ) );
rpt = obj << report;
distances = Matrix( rpt[String Col Box( "Distance" )] << get );
leader = rpt[String Col Box( "Leader" )] << get;
joiner = rpt[String Col Box( "Joiner" )] << get;
_mat = dt << get as matrix( {2, 3, 4} );
distanceToFrom = J( N Rows( distances ), 1, 0 );
wardDistanceToFrom = J( N Rows( distances ), 1, 0 );
numClusters = J( N Rows( dt ), 1, 1 );
meanVector = J( N Rows( dt ), 3, 0 );
For( i = 1, i <= N Rows( distances ), i++,
rowNoLeader = (dt << Get Rows Where( :Name( "To/From" ) == leader[i] ))[1];
rowNoJoiner = (dt << Get Rows Where( :Name( "To/From" ) == joiner[i] ))[1];
FromLeader = _mat[rowNoLeader, 0];
ToJoiner = _mat[rowNoJoiner, 0];
If( numClusters[rowNoLeader] > 1,
FromLeader = meanVector[rowNoLeader, 0]
);
If( numClusters[rowNoJoiner] > 1,
ToJoiner = meanVector[rowNoJoiner, 0]
);
meanVector[rowNoLeader, 0] = (numClusters[rowNoLeader] * FromLeader + numClusters[rowNoJoiner] * ToJoiner) / (numClusters[rowNoLeader]
+ numClusters[rowNoJoiner]);
distanceToFrom[i] = (Distance( FromLeader, ToJoiner ))[1];
wardDistanceToFrom[i] = Sqrt( distanceToFrom[i] / ((1 / numClusters[rowNoLeader]) + (1 / numClusters[rowNoJoiner])) );
numClusters[rowNoLeader] += numClusters[rowNoJoiner];
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Retrieve cluster report.
- Extract distance data.
- Extract leader data.
- Extract joiner data.
- Convert data table to matrix.
- Initialize distance matrices.
- Initialize cluster count matrix.
- Initialize mean vector matrix.
Example 61
Summary: Performs hierarchical clustering analysis on a data table, retrieving cluster reports and extracting distance matrices to facilitate further linkage calculations.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( "Average" ), Standardize( 0 ) );
rpt = obj << report;
distances = Matrix( rpt[String Col Box( "Distance" )] << get );
leader = rpt[String Col Box( "Leader" )] << get;
joiner = rpt[String Col Box( "Joiner" )] << get;
distanceToFrom = J( N Rows( distances ), 1, 0 );
averageLinkageToFrom = J( N Rows( distances ), 1, 0 );
leaderIndexList = {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}};
For( i = 1, i <= N Rows( distances ), i++,
rowNoLeader = (dt << Get Rows Where( :Name( "To/From" ) == leader[i] ))[1];
rowNoJoiner = (dt << Get Rows Where( :Name( "To/From" ) == joiner[i] ))[1];
tempDistance = 0;
averageLinkageToFrom[i] = tempDistance / (Length( leaderIndexList[rowNoLeader] ) * Length( leaderIndexList[rowNoJoiner] ));
leaderIndexList[rowNoLeader] = leaderIndexList[rowNoLeader] || leaderIndexList[rowNoJoiner];
leaderIndexList[rowNoJoiner] = leaderIndexList[rowNoLeader];
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Retrieve cluster report.
- Extract distance matrix.
- Extract leader column.
- Extract joiner column.
- Initialize distanceToFrom matrix.
- Initialize averageLinkageToFrom matrix.
- Define leader index list.
- Loop through distances, calculate linkage.
Example 62
Summary: Performs hierarchical clustering and distance matrix calculations for a given data table, allowing for repeated clustering with customizable cluster criteria.
Code:
dt = Open("data_table.jmp");
obj1 = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ) );
dtDist = obj1 << Save Distance Matrix;
obj2 = dtDist << Hierarchical Cluster( Y, Label( :Name ), Distance Matrix( 1 ), Cluster Criterion( 1 ) );
obj3 = dtDist << Hierarchical Cluster( Y, Label( :Name ), Distance Matrix( 1 ) );
obj3 << Cluster Criterion( 1 );
dt = New Table( "TestTable",
New Column( "Labels", Character, "Nominal", Set Values( {"a", "a", "b", "b"} ) ),
New Column( "a", Set Values( [1, 2, 3, 4] ) ),
New Column( "b", Set Values( [5, 6, 7, 8] ) )
);
For( i = 1, i <= 10, i++,
obj = dt << Hierarchical Cluster( Y( :a, :b ), Label( :Labels ), Distance Matrix( 1 ) )
);
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Save distance matrix.
- Cluster using saved distance matrix.
- Repeat hierarchical clustering with distance matrix.
- Set cluster criterion for third object.
- Create new table with labels.
- Loop 10 times.
- Perform hierarchical clustering within loop.
- End loop.
Example 63
Summary: Performs hierarchical clustering analysis using columns c1, c2, and c3 in a data table, with attribute and object IDs set to 'To/From'.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster(
Y( :c1, :c2, :c3 ),
Attribute ID( :Name( "To/From" ) ),
Object ID( :Name( "To/From" ) ),
Standardize( "Unstandardized" )
);
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Use columns c1, c2, c3.
- Set attribute ID.
- Set object ID.
- Do not standardize data.
Example 64
Summary: Performs hierarchical clustering analysis on a data table, using the Ward method and robust standardization to generate a report with distance matrix extraction.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( "Ward" ), Standardize( 0 ), Standardize Robustly( 1 ), );
rpt = obj << report;
dist = Matrix( rpt[Number Col Box( "Distance" )] << get );
Code Explanation:
- Open table.
- Perform hierarchical clustering.
- Use Ward method.
- Do not standardize.
- Use robust standardization.
- Retrieve report object.
- Extract distance matrix.
Example 65
Summary: Performs hierarchical clustering analysis on a data table using the Average linkage method and generates a report with distance matrix extraction.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( Average ), Standardize( 0 ) );
rep = Report( obj );
dist = rep[Number Col Box( "Distance" )] << get as matrix;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Use average linkage method.
- Do not standardize data.
- Create report object.
- Extract distance matrix.
Example 66
Summary: Performs hierarchical clustering analysis on a data table, using the single linkage method and retrieving the distance column box as a matrix.
Code:
dt = Open("data_table.jmp");
obj = dt << Hierarchical Cluster( Y( :c1, :c2, :c3 ), Method( Single ), Standardize( 0 ) );
rep = Report( obj );
dist = rep[Number Col Box( "Distance" )] << get as matrix;
Code Explanation:
- Open data table;
- Perform hierarchical clustering.
- Use single linkage method.
- Do not standardize data.
- Retrieve report object.
- Extract distance column box.
- Convert distances to matrix.
Example 67
Summary: Performs hierarchical clustering analysis on a data table, generating a scatterplot matrix and creating a new column while deleting existing ones.
Code:
dt = Open("data_table.jmp");
hc = dt << Hierarchical Cluster(
Y( :birth, :death ),
Label( :country ),
Method( "Ward" ),
Standardize Data( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 4 ),
SendToReport( Dispatch( {}, "Dendrogram", OutlineBox, {SetHorizontal( 1 )} ) )
);
dt << New Column( "Col4" );
Log Capture( dt << Delete Columns( {1, 2, 3} ) );
hc << Scatterplot Matrix;
hc << close window;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Create new column "Col4".
- Delete columns 1, 2, 3.
- Generate scatterplot matrix.
- Close hierarchical cluster window.
Example 68
Summary: Performs hierarchical clustering and parallel plotting to visualize relationships between variables, with certification values for quality control.
Code:
dt = Open("data_table.jmp");
hc = Hierarchical Cluster(
Y( :c1, :c2, :c3 ),
Method( "Ward" ),
Standardize( 0 ),
Color Clusters( 1 ),
Dendrogram Scale( "Distance Scale" ),
Number of Clusters( 2 ),
);
hc << Cluster Summary();
rpt = hc << report;
tb = rpt[Table Box( 2 )];
dt2 = tb << Make Into Data Table;
dt2 << Color or Mark by Column( :cluster );
pp = Parallel Plot(
Scale Uniformly( 1 ),
Center at zero( 1 ),
Y( :c1, :c2, :c3 ),
SendToReport( Dispatch( {}, "2", ScaleBox, {Min( -2 ), Max( 2 ), Inc( 0.5 ), Minor Ticks( 0 )} ) )
);
cert_ppvals = {values( 0.28278625, 0.08639375, 0.0230125, -1.0456, -0.00835, 0.069295 )};
cert_hcvals = {values( 0.28278625, 0.08639375, 0.0230125, -1.0456, -0.00835, 0.069295 )};
Report( hc )[FrameBox( 4 )] << Copy Frame Settings;
Report( pp )[FrameBox( 1 )] << Paste Frame Settings;
Code Explanation:
- Open data table.
- Perform hierarchical clustering.
- Generate cluster summary.
- Extract cluster table.
- Create new data table from summary.
- Color data table by cluster.
- Create parallel plot.
- Set plot scale and centering.
- Define certification values for parallel plot.
- Define certification values for hierarchical clustering.
- Copy frame settings from hierarchical cluster report.
- Paste frame settings to parallel plot report.
K Means Cluster
Example 1
Summary: Loads a data table, performs K-Means clustering with varying numbers of clusters (6-15), and generates reports for each analysis. The script also includes interactive features like biplots and report dispatching.
Code:
// K Means Cluster: CD3 to MCB
// Open data table
dt = Open("data_table.jmp");
// K Means Cluster: CD3 to MCB
K Means Cluster(
Y( :CD3, :CD8, :CD4, :MCB ),
{Number of Clusters( 6 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 7 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 8 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 9 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 10 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 11 ),
"K-Means Clustering"n,
Go( Biplot 3D( 1 ) )},
{Number of Clusters( 12 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 13 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 14 ),
"K-Means Clustering"n, Go},
{Number of Clusters( 15 ),
"K-Means Clustering"n, Go},
SendToReport(
Dispatch( {}, "Control Panel",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=6",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=7",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=8",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=9",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=10",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=12",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=13",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=14",
OutlineBox,
{Close( 1 )}
),
Dispatch( {},
"K Means NCluster=15",
OutlineBox,
{Close( 1 )}
)
)
);
Code Explanation:
- Open data table.
- Perform K Means Clustering.
- Analyze 6 clusters.
- Analyze 7 clusters.
- Analyze 8 clusters.
- Analyze 9 clusters.
- Analyze 10 clusters.
- Analyze 11 clusters with 3D biplot.
- Analyze 12 clusters.
- Close unnecessary reports.
Example 2
Summary: Loads a data table, performs K-Means Cluster analysis on variables CD3, CD8, CD4, and MCB with specific settings, and generates a 3D biplot. The control panel outline box is then closed.
Code:
// Normal Mixtures
// Open data table
dt = Open("data_table.jmp");
// Normal Mixtures
K Means Cluster(
Y( :CD3, :CD8, :CD4, :MCB ),
{Mixtures Tolerance( 0.00000001 ),
Mixtures MaxIter( 200 ),
Mixtures N Starts( 20 ),
Outlier Cluster( 0 ),
Diagonal Variance( 0 ),
Number of Clusters( 6 ),
Normal Mixtures, Go( Biplot 3D( 1 ) )
},
SendToReport(
Dispatch( {}, "Control Panel",
OutlineBox,
{Close( 1 )}
)
)
);
Code Explanation:
- Open data table.
- Run K Means Cluster analysis.
- Specify variables CD3, CD8, CD4, MCB.
- Set mixtures tolerance.
- Set maximum iterations.
- Set number of starts.
- Disable outlier cluster.
- Disable diagonal variance.
- Set number of clusters to 6.
- Use normal mixtures method.
- Generate 3D biplot.
- Close control panel outline box.
Example 3
Summary: Selects and clusters data rows using K-Means algorithm to identify patterns in Sepal Length, Width, Petal Length, and Width.
Code:
dt = Open("data_table.jmp");
dt << select rows( 1 :: 15 );
dt << select rows( 51 :: 65 );
dt << select rows( 101 :: 115 );
km = dt << K Means Cluster(
Y( :Sepal Length, :Sepal Width, :Petal length, :Petal width ),
{Number of Clusters( 3 ), K Means Cluster, Go( Parallel Coord Plots )},
);
Code Explanation:
- Open data table;
- Select first 15 rows.
- Select next 15 rows.
- Select last 15 rows.
- Perform K Means Clustering.
- Use Sepal Length, Width.
- Use Petal Length, Width.
- Set number of clusters to 3.
- Generate Parallel Coordinate Plots.
Example 4
Summary: Selects and clusters data rows using K Means Cluster, generating parallel coordinate plots in JMP.
Code:
dt = Open("data_table.jmp");
dt << select rows( 1 :: 15 );
dt << select rows( 51 :: 65 );
dt << select rows( 101 :: 115 );
km = dt << K Means Cluster(
Y( :Sepal Length, :Sepal Width, :Petal length, :Petal width ),
{Number of Clusters( 3 ), K Means Cluster, Go( Parallel Coord Plots )},
);
km << journal();
Code Explanation:
- Open data table.
- Select first 15 rows.
- Select next 15 rows.
- Select last 15 rows.
- Perform K Means clustering.
- Specify cluster variables.
- Set number of clusters to 3.
- Use K Means Cluster method.
- Generate parallel coordinate plots.
- Output results to journal.
Example 5
Summary: Runs K-Means clustering analysis on CD3 and CD8 variables, generating parallel coordinate plots and a biplot for the first cluster.
Code:
dt under test = Open("data_table.jmp");
obj = K Means Cluster(
Y( :CD3, :CD8 ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go( Parallel Coord Plots, Biplot( 1 ) )},
SendToReport( Dispatch( {}, "Control Panel", OutlineBox, {Close( 1 )} ) )
);
Code Explanation:
- Open data table;
- Perform K-Means clustering.
- Analyze CD3 and CD8 variables.
- Set number of clusters to 3.
- Generate parallel coordinate plots.
- Create biplot for first cluster.
- Close control panel outline box.
- Display clustering results.
- Save analysis output.
- Exit script.
Example 6
Summary: Runs K-Means clustering on a subset of columns in a data table, generating parallel coordinate plots and 3D biplots, and retrieving cluster method and number of clusters.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( 2 :: 7 ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go( Parallel Coord Plots, Biplot( 1 ), Biplot 3D( 1 ) )}
);
rpt = obj << report;
method = rpt[Combo Box( 1 )] << get;
noClust = rpt[Number Edit Box( 1 )] << get;
Code Explanation:
- Open data table;
- Perform K Means clustering.
- Select columns 2 to 7.
- Set number of clusters to 3.
- Generate parallel coordinate plots.
- Create biplot.
- Generate 3D biplot.
- Retrieve cluster method.
- Get number of clusters.
- Store results in variables.
Example 7
Summary: Runs K-Means clustering analysis on a dataset, generating reports and 3D biplots with varying settings for Self-Organizing Maps (SOM) and number of clusters.
Code:
dt = Open("data_table.jmp");
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( 1 ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( Yes ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( 0 ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster( Y( :Sepal length, :Sepal width, :Petal length, :Petal width ), Number of Clusters( 3 ), SOM( No ), Go );
rpt = obj << report;
obj << close window;
obj = K Means Cluster(
Y( :Sepal length, :Sepal width, :Petal length, :Petal width ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go}
);
obj << Biplot 3D( 1 );
obj << Biplot 3D( 0 );
Code Explanation:
- Open data table;
- Run K-Means Cluster with SOM=1.
- Get cluster report.
- Close cluster window.
- Run K-Means Cluster with SOM=Yes.
- Get cluster report.
- Close cluster window.
- Run K-Means Cluster with SOM=0.
- Get cluster report.
- Close cluster window.
- Run K-Means Cluster with SOM=No.
- Get cluster report.
- Close cluster window.
- Run K-Means Cluster with default settings.
- Create 3D biplot.
- Remove 3D biplot.
Example 8
Summary: Runs K-Means clustering on a filtered data table to identify 6 clusters, with normal mixtures enabled and cluster assignments saved.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster( Where( :species == "" ), Y( 1 :: 4 ), {Number of Clusters( 6 ), Normal Mixtures, Go}, );
obj << Save Clusters;
clustCol = Column( dt, "Cluster" ) << get as matrix;
obj << Save Cluster Formula;
clustFormCol = Column( dt, "Cluster Formula Where" ) << get as matrix;
obj << Data Table Window;
dt1 = Current Data Table();
Code Explanation:
- Open data_table data
- Perform K-Means clustering.
- Filter rows where species is empty.
- Use columns 1 to 4 for analysis.
- Set number of clusters to 6.
- Enable normal mixtures.
- Execute clustering.
- Save cluster assignments.
- Extract cluster column as matrix.
- Save cluster formula.
Example 9
Summary: Runs the K-Means clustering process on a data table, generating reports for each species and excluding rows based on specific conditions.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster( Y( 1 :: 4 ), By( :Species ), Go );
rpt = obj << report;
CCC_By_setosa = rpt[1][Number Col Box( "CCC" )] << get as matrix;
CCC_By_versicolor = rpt[2][Number Col Box( "CCC" )] << get as matrix;
CCC_By_virginica = rpt[3][Number Col Box( "CCC" )] << get as matrix;
dt << Select Where( :Species != "setosa" );
dt << Exclude;
obj1 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt1 = obj1 << report;
setosa_CCC = rpt1[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
dt << Select Where( :Species != "versicolor" );
dt << Exclude;
obj2 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt2 = obj2 << report;
versicolor_CCC = rpt2[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
dt << Select Where( :Species != "virginica" );
dt << Exclude;
obj2 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt2 = obj2 << report;
virginica_CCC = rpt2[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
Code Explanation:
- Open data table;
- Perform K-Means clustering by Species.
- Extract CCC report for setosa.
- Extract CCC report for versicolor.
- Extract CCC report for virginica.
- Select non-setosa rows.
- Exclude selected rows.
- Perform K-Means clustering on remaining data.
- Extract CCC report for setosa-only cluster.
- Reset row exclusions.
Example 10
Summary: Runs K-Means clustering on a data table, grouping by the Species variable and generating a biplot in 3D.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster( Y( 1 :: 4 ), By( :Species ), Go );
Code Explanation:
- Open data table;
- Perform K-Means clustering.
- Analyze all four variables.
- Group by Species variable.
- Execute the clustering process.
Example 11
Summary: Runs K-Means Cluster analysis on a data table, saving cluster assignments and formulas, and retrieving CCC values for setosa, versicolor, and virginica species.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster( Where( :species == "" ), Y( 1 :: 4 ), {Number of Clusters( 6 ), Normal Mixtures, Go}, );
obj << Save Clusters;
clustCol = Column( dt, "Cluster" ) << get as matrix;
obj << Save Cluster Formula;
clustFormCol = Column( dt, "Cluster Formula Where" ) << get as matrix;
obj << Data Table Window;
dt1 = Current Data Table();
Close( dt, No Save );
Close( dt1, No Save );
dt = Open("data_table.jmp");
obj = dt << K Means Cluster( Y( 1 :: 4 ), By( :Species ), Go );
rpt = obj << report;
CCC_By_setosa = rpt[1][Number Col Box( "CCC" )] << get as matrix;
CCC_By_versicolor = rpt[2][Number Col Box( "CCC" )] << get as matrix;
CCC_By_virginica = rpt[3][Number Col Box( "CCC" )] << get as matrix;
dt << Select Where( :Species != "setosa" );
dt << Exclude;
obj1 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt1 = obj1 << report;
setosa_CCC = rpt1[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
dt << Select Where( :Species != "versicolor" );
dt << Exclude;
obj2 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt2 = obj2 << report;
versicolor_CCC = rpt2[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
dt << Select Where( :Species != "virginica" );
dt << Exclude;
obj2 = dt << K Means Cluster( Y( 1 :: 4 ), Go );
rpt2 = obj2 << report;
virginica_CCC = rpt2[1][Number Col Box( "CCC" )] << get as matrix;
dt << Exclude( 0 );
Code Explanation:
- Open data table;
- Perform K Means Cluster analysis.
- Save cluster assignments.
- Retrieve cluster column as matrix.
- Save cluster formula.
- Retrieve cluster formula column as matrix.
- Display data table window.
- Close original data tables without saving.
- Open data table;
- Perform K Means Cluster analysis by species.
- Retrieve CCC for setosa.
- Retrieve CCC for versicolor.
- Retrieve CCC for virginica.
- Exclude non-setosa species.
- Perform K Means Cluster analysis.
- Retrieve CCC for setosa.
- Reset exclusion.
- Exclude non-versicolor species.
- Perform K Means Cluster analysis.
- Retrieve CCC for versicolor.
- Reset exclusion.
- Exclude non-virginica species.
- Perform K Means Cluster analysis.
- Retrieve CCC for virginica.
- Reset exclusion.
Example 12
Summary: Runs K-Means clustering on a data table, setting the number of clusters to 3 and disabling standardization, then saves cluster assignments and formulas.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go},
Standardize Data( 0 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Code Explanation:
- Open data table;
- Perform K-Means clustering.
- Set number of clusters to 3.
- Disable data standardization.
- Save cluster assignments.
- Save cluster formula.
- Retrieve expected cluster labels.
- Retrieve observed cluster labels.
Example 13
Summary: Runs K-means clustering on a data table, standardizing the data and saving cluster assignments and formulas.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go},
Standardize Data( 1 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Code Explanation:
- Open table.
- Perform K-means clustering.
- Set number of clusters to 3.
- Standardize data.
- Save cluster assignments.
- Save cluster formula.
- Retrieve expected cluster labels.
- Retrieve observed cluster labels.
Example 14
Summary: Runs the K-Means clustering process on a specified data table, with individual column scaling and cluster formula saving.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row, :palatine foramen, :jaw length ),
{SOM Bandwidth( 0.433012701892219 ), Number of Clusters( 3 ), SOM, Go},
Columns Scaled Individually( 1 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Code Explanation:
- Open table.
- Perform K Means Cluster.
- Specify cluster variables.
- Set clustering parameters.
- Scale columns individually.
- Save clusters.
- Save cluster formula.
- Get expected cluster labels.
- Get observed cluster labels.
- Convert labels to matrices.
Example 15
Summary: Runs K-Means clustering on a data table, specifying cluster variables and number of clusters, with SOM bandwidth adjustment and column scaling.
Code:
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row, :palatine foramen, :jaw length ),
{SOM Bandwidth( 0.433012701892219 ), Number of Clusters( 3 ), SOM, Go},
Columns Scaled Individually( 0 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Code Explanation:
- Open table.
- Perform K Means Cluster.
- Specify cluster variables.
- Set SOM Bandwidth.
- Define number of clusters.
- Use SOM method.
- Execute clustering.
- Scale columns individually.
- Save cluster assignments.
- Save cluster formula.
Example 16
Summary: Runs K-Means clustering and SOM analysis on a data table, saving cluster results and formulas, and retrieving expected and observed cluster labels.
Code:
ut relative epsilon = 1e-10;
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go},
Standardize Data( 0 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Close( dt, no save );
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row ),
{Number of Clusters( 3 ), Name( "K-Means Clustering" ), Go},
Standardize Data( 1 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Close( dt, no save );
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row, :palatine foramen, :jaw length ),
{SOM Bandwidth( 0.433012701892219 ), Number of Clusters( 3 ), SOM, Go},
Columns Scaled Individually( 1 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Close( dt, no save );
dt = Open("data_table.jmp");
obj = dt << K Means Cluster(
Y( :skull length, :teeth row, :palatine foramen, :jaw length ),
{SOM Bandwidth( 0.433012701892219 ), Number of Clusters( 3 ), SOM, Go},
Columns Scaled Individually( 0 )
);
obj << Save Clusters;
obj << Save Cluster Formula;
expCLabels = Column( "Cluster" ) << get as matrix;
obsCLabels = Column( "Cluster Formula" ) << get as matrix;
Code Explanation:
- Set relative epsilon.
- Open data table.
- Perform K Means Cluster analysis.
- Save cluster results.
- Save cluster formula.
- Get expected cluster labels.
- Get observed cluster labels.
- Close data table without saving.
- Repeat steps 2-8 with standardized data.
- Perform SOM clustering with individual scaling.
- Save cluster results.
- Save cluster formula.
- Get expected cluster labels.
- Get observed cluster labels.
- Perform SOM clustering without individual scaling.
- Save cluster results.
- Save cluster formula.
Cluster using Subset
Example 1
Summary: Runs text analysis and visualization for the Final Narrative column, utilizing Text Explorer to generate word clouds and perform latent class analysis with 5 clusters.
Code:
dt = Open("data_table.jmp") << Subset( Rows( 1 :: 100 ) );
te = dt << Text Explorer(
Text Columns( :Final Narrative ),
Show Word Cloud( 1 ),
Latent Class Analysis(
Number of Clusters( 5 ),
Maximum Number of Terms( 25 ),
Minimum Term Frequency( 10 ),
Word Clouds by Cluster( 1 )
),
Discriminant Analysis(
Column( :Weather Condition ),
Maximum Number of Terms( 25 ),
Minimum Term Frequency( 10 ),
Weighting( "TF IDF" ),
Number of Singular Vectors( 100 ),
Canonical Plot( 1, N Canon( 2 ) )
),
Layout( "Centered" ),
Coloring( "Arbitrary Colors" ),
Tokenizing( "Basic Words" ),
Minimum Characters per Word( 8 ),
Maximum Characters per Word( 8 ),
Maximum Number of Phrases( 25 ),
Language( "English" ),
SendToReport(
Dispatch( {}, "", IfBox, {Set Summary Behavior( "Visible" )} ),
Dispatch( {"Term and Phrase Lists"}, "", TableBox, {Set Summary Behavior( "Collapse" )} ),
Dispatch( {"Latent Class Analysis for 5 Clusters", "MDS Plot"}, "1", ScaleBox,
{Min( -10.8333333333333 ), Max( 15.8333333333333 ), Inc( 5 ), Minor Ticks( 1 )}
),
)
);
Code Explanation:
- Open data_table data
- Subset first 100 rows.
- Launch Text Explorer.
- Analyze Final Narrative column.
- Show word cloud.
- Perform latent class analysis.
- Set 5 clusters.
- Limit terms to 25.
- Require minimum term frequency of 10.
- Display word clouds by cluster.
Example 2
Summary: Analyze and visualize text data in a JMP report, including word cloud generation, latent class analysis, and discriminant analysis.
Code:
dt = Open("data_table.jmp") << Subset( Rows( 1 :: 100 ) );
te = dt << Text Explorer(
Text Columns( :Final Narrative ),
Show Word Cloud( 1 ),
Latent Class Analysis(
Number of Clusters( 5 ),
Maximum Number of Terms( 25 ),
Minimum Term Frequency( 10 ),
Word Clouds by Cluster( 1 )
),
Discriminant Analysis(
Column( :Weather Condition ),
Maximum Number of Terms( 25 ),
Minimum Term Frequency( 10 ),
Weighting( "TF IDF" ),
Number of Singular Vectors( 100 ),
Canonical Plot( 1, N Canon( 2 ) )
),
Layout( "Centered" ),
Coloring( "Arbitrary Colors" ),
Tokenizing( "Basic Words" ),
Minimum Characters per Word( 8 ),
Maximum Characters per Word( 8 ),
Maximum Number of Phrases( 25 ),
Language( "English" ),
SendToReport(
Dispatch( {}, "", IfBox, {Set Summary Behavior( "Visible" )} ),
Dispatch( {"Term and Phrase Lists"}, "", TableBox, {Set Summary Behavior( "Collapse" )} ),
Dispatch( {"Latent Class Analysis for 5 Clusters", "MDS Plot"}, "1", ScaleBox,
{Min( -10.8333333333333 ), Max( 15.8333333333333 ), Inc( 5 ), Minor Ticks( 1 )}
),
)
);
(te << Report)[Table Box( 2 )] << Set Selected Rows( [2] );
Code Explanation:
- Open data table.
- Subset first 100 rows.
- Launch Text Explorer.
- Analyze Final Narrative column.
- Show word cloud.
- Perform latent class analysis.
- Set number of clusters to 5.
- Configure latent class analysis parameters.
- Conduct discriminant analysis.
- Set discriminant analysis parameters.
- Adjust layout and appearance.
- Customize tokenization settings.
- Modify report summary behavior.
- Collapse term and phrase lists.
- Adjust MDS plot scale.
- Select second row in table box.
Cluster using New Column
Example 1
Summary: Performs hierarchical clustering analysis on a data table, generating distance matrices and visualizing the results.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Sex Continuous", Formula( If( :Sex == "F", 1, 2 ) ) );
dt:Sex Continuous << Delete Formula;
hclust = Expr(
dt << Hierarchical Cluster( Y( :Sex Continuous, :Age, :Weight, :Oxy, :Runtime, :RunPulse, :RstPulse, :MaxPulse ) )
);
dt:Sex Continuous[1 :: 3] = 0;
dt:Sex Continuous << Set Property( "Missing Value Codes", {0} );
obj1 = Eval( Name Expr( hclust ) );
dist1 = Matrix( Report( obj1 )[Number Col Box( "Distance" )] << get );
dt:Sex Continuous[1 :: 3] = .;
obj2 = Eval( Name Expr( hclust ) );
dist2 = Matrix( Report( obj2 )[Number Col Box( "Distance" )] << get );
Code Explanation:
- Open data_table data
- Create new column "Sex Continuous".
- Define formula for "Sex Continuous".
- Delete formula from "Sex Continuous".
- Define hierarchical clustering expression.
- Set first three "Sex Continuous" values to 0.
- Set missing value codes for "Sex Continuous".
- Execute hierarchical clustering with modified data.
- Retrieve distance matrix from first clustering result.
- Reset first three "Sex Continuous" values to missing.
- Execute hierarchical clustering again with original data.
- Retrieve distance matrix from second clustering result.
Example 2
Summary: Performs hierarchical clustering analysis on a data table, generating a report and extracting the second text box content.
Code:
dt = Open("data_table.jmp");
dt << New Column( "Empty", Numeric );
obj = dt << Hierarchical Cluster(
Y( :height, :weight, :Empty ),
Method( "Fast Ward" ),
Standardize Data( 1 ),
Missing value imputation( 1 )
);
rpt = obj << report;
txt = rpt["Hierarchical Clustering"][Text Box( 2 )] << get text;
Code Explanation:
- Open data table.
- Add new numeric column.
- Perform hierarchical clustering.
- Use Fast Ward method.
- Standardize data.
- Impute missing values.
- Generate cluster report.
- Extract hierarchical clustering section.
- Retrieve second text box content.
- Assign text to variable.
Cluster using Lock Data Table
Example 1
Summary: Performs hierarchical clustering analysis on a data table, capturing log output and generating a distance matrix.
Code:
dt = Open("data_table.jmp");
dt << Lock Data Table( 1 );
Log Capture(
obj = dt << Hierarchical Cluster(
Y( :age, :sex ),
Save Constellation Coordinates,
Save Clusters,
Save Display Order,
Save Cluster Hierarchy,
Save Cluster Tree,
Save Distance Matrix
)
);
dt << Lock Data Table( 0 );
Close( dt, No Save );
dt = New Table( "outputnomiss_small_onesex.sas7bdat",
New Column( "sex", Set Values( {2, 2} ) ),
New Column( "_TYPE_", Character, Nominal, Set Values( {CORR, CORR} ) ),
New Column( "_NAME_", Character, Nominal, Set Values( {numgeno31, numgeno32} ) ),
New Column( "numgeno25", Set Values( {0.1, 0.130465614610688} ) ),
New Column( "numgeno26", Set Values( {., .} ) ),
New Column( "numgeno27", Set Values( {0.232889003895833, -0.208890048326718} ) ),
New Column( "numgeno30", Set Values( {0.269679944985297, 0.219899748566771} ) ),
);
Column( "sex" ) << label( 1 );
Column( "_NAME_" ) << label( 1 );
obj1 = dt << Hierarchical Cluster(
By( :sex ),
Y( Name( "numgeno25" ), Name( "numgeno26" ), Name( "numgeno27" ), Name( "numgeno30" ) ),
Method( "Centroid" ),
Missing value imputation( 1 ),
Standardize( 0 ),
ColorClusters( 1 ),
Two way clustering,
Number of Clusters( 3 ),
Color Map( Blue to Gray to Red ),
Legend( 1 ),
Dendrogram Scale( Distance Scale )
);
dist1 = Report( obj1 )[Outline Box( "Clustering History" )][Number Col Box( "Distance" )] << get as matrix;
obj2 = dt << Hierarchical Cluster(
By( :sex ),
Y( Name( "numgeno25" ), Name( "numgeno26" ), Name( "numgeno27" ), Name( "numgeno30" ) ),
Method( "Centroid" ),
Missing value imputation( 1 ),
Standardize( 0 ),
ColorClusters( 1 ),
Two way clustering,
Number of Clusters( 3 ),
Color Map( Blue to Gray to Red ),
Legend( 1 ),
Dendrogram Scale( Distance Scale )
);
dist2 = Report( obj1 )[Outline Box( "Clustering History" )][Number Col Box( "Distance" )] << get as matrix;
Code Explanation:
- Open data table.
- Lock data table.
- Perform hierarchical clustering.
- Capture log output.
- Unlock data table.
- Close data table without saving.
- Create new data table.
- Label columns.
- Perform hierarchical clustering by sex.
- Extract distance matrix.
Example 2
Summary: Performs hierarchical clustering analysis on a data table, using age and sex as variables, and saves various results including constellation coordinates, clusters, display order, cluster hierarchy, cluster tree, and distance matrix.
Code:
dt = Open("data_table.jmp");
dt << Lock Data Table( 1 );
Log Capture(
obj = dt << Hierarchical Cluster(
Y( :age, :sex ),
Save Constellation Coordinates,
Save Clusters,
Save Display Order,
Save Cluster Hierarchy,
Save Cluster Tree,
Save Distance Matrix
)
);
dt << Lock Data Table( 0 );
Code Explanation:
- Open data table;
- Lock data table.
- Start log capture.
- Perform hierarchical clustering.
- Use age and sex as variables.
- Save constellation coordinates.
- Save clusters.
- Save display order.
- Save cluster hierarchy.
- Save cluster tree.
- Save distance matrix.
- Stop log capture.
- Unlock data table.
Cluster using N Rows
Example 1
Summary: Performs hierarchical clustering analysis on a data table, generating a report with cubic clustering criterion values.
Code:
dt = Open("data_table.jmp");
nR = N Rows( dt );
obj = dt << Hierarchical Cluster( Y( :Weight, :Oxy ), Label( :Name ), Method( "Ward" ), Standardize( 1 ), Cluster Criterion( 1 ), );
rpt = obj << report;
nClust = rpt[Outline Box( "Cubic Clustering Criterion" )][Number Col Box( "CCC" )] << get as matrix;
Code Explanation:
- Open data table;
- Get number of rows.
- Perform hierarchical clustering.
- Specify weight and oxy variables.
- Use name for labels.
- Apply Ward method.
- Standardize data.
- Use CCC criterion.
- Retrieve report object.
- Extract CCC values.
Example 2
Summary: Process of performing hierarchical clustering on a data table, generating a report with cluster information and extracting CCC values as a matrix.
Code:
dt = Open("data_table.jmp");
nR = N Rows( dt );
obj = dt << Hierarchical Cluster( Y( :Petal length, :Sepal width ), Method( "Ward" ), Standardize( 1 ), Cluster Criterion( 1 ), );
rpt = obj << report;
nClust = rpt[Outline Box( "Cubic Clustering Criterion" )][Number Col Box( "CCC" )] << get as matrix;
Code Explanation:
- Open data table;
- Count number of rows.
- Perform hierarchical clustering.
- Specify clustering method.
- Enable standardization.
- Set cluster criterion.
- Retrieve clustering report.
- Locate CCC outline box.
- Find CCC number column.
- Extract CCC values as matrix.
Cluster using Distribution
Example 1
Summary: Analyze and visualize multiple continuous variables, including Age, Weight, Oxy, Runtime, RunPulse, RstPulse, and MaxPulse, using a hierarchical clustering method with 4 clusters.
Code:
dt = Open("data_table.jmp");
obj = Distribution(
Nominal Distribution( Column( :Sex ) ),
Continuous Distribution( Column( :Age ) ),
Continuous Distribution( Column( :Weight ) ),
Continuous Distribution( Column( :Oxy ) ),
Continuous Distribution( Column( :Runtime ) ),
Continuous Distribution( Column( :RunPulse ) ),
Continuous Distribution( Column( :RstPulse ) ),
Continuous Distribution( Column( :MaxPulse ) )
);
rpt = obj << report;
obj << close window;
obj = Hierarchical Cluster(
Y( :Sex, :Age, :Weight, :Oxy, :Runtime, :RunPulse, :RstPulse, :MaxPulse ),
Method( "Ward" ),
Standardize( 1 ),
Two Way Clustering,
Number of Clusters( 4 ),
Color Map( "Blue to Gray to Red" ),
Legend( 1 )
);
rpt = obj << report;
Code Explanation:
- Open data table;
- Create distribution object.
- Analyze nominal Sex column.
- Analyze continuous Age column.
- Analyze continuous Weight column.
- Analyze continuous Oxy column.
- Analyze continuous Runtime column.
- Analyze continuous RunPulse column.
- Analyze continuous RstPulse column.
- Analyze continuous MaxPulse column.
Example 2
Summary: Creates a hierarchical cluster analysis report using the Ward method, with standardized data and color-coded clusters.
Code:
ut relative epsilon = 1e-9;
dt = Open("data_table.jmp");
obj = Distribution(
Nominal Distribution( Column( :Sex ) ),
Continuous Distribution( Column( :Age ) ),
Continuous Distribution( Column( :Weight ) ),
Continuous Distribution( Column( :Oxy ) ),
Continuous Distribution( Column( :Runtime ) ),
Continuous Distribution( Column( :RunPulse ) ),
Continuous Distribution( Column( :RstPulse ) ),
Continuous Distribution( Column( :MaxPulse ) )
);
rpt = obj << report;
obj << close window;
obj = Hierarchical Cluster(
Y( :Sex, :Age, :Weight, :Oxy, :Runtime, :RunPulse, :RstPulse, :MaxPulse ),
Method( "Ward" ),
Standardize( 1 ),
Two Way Clustering,
Number of Clusters( 4 ),
Color Map( "Blue to Gray to Red" ),
Legend( 1 )
);
rpt = obj << report;
Code Explanation:
- Set relative epsilon.
- Open data table;
- Create distribution object.
- Include nominal distribution for Sex.
- Include continuous distributions for other variables.
- Generate distribution report.
- Close distribution window.
- Perform hierarchical clustering.
- Use Ward method for clustering.
- Standardize data before clustering.
- Enable two-way clustering.
- Specify number of clusters as 4.
- Use blue-to-gray-to-red color map.
- Add legend to the plot.