Python 和 JMP 18你好,
我正在嘗試在 JMP 18 中使用一段程式碼,但我不確定我是否理解它的工作原理。我一開始就安裝了 pythonn 套件,然後將變數傳送到 Python 並運行 Python 程式碼。但我總是收到以下錯誤之一:要么它無法檢測到 numpy(即使安裝了 numpy),要么它不再檢測到我剛剛發送的變數。
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 );


自動化和腳本回覆:Python 和 JMP 18您是否在 JMP(JSL)腳本編輯器中運行了該程式碼?我暫時沒發現該腳本有什麼問題,它對我來說運作良好。
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
回覆:Python 和 JMP 18您好,我之前使用的是 JMP 18.0.0,但我重新啟動了 JMP,現在不再出現問題了…
回覆:Python 和 JMP 18有時,尤其是第一次執行 JMP 時,您可能需要重新啟動 JMP 才能識別新安裝的 Python 套件。 Numpy 特別挑剔。此外,Python 的套件處理機制不會重新尋找導入失敗的套件。它知道導入失敗了,所以為什麼要重試呢?您可以使用 importlib 和 reload 強制重新載入套件。