I currently have a script that generates a random column of X's, calculates a column of Y's based on the X's, makes a predicted Y column, a residual column (Predicted Y - Y), and a predicted Y column. From there, my code selects the rows with residuals lower than 3 and deletes them.
I want to then add more rows of augmented data points, and do the cycle again with the intent of making the residuals lower. Below is my code:
// 1. Creates X1 column, and corresponding Y1 and Ystat columns
Close All( Data Tables, NoSave );
dt = New Table( "SampleRun 3",
Add Rows( 100 ),
New Script(
"Ystat vs. X1",
Graph Builder(
Variables( X( :X1 ), Y( :Ystat ) ),
Elements( Points( X, Y, Legend( 5 ) ) )
)
),
New Column( "X1",
Formula( Random Integer( 50 ) )
),
New Column( "Y1",
Formula( If( :X1 < 25, 2 * :X1, 25 <= :X1 <= 30, 3 * :X1, 4 * :X1 ) )
),
New Column( "Ystat",
Formula( :Y1 )
)
);
// 2. Creates predicted Ystat column, saves formulas into same data table (first iteration)
PredictedYstat = dt << Neural(
Y( :Ystat ),
X( :X1 ),
Informative Missing( 0 ),
Validation Method( "Holdback", 0.3333 ),
Fit( NTanH( 3 ) )
);
PredictedYStat << Save Profile Formulas;
// 3. Adds residual column
dt << New Column( "Residual 1", Formula( Abs( :Predicted Ystat - :Ystat ) ) );
Column( dt, "X1" ) << Suppress Formula Eval();
Column( dt, "Y1" ) << Suppress Formula Eval();
Column( dt, "Ystat" ) << Suppress Formula Eval();
dt << Select where( :Residual 1 <= 3 );
dt << delete rows;
// 4. Creates and predicts residual column
PredictedResidual = dt2 << Neural(
Y( :Residual 1 ),
X( :X1 ),
Informative Missing( 0 ),
Validation Method( "Holdback", 0.3333 ),
Fit( NTanH( 3 ) )
);
PredictedResidual << Save Profile Formulas;
// 5. Adds new data points, cycle starts over from 2 (lets user choose how many)
// Iteration 2
DOE( Augment Design, X( :X1 ), Y( :Ystat ), {Make Design, Make Table} );
dt << add rows();
But the last chunk of code (where it is supposed to add rows) doesn't do anything. Any suggestions?
Thanks,
Kyle