@HydeMiller, we may want to update this for JMP 18 since the setup will change and there will be a built in editor as well.
@HydeMiller I can help with updating this.
@SamGardner @Chris_Kirchberg @kemal_oflus Kemal asked me to help publish for a short term need. I do agree we need Python examples for JMP 18 and appreciate some help with that.
This is a collection of scripts that can be used to illustrate the new Python integration in JMP 18. Feel free to repost with any other examples you might have that worked well for a customer presentation. Thanks to all who helped develop these examples including Kemal Oflus, Sam Gardner and Paul Nelson.
For examples integrating with R using the new Python integration in JMP 18, see this companion post:
C80.1 JMP Python Use Cases - Examples Integrating with R
**************************************************************************************************
Dialog and Regression.py
- This is an example of using the Python Integration to do an analysis that JMP doesn't currently do, MLP or Multi-layer Perceptron Model
- numpy is used to build arrays
- pandas is used to build data frames
- sklearn is used for linear regression and multilayer perceptron
- sklearn is used to split modeling data into train and test sets
- sklearn is used to standardize modeling data
- JSL and the run_JSL() feature is used to open the table, build a column selector dialog and pass the selected data to Python
- See JMP Log for results
- Results are also saved as a JMP table and Graph Builder is used to make an Actual vs. Predicted Plot of the Linear Regression model and the MLP model from sklearn
**************************************************************************************************
GradientBar.py
- Python Classes, a type of object that bundles data and functionality together.
- Python def keyword which is used to define a function.
- The Pycairo package which provides bindings for the cairo graphics library.
- Using the Python integration to build a graph that is not natively supported in JMP. In this case, an example gradient bar graph is produced.
- Saving a graph generated by Python to a .png file and displaying the graph in a JMP picture box inside a JMP Window. The file is saved to $TEMP which can be determined by running Show(Convert File Path("$TEMP")) in a JMP script window, then see the JMP Log.
**************************************************************************************************
hdf5_import.py
- Using the Python integration to import a data format that is not natively supported in JMP. In this case, the data is hdf5 (hierarchical data format) which is popular in many scientific disciplines.
- The h5py package which supports importing hdf5 files.
- Some of the hdf5 data is copied to a JMP table and plotted in Graph Builder (this is spectral data).
**************************************************************************************************
jmp_slice.py
- Slicing in Python.
- Using Python’s slicing feature on JMP data tables.
- Opening JMP tables in Python and accessing values of cells in the tables.
**************************************************************************************************
parquet.py
- Using the Python integration to import a data format that is not natively supported in JMP. In this case, the data is parquet data.
- The PyArrow package which supports importing many different formats of data including parquet files.
- Creating a JMP table and saving the contents of the parquet file to the JMP table. This is done by by iterating on columns in pq_Table and adding one column at a time to the JMP table using a helper function.
- Python def keyword which is used to define a function. In this case, the function accepts arguments and returns an object.
- Use jmp.run_jsl() to set column properties of the JMP table.
**************************************************************************************************
local_import.py
- Importing a local user-written package. In this case, the package is called dt2pandas.
- This is a local package, meaning it is located in the same directory as the script which imports it.
- The local package has a defined function called dt2df. This creates a pandas dataframe in memory from a JMP data table.
**************************************************************************************************
pyFromJSL.py
- Using the Python Submit() feature.
- Using the Python Execute() feature.
- Calling a Python defined function from a JSL defined function.
- Nesting JSL inside Python inside JSL.
- Defining a Python function that can be used to manipulate JMP objects. In this case, the Python function uses the plus operator. In Python, the plus operator behaves differently when used with different types of data. With numberic data, plus returns the sum. With strings and lists, plus returns a concatenated string or list. With vectors and martrices, plus returns the element by element sum.
- The function defined in Python can be invoked in JSL using Python Execute().
- This can be further generalized by creating a JSL function that calls the Python function.
- JSL and Python code can be nested. In the example shown below:
- The script is JSL that calls Python using Python Submit().
- The Python code calls JSL using jmp.run_jsl().
- The end result is JSL calling Python which calls JSL.
- JSL Associative Arrays and Python Dictionaries. In the example below, an associative vector created in JSL is passed to Python using Python Submit(). In Python, the associative vector becomes a Python Dictionary.
**************************************************************************************************
array_handling.py
- Python Lists, arrays and numpy arrays.
- Marshalling data from Lists, arrays and numpy arrays to JMP Data Tables.
- Considerations on data types and compatibility with JMP Tables
- Considerations on None and NaN data and JMP Tables
- Using slicing and JMP Tables
- Pointers to data and Python buffer conventions
- Using run_jsl() to define column formulas and formats
- Python conventions for plus and asterisk operators on lists, arrays and numpy arrays
**************************************************************************************************
I also have plenty of examples that I can share. Many of were created as I was building and testing functionality. I this case most are basic functionality rather then and advanced statistics.
Hi @Paul_Nelson , more examples would be really useful. Can we schedule a session to look at what you have? I'll build some documentation around them.
Yes we can schedule a session. As I just got back from UK ( a week vacation after Manchester ), I'm still catching up this week.