Dynamic sample size in for-loops
Help Request
Use case
I want to use a for-loop to create multiple predictions and also generate different samples ranging from 8 to 16384 in steps of powers of 2
Minimal Working Example
example 1:
import "definitions" from de.evoal.core.math;
import "definitions" from de.evoal.generator.generator;
import "data" from realdata;
module ackley {
/**
* Introduce a simple pipeline that generates some test data using
* the ackley function.
*/
pipeline 'main-pipeline' [
/**
* First, we generate some normally distributed data.
*/
step {
component 'normal-distribution' {
'μ' := 0.0;
'σ' := 1;
}
writes [data 'x:0', data 'x:1', data 'x:2', data 'x:3', data 'x:4'];
}
step {
component 'ackley' {
}
reads [data 'x:0'];
writes [data 'y:0'];
}
step {
component 'rastrigin' {
}
reads [data 'x:1'];
writes [data 'y:1'];
}
step {
component 'rosenbrock' {
}
reads [data 'x:2', data 'x:3'];
writes [data 'y:2'];
}
step {
component 'weighted-sphere' {
}
reads [data 'x:4'];
writes [data 'y:3'];
}
step {
component 'noise-data' {
/* define distribution per data */
distributions := [
// noise for y:0
'normal-distribution' {
'μ' := 0.0;
'σ' := 1.0;
},
// noise for y:1
'normal-distribution' {
'μ' := 0.0;
'σ' := 1.0;
},
// noise for y:2
'normal-distribution' {
'μ' := 0.0;
'σ' := 1.0;
},
// noise for y:3
'normal-distribution' {
'μ' := 0.0;
'σ' := 1.0;
}
];
}
reads [data 'y:0', data 'y:1', data 'y:2', data 'y:3'];
writes [data 'y:0', data 'y:1', data 'y:2', data 'y:3'];
}
]
for _counter in [3 to 14] loop // i want to do this part
_samples := 2^(_counter)
write "noised/samples-${_samples}/sigma-1/all.json" with _samples samples from executing [ pipeline 'main-pipeline'];
end
}
example 2:
import "definitions" from de.evoal.surrogate.ml;
import "definitions" from de.evoal.surrogate.smile.ml;
import "data" from surrogate;
module all_training {
prediction svr_ackley
maps 'x:0'
to 'y:0'
using
layer transfer
with function 'gaussian-svr'
mapping 'x:0'
to 'y:0'
with parameters
'ε' := 1.0; // default 1.4
'σ' := 2.0; // default 1.0
'soft-margin' := 0.3; // default 0.15
tolerance := 0.05; // default 0.1
prediction svr_rastrigin
maps 'x:1'
to 'y:1'
using
layer transfer
with function 'gaussian-svr'
mapping 'x:1'
to 'y:1'
with parameters
'ε' := 1.0; // default 0.5
'σ' := 2.0; // default 1.0
'soft-margin' := 0.3; // default 0.15
tolerance := 0.05; // default 0.1
prediction svr_rosenbrock
maps 'x:2', 'x:3'
to 'y:2'
using
layer transfer
with function 'gaussian-svr'
mapping 'x:2', 'x:3'
to 'y:2'
with parameters
'ε' := 1.0; // default 0.5
'σ' := 2.0; // default 1.0
'soft-margin' := 0.3; // default 0.15
tolerance := 0.05; // default 0.1
prediction svr_weightedsphere
maps 'x:4'
to 'y:3'
using
layer transfer
with function 'gaussian-svr'
mapping 'x:4'
to 'y:3'
with parameters
'ε' := 1.0; // default 0.5
'σ' := 2.0; // default 1.0
'soft-margin' := 0.3; // default 0.15
tolerance := 0.05; // default 0.1
for _counter in [3 to 14] loop // i want to do this part here
_samples := 2^(_counter)
predict svr_ackley from "../generated/pure/samples-${_samples}/sigma-1/all.json"
and measure
'cross-validation'(10);
'R²'();
'rmse'();
end
and store to "../generated/pure/samples-${_samples}/sigma-1/gaussian_ackley.pson"
predict svr_rastrigin from "../generated/pure/samples-${_samples}/sigma-1/all.json"
and measure
'cross-validation'(10);
'R²'();
'rmse'();
end
and store to "../generated/pure/samples-${_samples}/sigma-1/gaussian_rastrigin.pson"
predict svr_rosenbrock from "../generated/pure/samples-${_samples}/sigma-1/all.json"
and measure
'cross-validation'(10);
'R²'();
'rmse'();
end
and store to "../generated/pure/samples-${_samples}/sigma-1/gaussian_rosenbrock.pson"
predict svr_weightedsphere from "../generated/pure/samples-${_samples}/sigma-1/all.json"
and measure
'cross-validation'(10);
'R²'();
'rmse'();
end
and store to "../generated/pure/samples-${_samples}/sigma-1/gaussian_weightedsphere.pson"
end
}
What is your question or problem
How can i define variables inside the for-loop correctly and use them to set the sample size dynamically?