Python e JMP 18Ciao,
Sto cercando di usare un pezzo di codice in JMP 18, ma non sono sicuro di aver capito come funziona. Installo i pacchetti Python all'inizio, poi invio le mie variabili a Python ed eseguo il codice Python. Ma ricevo sempre uno dei seguenti errori: o non rileva numpy, anche se è installato, oppure non rileva più la variabile che ho appena inviato.
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 );


Automazione e scriptingRe: Python e JMP 18Stai eseguendo esattamente quel codice nell'editor di script di JMP (JSL)? Non vedo subito problemi con lo script e funziona bene per 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
Re: Python e JMP 18Ciao, stavo usando JMP 18.0.0 ma ho riavviato JMP e ora non ho più avuto problemi...
Re: Python e JMP 18A volte, soprattutto la prima volta che si esegue JMP, potrebbe essere necessario riavviarlo affinché JMP riconosca i pacchetti Python appena installati. Numpy è particolarmente pignolo. Inoltre, il meccanismo di gestione dei pacchetti di Python non cerca di nuovo un pacchetto la cui importazione non è riuscita. Sa che è fallito, quindi perché riprovare? È possibile forzare un tentativo di ricaricamento del pacchetto utilizzando importlib e reload.