Hi @abmayfield ,
Thanks for sharing the data table. I was able to find a few things.
- Found out where the error was that it keeps writing to the log window and fixed that. It's in the str call. Had to move a parenthesis to a different location.
- I found out that when doing K-fold or Holdback, you need to change the Validation() to Validation Method(). Then it works and proportions the data appropriately.
- I recoded how it tests for the modeling type of the column and made some associated changes.
- I also wrote it so the same code can be used for Nominal, Ordinal, and Continuous. This can be done simply by changing the variable y_resp -- the Y response column name. It does all the rest automatically.
- I also added a title to the results data table that changes with the "host" data table and the validation type so you can run all three methods and there will be no naming interference from JMP.
- The three NN fitting scripts in your data table can now by copy-pasted from one data table to the next without issues. I tested it with the first data table you sent, and it worked just fine.
It's getting a little more automated now, and is a bit improved. I would prefer to have it check the validation method and then generate the extra columns and assign values accordingly. Maybe in the next roll-out!
Here's what the code looks like in general. Notice that I was testing on the temperature column to check for continuous modeling types.
Names Default To Here( 1 );
dt = Current Data Table();
dt_parms = Data Table( "NN Tuning 8" );
dtp_name = dt_parms << get name;
dt_name = dt << get name;
//edit the line below so that it has the name of the column you want to model.
y_resp = "temperature (1, 2, 3)";
response_col = Column( dt, Eval( Eval Expr( Expr( y_resp ) ) ) );
dt_results = dt_parms << Subset( Output Table( "Output of " || dtp_name || " with (validation type)" || " for " || dt_name), All rows, Selected Columns Only( 0 ) );
//This tests the response column type to automatically set the values for pulling the data out of the report window.
//It also will create the appropriate columns depending on the modeling type of the response column.
coltype = response_col << Get Modeling Type;
If( coltype == "Ordinal",
o_box = 3;
ncol_box_v = 10;
ncol_box_test = 19;
dt_results << New Column( "Generalized R² Training" );
dt_results << New Column( "Generalized R² Validation" );
dt_results << New Column( "Generalized R² Test" );
dt_results << New Column( "Entropy R² Training" );
dt_results << New Column( "Entropy R² Validation" );
dt_results << New Column( "Entropy R² Test" );
dt_results << New Column( "RMSE Training" );
dt_results << New Column( "RMSE Validation" );
dt_results << New Column( "RMSE Test" );
dt_results << New Column( "Mean Abs Dev Training" );
dt_results << New Column( "Mean Abs Dev Validation" );
dt_results << New Column( "Mean Abs Dev Test" );
dt_results << New Column( "Misclassification Rate Training" );
dt_results << New Column( "Misclassification Rate Validation" );
dt_results << New Column( "Misclassification Rate Test" );
dt_results << New Column( "-LogLiklihood Training" );
dt_results << New Column( "-LogLiklihood Validation" );
dt_results << New Column( "-LogLiklihood Test" );
dt_results << New Column( "Sum Freq Training" );
dt_results << New Column( "Sum Freq Validation" );
dt_results << New Column( "Sum Freq Test" );
);
If( coltype == "Nominal",
o_box = 3;
ncol_box_v = 10;
ncol_box_test = 19;
dt_results << New Column( "Generalized R² Training" );
dt_results << New Column( "Generalized R² Validation" );
dt_results << New Column( "Generalized R² Test" );
dt_results << New Column( "Entropy R² Training" );
dt_results << New Column( "Entropy R² Validation" );
dt_results << New Column( "Entropy R² Test" );
dt_results << New Column( "RMSE Training" );
dt_results << New Column( "RMSE Validation" );
dt_results << New Column( "RMSE Test" );
dt_results << New Column( "Mean Abs Dev Training" );
dt_results << New Column( "Mean Abs Dev Validation" );
dt_results << New Column( "Mean Abs Dev Test" );
dt_results << New Column( "Misclassification Rate Training" );
dt_results << New Column( "Misclassification Rate Validation" );
dt_results << New Column( "Misclassification Rate Test" );
dt_results << New Column( "-LogLiklihood Training" );
dt_results << New Column( "-LogLiklihood Validation" );
dt_results << New Column( "-LogLiklihood Test" );
dt_results << New Column( "Sum Freq Training" );
dt_results << New Column( "Sum Freq Validation" );
dt_results << New Column( "Sum Freq Test" );
);
If( coltype == "Continuous",
o_box = 3;
ncol_box_v = 2;
ncol_box_test = 3;
dt_results << New Column( "R² Training" );
dt_results << New Column( "R² Validation" );
dt_results << New Column( "R² Test" );
dt_results << New Column( "RMSE Training" );
dt_results << New Column( "RMSE Validation" );
dt_results << New Column( "RMSE Test" );
dt_results << New Column( "Mean Abs Dev Training" );
dt_results << New Column( "Mean Abs Dev Validation" );
dt_results << New Column( "Mean Abs Dev Test" );
dt_results << New Column( "-LogLiklihood Training" );
dt_results << New Column( "-LogLiklihood Validation" );
dt_results << New Column( "-LogLiklihood Test" );
dt_results << New Column( "SSE Training" );
dt_results << New Column( "SSE Validation" );
dt_results << New Column( "SSE Test" );
dt_results << New Column( "Sum Freq Training" );
dt_results << New Column( "Sum Freq Validation" );
dt_results << New Column( "Sum Freq Test" );
);
imax = N Row( dt_parms );
For( i = 1, i <= imax, i++,
Nlayer = dt_parms:N_Layers[i];
If( dt_results:N_Layers[i] == 1,
dt_results:N_TanH_2[i] = 0;
dt_results:N_Linear_2[i] = 0;
dt_results:N_Gauss_2[i] = 0;
);
If( dt_results:N_Layers[i] == 2,
dt_results:N_Boosts[i] = 0;
dt_results:Learn_Rate[i] = 0.1;
);
NTH1 = dt_results:N_TanH_1[i];
NTH2 = dt_results:N_TanH_2[i];
NL1 = dt_results:N_Linear_1[i];
NL2 = dt_results:N_Linear_2[i];
NG1 = dt_results:N_Gauss_1[i];
NG2 = dt_results:N_Gauss_2[i];
Nboosts = dt_results:N_Boosts[i];
LR = dt_results:Learn_Rate[i];
TCov = dt_results:T_Cov[i];
RFit = dt_results:Robust_Fit[i];
PMethod = dt_results:Penalty_Method[i];
Ntours = dt_results:N_Tours[i];
str = Eval Insert(
"report = (dt << Neural(
Y( response_col ),
X(
:OFA...22_c0_g2_i1.p1,
:OFA...47_c0_g1_i1.p1,
:OFA...73_c1_g1_i3.p1,
:OFA...72_c1_g1_i1.p1,
:OFA...5_c1_g2_i15.p1,
:OFA...78_c2_g1_i3.p1,
:OFA...51_c4_g1_i1.p1,
:OFA...38_c0_g1_i8.p1,
:OFA...19_c0_g1_i1.p1,
:OFA...22_c2_g1_i4.p1,
:OFA...27_c1_g3_i5.p1,
:OFA...82_c3_g2_i3.p1,
:OFA...11_c1_g1_i7.p1,
:OFA...50_c2_g4_i1.p3,
:OFA...18_c1_g1_i7.p1,
:OFA...66_c2_g1_i3.p1,
:OFA...85_c0_g1_i2.p1,
:OFA...99_c5_g1_i6.p1,
:OFA...03_c2_g1_i1.p1,
:SYM...24_c0_g1_i1.p1,
:SYM...75_c0_g2_i1.p1,
:SYM...42_c0_g1_i1.p1,
:SYM...04_c0_g1_i1.p1,
:SYM...97_c0_g1_i1.p1,
:SYM...13_c0_g1_i1.p1,
:SYM...66_c0_g1_i1.p1,
:SYM...72_c0_g6_i1.p1,
:SYM...13_c0_g1_i1.p1 2,
:SYM...33_c0_g1_i1.p1 3,
:SYM...43_c0_g1_i1.p1,
:SYM...51_c0_g1_i1.p1,
:SYM...65_c0_g1_i1.p1 2
),
Validation ( :Validation with test ),
Informative Missing(0),
Transform Covariates(^TCov^),
Fit(
NTanH(^NTH1^),
NLinear(^NL1^),
NGaussian(^NG1^),
NTanH2(^NTH2^),
NLinear2(^NL2^),
NGaussian2(^NG2^),
Transform Covariates(^TCov^),
Penalty Method(\!"PMethod\!"),
Number of Tours(^Ntours^),
N Boost(^Nboosts^),
Learning Rate(^LR^)
),
Go,
invisible
)) << Report;"
);
Eval( Parse( str ) );
w = Window( dt << GetName || " - " || "Neural of " || y_resp );
T_stats = w[Outline Box( o_box ), Number Col Box( 1 )] << Get;
V_stats = w[Outline Box( o_box ), Number Col Box( ncol_box_v )] << Get;
Test_stats = w[Outline Box( o_box ), Number Col Box( ncol_box_test )] << Get;
report << Close Window;
If( coltype == "Ordinal",
dt_results:Generalized R² Training[i] = T_stats[1];
dt_results:Entropy R² Training[i] = T_stats[2];
dt_results:RMSE Training[i] = T_stats[3];
dt_results:Mean Abs Dev Training[i] = T_stats[4];
dt_results:Misclassification Rate Training[i] = T_stats[5];
dt_results:Name( "-LogLiklihood Training" )[i] = T_stats[6];
dt_results:Sum Freq Training[i] = T_stats[7];
dt_results:Generalized R² Validation[i] = V_stats[1];
dt_results:Entropy R² Validation[i] = V_stats[2];
dt_results:RMSE Validation[i] = V_stats[3];
dt_results:Mean Abs Dev Validation[i] = V_stats[4];
dt_results:Misclassification Rate Validation[i] = V_stats[5];
dt_results:Name( "-LogLiklihood Validation" )[i] = V_stats[6];
dt_results:Sum Freq Validation[i] = V_stats[7];
dt_results:Generalized R² Test[i] = Test_stats[1];
dt_results:Entropy R² Test[i] = Test_stats[2];
dt_results:RMSE Test[i] = Test_stats[3];
dt_results:Mean Abs Dev Test[i] = Test_stats[4];
dt_results:Misclassification Rate Test[i] = Test_stats[5];
dt_results:Name( "-LogLiklihood Test" )[i] = Test_stats[6];
dt_results:Sum Freq Test[i] = Test_stats[7];
);
If( coltype == "Nominal",
dt_results:Generalized R² Training[i] = T_stats[1];
dt_results:Entropy R² Training[i] = T_stats[2];
dt_results:RMSE Training[i] = T_stats[3];
dt_results:Mean Abs Dev Training[i] = T_stats[4];
dt_results:Misclassification Rate Training[i] = T_stats[5];
dt_results:Name( "-LogLiklihood Training" )[i] = T_stats[6];
dt_results:Sum Freq Training[i] = T_stats[7];
dt_results:Generalized R² Validation[i] = V_stats[1];
dt_results:Entropy R² Validation[i] = V_stats[2];
dt_results:RMSE Validation[i] = V_stats[3];
dt_results:Mean Abs Dev Validation[i] = V_stats[4];
dt_results:Misclassification Rate Validation[i] = V_stats[5];
dt_results:Name( "-LogLiklihood Validation" )[i] = V_stats[6];
dt_results:Sum Freq Validation[i] = V_stats[7];
dt_results:Generalized R² Test[i] = Test_stats[1];
dt_results:Entropy R² Test[i] = Test_stats[2];
dt_results:RMSE Test[i] = Test_stats[3];
dt_results:Mean Abs Dev Test[i] = Test_stats[4];
dt_results:Misclassification Rate Test[i] = Test_stats[5];
dt_results:Name( "-LogLiklihood Test" )[i] = Test_stats[6];
dt_results:Sum Freq Test[i] = Test_stats[7];
);
If( coltype == "Continuous",
dt_results:R² Training[i] = T_stats[1];
dt_results:RMSE Training[i] = T_stats[2];
dt_results:Mean Abs Dev Training[i] = T_stats[3];
dt_results:Name( "-LogLiklihood Training" )[i] = T_stats[4];
dt_results:SSE Training[i] = T_stats[5];
dt_results:Sum Freq Training[i] = T_stats[6];
dt_results:R² Validation[i] = V_stats[1];
dt_results:RMSE Validation[i] = V_stats[2];
dt_results:Mean Abs Dev Validation[i] = V_stats[3];
dt_results:Name( "-LogLiklihood Validation" )[i] = V_stats[4];
dt_results:SSE Validation[i] = V_stats[5];
dt_results:Sum Freq Validation[i] = V_stats[6];
dt_results:R² Test[i] = Test_stats[1];
dt_results:RMSE Test[i] = Test_stats[2];
dt_results:Mean Abs Dev Test[i] = Test_stats[3];
dt_results:Name( "-LogLiklihood Test" )[i] = Test_stats[4];
dt_results:SSE Test[i] = Test_stats[5];
dt_results:Sum Freq Test[i] = Test_stats[6];
);
);
Let me know if there are any further issues.
Thanks!,
DS