I have a matrix that has 223 rows and 11 columns.I want to split this matrix into packets(each packet will have 10 rows from the matrix) so at the end I should have 22 packets (I will dismiss the last 3 rows). After I have the packets I want to perform a cross validation algorithm on my packets and I was thinking to put all my packets in a HaskMap
that will have as key one packet and value the rest of them. So it would look like this
key = pack1, value = pack2,...,pack22
key = pack2, values = pack1, pack3,...pack22
.............................................
key = pack22, values = pack1,...,pack21
Before creating the map I have problems in spliting the matrix into packets Here is my code:
int k = 0;
ArrayList<ArrayList<double[]>> allPacks = new ArrayList<ArrayList<double[]>>();
ArrayList<double[]> batch = new ArrayList<double[]>();
for (int i=0;i<matrix.length;i+=10) {
System.out.println(i);
batch.add(matrix[i]);
k++;
if (k % 10 == 0) {
allPacks.add(batch);
batch.clear();
}
}
If I print the size of allPacks
is 2. I don't get it.Any help?