Overview
These materials demonstrate the Python integration capabilities introduced in JMP 18. The demo focuses on network analysis of an anonymized Facebook data set with the NetworkX Python package. It is intended as an example of exploring data in JMP and seamlessly calling out to Python for a specific analysis that JMP does not offer.
The goal of the analysis is to quantify how “important” each node is to the network via calculating four centrality measures for each node: degree, betweenness, eigenvector, and closeness. The analysis returns a network graph and a JMP data table of centrality measures. JMP’s data exploration tools can be applied to the network data before the analysis and/or to the centrality measures produced by the analysis.
The example was developed by Kyra Dalbo, JMP Academic 2024 summer intern. Direct questions or requests to @Ross_Metusalem.
Demo Materials
The Data
The data set is from Stanford Network Analysis Project; specifically, it is the facebook_combined.txt file found here.
The data consist of ‘circles’ (or ‘friends lists’) of real user connections, with 4,039 users included and 88,234 edges or connections in total. The network is based around several ‘ego nodes’: focal nodes to which many other nodes are connected. The non-ego nodes also are connected to one another.
Each row represents one connection. For example, row 1 shows that Node 0 is connected to Node 1. Note that the script requires numeric Node IDs.
The materials include two versions of the data: the full data set of 88,234 connections and a subset of 37,655 connections. The subset consists of data for all nodes with ID values <= 2,000. In testing, the subset can be analyzed quickly enough to demo live. The full data set may take too long for live demo.
The Analysis Script
The analysis script is provided both as a Python script with embedded JSL code and a JSL script with embedded Python code. The JSL script has also been bundled as a JMP add-in for demonstrating a solution that is “no-code” to the end-user.
Each includes an interactive JMP launch dialog that allows the user to specify the columns for analysis and which of the four centrality measures should be calculated.
Each automatically installs any necessary Python packages.
Demo Flow
At the outset, consider a quick exploration of the network data before running the analysis script. For example, you can stack the two node columns and use Distribution, Graph Builder, or Tabulate on the stacked data to quantify the number of connections of each node. This corresponds to the node’s degree centrality.
Next, you can run the network analysis and use JMP to explore the centrality measures. For example, use Graph Builder to plot betweenness by degree and identify several nodes that have low degree but relatively high betweenness. These nodes have few connections but nevertheless serve as crucial connections between many other pairs of nodes. These low-degree high-betweenness nodes are apparent in the graph as large, darkly colored points.
See the attached video for an example demo. Note that the video portrays a demo specifically aimed at university statistics instructors – the demo was developed for the Academic team – but should not be difficult to adapt for commercial customers.
Technical Notes
- Minimum JMP version: 18.
- Required Python packages: jmp, jmputils, networkx, matplotlib, pandas, numpy, scipy, os, tempfile.
- The code operates on the currently active JMP data table. Have the table open and active before running the analysis.
- The data table must contain two numeric columns of node ID values, with each row representing one connection.
- The script converts the JMP data table to a Pandas data frame for input into NetworkX.
- Analysis of the full data set can take up to several minutes depending on your machine. A data subset is provided that can be analyzed in approximately 30 seconds on a 2021 Macbook Pro with M1 Pro processor.
- To display the network graph in JMP, the graph is first saved as a png to the OS’s temporary directory and then opened using JSL. The png file is automatically deleted from the temporary directory.
Products and Scripted Platforms
Products: JMP 18+
Scripted Platforms: Python integration
Data Source
Files
- NetworkData_Full.jmp: Full data set of 88,234 Facebook connections
- NetworkData.jmp: Subset of the NetworkData_Full.jmp that may be practical for live demos
- networkAnalysis.jsl: JSL script that completes the network analysis
- networkAnalysis.py: Python script that completes the network Analysis
- Network Centrality Measures.jmpaddin: Add-in that runs the same JSL code as in networkAnalysis.jsl
- Demo Example.mp4: example demonstration