JSL - Repeats within a platform functionNames Default To Here( 1 );
// Create an Example data table
dt = currentdatatable();
// Get the names of the columns in the data table
colNames = dt << get column group( "WLS" );
nIters = 2;
Neural(
Y( :Type ),
X(eval(colNames)),
Validation Method( "KFold", 5 ),
Set Random Seed( 2 ),
for( k=1, k <= nIters, k++, Fit( NTanH ( 2 ) ) ),
);
I am trying to fit more than 1 neural model using attached script. If instead of the for-loop I write several times Fit( NTanH(2)) it works fine, but with a for-loop I cannot get it to work. Any suggestins? Thanks!
Automation and ScriptingData Exploration and VisualizationRe: JSL - Repeats within a platform functionYou could move the Fit(NTanH()) outside the Neural(). Below is example from scripting index:

Modified version from scripting index with for loop:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Boston Housing.jmp");
obj = Neural(
Y(:mvalue),
X(:crim, :indus, :chas, :nox, :rooms, :age, :distance, :radial),
Set Random Seed(2)
);
For(i = 1, i <= 2, i++,
obj << Fit(NTanH(4));
);

Re: JSL - Repeats within a platform functionHi Jarmo, that was an option that I did not try and it is a solution to my problem. Works fine. Thank you!
Re: JSL - Repeats within a platform functionHi Jarmo, Below is a working script:
Names Default To Here( 1 );
delete symbols();
dt = current data table();
colNames = dt << get column group("WLs");
exclColnames = dt << get excluded columns();
For( i = 1, i <= N Items( exclColnames ), i++,
Remove From( colNames, As List( Loc( colNames, exclColnames[i] ) ) )
);
rpt = New Window( "Neural of Type", dt <<
Neural(
Y( :Type ),
X( eval ( colNames ) ),
Informative Missing( 0 ),
Validation Method( "KFold", 5 ),
Set Random Seed( 2 ),
Fit( NTanH( 2 ) ),
Fit( NTanH( 2 ) ),
Fit( NTanH( 2 ) )
)
);
Wait( 0 );
rpt["Neural", Outline Box( 1 ), "Validation", "Type", Table Box( 1 )] <<
Make Combined Data Table;
rpt << Close Window;However, I want to make the Fit( NTanH(2)) flexibe. The way you demonstrated does not work here, I tried to solve it by next script (leaving out the first part):
obj =Neural(
Y( :Type ),
X( eval ( colNames ) ),
Informative Missing( 0 ),
Validation Method( "KFold", 5 ),
Set Random Seed( 2 ),
);
for(i=1, i<=3, i++, obj << Fit( NTanH(2)));
rpt = current window();<BR />
Wait( 0 );
rpt["Neural", Outline Box( 1 ), "Validation", "Type", Table Box( 1 )] <<
Make Combined Data Table;
rpt << Close Window;
But now I get the error message: "Cannot subscript Display Box in access or evaluation of 'rpt[ /*###*/"Neural",Outline Box(1),"Validation","Type",Table Box(1)]' , rpt[/*###*/"Neural", Outline Box( 1 ), "Validation", "Type", Table Box( 1 )]". I do not understand why I get this message, because the first script runs well.
Do you have a solution for this problem and can you explain why I have this problem, in order to understand JSL a bit better. Thanks!
Re: JSL - Repeats within a platform functionThanks, Jarmo, that was where I am looking for. Simple line, but hard to figure out for someone new to JSL!
Re: JSL - Repeats within a platform functionThe code isn't finding correct references, it could be that changing rpt = Current Window(); to rpt = Current Report() is enough, but I would strongly suggest using the reference you (can) have (in my example obj)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Boston Housing.jmp");
obj = Neural(
Y(:mvalue),
X(:crim, :indus, :chas, :nox, :rooms, :age, :distance, :radial),
Set Random Seed(2),
<< Fit(NTanH(4)),
<< Fit(NTanH(4)),
<< Fit(NTanH(4))
);
For(i = 1, i <= 2, i++,
obj << Fit(NTanH(4));
);
Report(obj)[Outline Box("Neural")][Outline Box("Training")][Table Box(1)] << Make Combined Data Table;