cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Python and JMP 18

Hello,

 

I am trying to use a piece of code in JMP 18, but I am not sure I understand how it works. I install the pythonn packages at the very beginning, then I send my variables to Python and run the Python code. But I always get one of the following errors: Either it does not detect numpy, even though numpy is installed, or it no longer detects the variable I just sent.

 

	Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
lstMeasures = Column( dt, "height" ) << Get As Matrix();
		
		Python Install Packages( "numpy pandas scipy" );

		Python Send( lstMeasures );
		

		Python Submit(
			"
import numpy as np
from scipy.stats import kstest, norm, weibull_min, rayleigh

data = np.array(lstMeasures)

# Fit des lois
mu, sigma = norm.fit(data)
ks_norm = kstest(data, 'norm', args=(mu, sigma))

c, loc, scale = weibull_min.fit(data)
ks_weibull = kstest(data, 'weibull_min', args=(c, loc, scale))

loc_r, scale_r = rayleigh.fit(data)
ks_rayleigh = kstest(data, 'rayleigh', args=(loc_r, scale_r))
"
		);

		ks_norm = Python Get( ks_norm );
		ks_weibull = Python Get( ks_weibull );
		ks_rayleigh = Python Get( ks_rayleigh );

SophieCuvillier_0-1753778950656.png

SophieCuvillier_1-1753779073576.png

 

3 REPLIES 3
jthi
Super User

Re: Python and JMP 18

Are you running exactly that code in JMP's (JSL) Script editor? I don't quickly see any issues with the script and it does works fine for me

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
lstMeasures = Column(dt, "height") << Get As Matrix();
Python Install Packages("numpy pandas scipy");

Python Send(lstMeasures);

Python Submit("
import numpy as np
from scipy.stats import kstest, norm, weibull_min, rayleigh

data = np.array(lstMeasures)

mu, sigma = norm.fit(data)
ks_norm = kstest(data, 'norm', args=(mu, sigma))

c, loc, scale = weibull_min.fit(data)
ks_weibull = kstest(data, 'weibull_min', args=(c, loc, scale))

loc_r, scale_r = rayleigh.fit(data)
ks_rayleigh = kstest(data, 'rayleigh', args=(loc_r, scale_r))
");

ks_norm = Python Get(ks_norm);
ks_weibull = Python Get(ks_weibull);
ks_rayleigh = Python Get(ks_rayleigh);

show(ks_norm, ks_weibull, ks_rayleigh);

@Paul_Nelson 

 

Edit: Which JMP18 are you using?

-Jarmo

Re: Python and JMP 18

 Hello, I was using JMP Pro 18.0.0 but I restarted JMP and now I had no more issue ...

Re: Python and JMP 18

Sometimes, especially the very first time JMP is run you may have to restart JMP in order for JMP to recognize newly installed Python packages. Numpy is particularly finicky. Also, Python's package handling mechanism doesn't look re-look for a package that failed to import.  It knows it failed so why try again.  You can force a package reload attempt by using importlib and reload.  

Recommended Articles