CrossValidation operation converts input PSG Matrix in N pairs of complementary sub-matrices. This operation is used for N-fold cross-validation in statistical procedures, such as linear regression. E.g., in linear regression, the first sub-matrix from a pair of sum-matrices is used for fitting and the second sub-matrix is used for validating.
Syntax
CrossValidation(N, matrix1) |
Parameters
matrix1 |
name of input Matrix (to be split in pairs of complementary sub-matrices); |
N |
number of pairs of complementary sub-matrices with approximately equal number of rows. |
Description
Input:
CrossValidation(N, matrix1)
Output presented with matrix operations Cutout and Takein
{ Cutout(1, N,<matrix1>), Takein(1, N,<matrix1>), 1}
{ Cutout(2, N,<matrix1>), Takein(2, N,<matrix1>), 2 }
………………………………………………..
{ Cutout(N, N,<matrix1>), Takein(N, N,<matrix1>), N }.
CrossValidation operation splits all rows of the original matrix matrix1 in N approximately equal parts. {Cutout(1,N,matrix1), Takein(1,N,matrix1),1} is the first pair of complementary sub-matrices. Cutout(1,N,matrix1) is the first sub-matrix, Takein(1, N,matrix1) and Takein(1, N,matrix1)are the second sub-matrix. Similar, other pairs of sub-matrices are generated.
CrossValidation is used in cycle for N-fold cross-validation in statistics (see section "General (Text) Format of PSG", subsection Cycle in Problem Statement).
Example
for {matrix_cut, matrix_take,NN}=CrossValidation(3, matrix_fact19)
problem: problem_SimpleCrossValidation_NN, type = minimize
objective: objective_cvar1
cvar_risk_1(0.75,matrix_cut)
value:
cvar_risk_2(0.75,matrix_take)
box_of_variables: lowerbounds = -10, upperbounds = 10
solver: van, precision = 6
end for
Initial input matrix:
matrix_fact19:
x1 |
x2 |
scenario_benchmark |
-2 |
2 |
1 |
0 |
10 |
2 |
1 |
-1 |
15 |
5 |
15 |
11 |
7 |
-7 |
3 |
11 |
12 |
1 |
2 |
21 |
1 |
12 |
-2 |
11 |
19 |
9 |
4 |
15 |
5 |
15 |
17 |
7 |
3 |
9 |
-19 |
9 |
-12 |
5 |
7 |
10 |
1 |
2 |
13 |
3 |
8 |
25 |
5 |
12 |
-7 |
7 |
3 |
31 |
-3 |
1 |
3 |
3 |
13 |
Variable NN, takes values 1, 2, and 3, in the cycle. Three optimization problems are solved. Problem names end with cycle variable, NN. Each problem generates three output files: problem statement, solution, and optimal point; e.g., here are files for the second problem:
- | problem_simplecrossvalidation_2.txt; |
- | solution_ problem_simplecrossvalidation_2.txt; |
- | point_ problem_simplecrossvalidation_2.txt. |
Here is the problem statement for the second problem:
problem: problem_simplecrossvalidation_2, type = minimize
objective: objective_cvar1
cvar_risk_1(0.75,cutout(2,3,matrix_fact19))
value:
cvar_risk_2(0.75, takein(2,3,matrix_fact19))
box_of_variables: lowerbounds = -10, upperbounds = 10
solver: van, precision = 6
Initial matrix, matrix_fact19, is split in three parts:
part 1
-2 |
2 |
1 |
0 |
10 |
2 |
1 |
-1 |
15 |
5 |
15 |
11 |
7 |
-7 |
3 |
11 |
12 |
1 |
2 |
21 |
1 |
part 2
12 |
-2 |
11 |
19 |
9 |
4 |
15 |
5 |
15 |
17 |
7 |
3 |
9 |
-19 |
9 |
-12 |
5 |
7 |
part 3
10 |
1 |
2 |
13 |
3 |
8 |
25 |
5 |
12 |
-7 |
7 |
3 |
31 |
-3 |
1 |
3 |
3 |
13 |
For instance, operation cutout(2,3,matrix_fact19)is the matrix containing parts 1 and 3:
-2 |
2 |
1 |
0 |
10 |
2 |
1 |
-1 |
15 |
5 |
15 |
11 |
7 |
-7 |
3 |
11 |
12 |
1 |
2 |
21 |
1 |
10 |
1 |
2 |
13 |
3 |
8 |
25 |
5 |
12 |
-7 |
7 |
3 |
31 |
-3 |
1 |
3 |
3 |
13 |
For instance, operation takein(2,3,matrix_fact19) is the part 2:
12 |
-2 |
11 |
19 |
9 |
4 |
15 |
5 |
15 |
17 |
7 |
3 |
9 |
-19 |
9 |
-12 |
5 |
7 |
Case Studies with CrossValidation Operation
See also
Block Operation for Matrix, Cutout Operation for Matrix, Takein Operation for Matrix.