自動化神經網絡大家好,
我正在進行一個項目,使用神經網路模型來預測由其唯一座標定義的不同位置(大約 1000 個)的土壤濕度。JMP 中神經網路的相同結構可以應用於所有站點。 因此,我正在考慮將工作自動化。 它可以是一個 JMP 腳本,可以找到位置協調器(X,Y),提取必要的資料輸入,並運行神經網路。 最後,腳本可以儲存模型的報告。 您有什麼建議或建議可以與我分享嗎?
先感謝您。
任何建議或討論表示讚賞。
回覆:神經網路自動化你好@giaMSU ,
這聽起來很可行,但你的問題相當開放。您發現哪些障礙需要社區協助解決?
我將從神經網路的腳本開始,看看您需要在腳本中為每個位置進行替換。定義函數或表達式來提取特定於位置的信息,執行神經網路分析,保存報告/腳本。迭代每次運行該函數/表達式的位置。
回覆:神經網路自動化@giaMSU ,你計劃要做的事情是可能的。步驟1。 使用 Summarize 函數建立每個 J = 1000+ 位置的清單。第2步。 對清單中的 J 位置建立索引。步驟3。 使用「選擇位置」和「子集」函數為第 j 個位置建立資料集。步驟4。 針對第 j 個位置運行第 j 個神經網路模型。步驟 5。 以您所需的格式儲存 NN 平台報告。 步驟 6。 重複直到到達最後一個位置。我沒有測試,但以下內容應該有效或讓您真正接近。
//assumes data table is "dt" and location is in a variable called "Location"
Summarize( locs = BY(dt:Location) );
For(
j=1, j<=NItems(locs), j++,
file = dt << Select Where(locs[j] == :Location) << Subset(
file,
Output Table Name("Model Subset File")
);
NN = file << Neural(
Y( :Name( "Y" ) ),
X( :Name( "X1" ), :Name( "X2" ) ),
Validation( :Validation ),
Informative Missing( 0 ),
Set Random Seed( 1121 ),
Fit( NTanH( 3 ) )
);
NNReport = NN << Report;
NNReport << Save PDF("Path")
);回覆:神經網路自動化@G_M我喜歡你的方法。
為了@giaMSU ,您所要做的就是運行神經網路的一種情況,並將腳本儲存到腳本視窗(或剪貼簿)。 (最上面的紅色三角形選單,清單中的最後一個選項,「儲存腳本」)
拿G_M寫的腳本,替換這部分:
Neural(
Y( :Name( "Y" ) ),
X( :Name( "X1" ), :Name( "X2" ) ),
Validation( :Validation ),
Informative Missing( 0 ),
Set Random Seed( 1121 ),
Fit( NTanH( 3 ) )
);
有了你的神經腳本,你可能就可以開始了,或至少已經完成了 90%。
回覆:神經網路自動化感謝您的協助。 我編寫了一個包含 2 個位置資料集的腳本。
首先,我使用了在 JMP 14 Pro 上運行的神經網路保存的神經腳本。 我使用了兩個隱藏層,分別有六個節點和三個節點。
Neural(
Y( :Name( "SoilMoisture(kg.m-2) or (mm)" ) ),
X(
:Name( "Tmax(K)" ),
:Name( "Tmin(K)" ),
:Name( "Precip(mm)" ),
:LAI_hv,
:LAI_lv,
:Name( "Winspeed(m/s)" ),
:Name( "Evatransporation(kgm-2s-1)" ),
:LandCover,
:USDASoilClass,
:Forecast_Albedo
),
Informative Missing( 0 ),
Transform Covariates( 1 ),
Validation Method( "KFold", 7 ),
Set Random Seed( 1234 ),
Fit(
NTanH( 1 ),
NLinear( 1 ),
NGaussian( 1 ),
NTanH2( 3 ),
NGaussian2( 3 ),
Transform Covariates( 1 ),
Robust Fit( 1 ),
Penalty Method( "Absolute" ),
Number of Tours( 10 )
)
);
這部分效果很好。 然後我按照 G_M 的建議添加 For 循環。
dt = Open( "E:/Ready_for_ANN/Subset of 765-450.jmp" );
Summarize(locs=BY(dt:ID))
For (
j=1, j<=NItems(locs),j++,
file = dt << Select Where(locs[j])== :ID << Subset(
file,
Output Table Name ("Model Subject File"))
);
NN = file << Neural(
Y( :Name( "SoilMoisture(kg.m-2) or (mm)" ) ),
X(
:Name( "Tmax(K)" ),
:Name( "Tmin(K)" ),
:Name( "Precip(mm)"),
:LAI_hv,
:LAI_lv,
:Name( "Winspeed(m/s)" ),
:Name( "Evatransporation(kgm-2s-1)" ),
:LandCover,
:USDASoilClass,
:Forecast_Albedo
),
Informative Missing( 0 ),
Transform Covariates( 1 ),
Validation Method( "KFold", 7 ),
Set Random Seed( 1234 ),
Fit(
NTanH( 1 ),
NLinear( 1 ),
NGaussian( 1 ),
NTanH2( 3 ),
NLinear2( 0 ),
NGaussian2( 3 ),
Transform Covariates( 1 ),
Robust Fit( 1 ),
Penalty Method( "Absolute" ),
Number of Tours( 10 )
)
);
NNReport = NN << Report;
NNReport << Save PDF("E:/Ready_for_ANN/result")然後,它就不起作用了。
據我從腳本中了解到,For 循環創建了一個子集,其中包括從 j=1 到 j++ 的所有 ID。 然後這個子集將被神經腳本使用。 但神經部分不包含在 For 迴圈中。 那麼,這不是我想做的事。
我想建立 1 個位置資料的子集,並在每個步驟中運行該子集的神經網路。如果我錯了,請糾正。
我在此處附加了我的資料子集(02 個位置)。
請幫我解決這個問題。
先感謝您。
回覆:自動化神經網絡嗨,G_M,
我已經嘗試過你的腳本。 它運作良好,但不完全如我所願。 看起來該腳本從所有位置提取資料以建立子集,然後運行神經網路。 我用 02 個位置的子集對其進行了測試。 神經運行了兩次。 然而,他們的報告是相同的。 所以我認為 For 迴圈有一些問題。 請你幫助我好嗎 ? 我在本次討論中附上了我的腳本和數據,以防您需要使用。
謝謝回覆:自動化神經網絡我認為問題在於您需要在 SelectWhere 函數中的 :ID 周圍新增 Char 函數。
Select Where(loc[j] == Char(:ID))
回覆:自動化神經網絡該腳本現在運行良好。
劇本有個小問題。 由於您將該檔案命名為“模型子集檔案”,因此該腳本會在每個步驟中取代 PDF 檔案。 完成後,資料夾中只有一個檔案。 您能否幫我將位置 ID 新增到檔案名稱中,以便腳本可以使用唯一的名稱記錄每個報告?
謝謝
回覆:神經網路自動化聽起來報告已經寫完了。 嘗試將 ID 連線到報告,如下所示:
Save PDF("C:\test\model_"|| Char(i) ||".pdf");回覆:神經網路自動化嗨,G_M
在您的幫助下,我進行了近千次神經網路分析。 另外,我還保存了一千個 NN 報告的 pdf 檔。 然後,這成為一個問題,因為我需要手動閱讀許多 pdf 檔案才能取得每個 NN 的 R2。
我嘗試添加取得 R 方測試到腳本中,以便它可以顯示 R2 值。 然後我可以使用將它們與文件一起保存
obj << Save (Get Gen RSquare Test)
該腳本仍在運行,但它不會在任何地方保存 R2 值。 我看不到價值。
你能幫我解決這個問題嗎?
太感謝了。
腎絲球腎
回覆:神經網路自動化@giaMSU ,因此我可能採用的方法是存取報表圖層並從報表圖層的樹狀結構中的相應顯示框中取得值。 捕獲後,報告中的 R^2_i 統計資料可以將值插入列表,然後從列表建立資料表,或建立資料表並將值連接到單一資料表中。 在腳本索引中搜尋“顯示樹結構”。
回覆:神經網路自動化學習劇本。回覆:神經網路自動化嗨@giaMSU ,
我喜歡自動化神經網路擬合的想法,我已經為其他平台做了類似的事情。我想我會嘗試為神經網路做類似的事情,以測試神經網路平台中的各種擬合參數,以找到最佳擬合。
我做了一些非常相似的事情,但使用了不同的建模平台(隨機森林和增強樹)。我將在下麵包含我的程式碼以及主要線路功能的描述。
但一般來說,每次選擇新位置時,您不會將新資訊提供給神經網路擬合。擬合實際上需要位於 FOR 迴圈內。我將我的作為腳本代碼放在我的數據表中,這樣做是因為我需要運行一個非常大的調整表以獲得最佳擬合,當我這樣做時,它為我的計算機節省了大量內存,而且你透過這種方式,可以在數據表中處理超過 24k+ 行,並讓它運行過夜。
順便說一句,這個最初的概念和擬合循環的想法是透過 gzmorgan0 的貼文想到的,但我不記得原來的貼文了。我用它所有的時間。
Names Default To Here( 1 );//keeps all variables local<BR />
dt = Data Table( "My data table" ); //this is where you specify your data table with the :Y and :X columns
dt_pars = Data Table( "tuning table" ); //for me, this is my tuning table that has modified tuning parameters. For you, it might be the "Model Subject File" data table.
dt_results = dt_pars << Subset( All rows, Selected columns only( 0 ) ); //this just duplicate the above dt because I want to add columns for recording fit parameters.
<BR />//the below portion creates new columns for recording the fit parameters.<BR />dt_results << New Column("Overall In Bag RMSE");
dt_results << New Column("Overall Out of Bag RMSE");
dt_results << New Column( "R² Training" );
dt_results << New Column( "R² Validation" );
dt_results << New Column( "RMSE Training" );
dt_results << New Column( "RMSE Validation" );
<BR />//The FOR loop here is to actually run the fit with each of the different tuning parameters.
For( i = 1, i <= N Row( dt_pars ), i++,<BR /> //these next few lines pulls the NEW fit parameters to put into the model fit. This would be each new row of data (location) for your case
NumTrees = dt_pars:Number Trees[i];
NumTerms = dt_pars:Number Terms[i];
PortBoot = dt_pars:Portion Bootstrap[i];
MinSplpTr = dt_pars:Minimum Splits per Tree[i];
MaxSplpTr = dt_pars:Maximum Splits per Tree[i];
MinSplSz = dt_pars:Minimum Size Split[i];<BR /><BR /> //this next section is a string that will be evaluated below and represents what you would do via a normal GUI in JMP.
str = Eval Insert(
"report = (dt << Bootstrap Forest( //this is the fit method
Y( :Y_Response ), //whatever your response variable is
X(
:X_1, //these are all your x variables that you put in (which you want to be changing each time)
:X_2,
:X_3,
),
Minimum Size Split( ^MinSplSz^ ), //here is where something is changing and the new values are inserted via the ^ ^ and fed to the fit method. Here is where you'd want to do something similar, but above with the :X's
Validation Portion( 0.2 ), //this too can even be a variable and changed each time.
Set Random Seed( ),
Method( \!"Bootstrap Forest\!" ), //this again defines the method
Minimum Splits per Tree( ^MinSplpTr^ ),
Maximum Splits per Tree( ^MaxSplpTr^ ),
Portion Bootstrap( ^PortBoot^ ),
Number Terms( ^NumTerms^ ),
Number Trees( ^NumTrees^ ),
Early Stopping( 0 ),
Go,
invisible
)) << Report;"
); //this closes the Eval Insert() command<BR />
Eval( Parse( str ) ); //this actually runs the fit for each iteration<BR /><BR /> //The below lines, I pull out the relevant fit statistic I want to evaluate from the report and save it to the data table called dt_results. I can then analyze my multiple thousand data points later and not chew up too much RAM.
Overall=report["Overall Statistics"][Number Col Box( 1 )] << Get;
R2 = report["Overall Statistics"][Number Col Box( 2 )] << Get;
RMSE = report["Overall Statistics"][Number Col Box( 3 )] << Get;
report << Close Window;
dt_results:Name("Overall In Bag RMSE")[i]=Overall[1];
dt_results:Name("Overall Out of Bag RMSE")[i]=Overall[2];
dt_results:Name("R² Training")[i] = R2[1];
dt_results:Name("R² Validation")[i] = R2[2];
dt_results:Name("RMSE Training")[i] = RMSE[1];
dt_results:Name("RMSE Validation")[i] = RMSE[2];
);我想您應該能夠從上面獲取大綱並根據您的具體需求進行修改。
順便說一句,不要忘記不僅要進行擬合驗證以免過度擬合,還要在從擬合資料中分離出的完全未使用的測試資料集上測試其預測能力。另外,如果你能負擔得起,我建議增加旅行次數> = 25。神經網路平台有時需要更多的嘗試,例如在 DOE 中找到給定參數集的最佳擬合。
祝你好運!我希望看到最終的解決方案。我也可能會嘗試一下。
感謝您啟動此線程。
DS