^no. not like that. 2D. I want to shuffle one D without changing at all the other D. plus thats about android. get that outta here.
I have a 2D array which is made up of elements:
Example:
Document 1 = ["I", "am", "awesome"]
Document 2 = ["I", "am", "great", "great"]
Dictionary is:
["I", "am", "awesome", "great"]
So the 2D array would look like:
[1, 1, 1, 0]
[1, 1, 0, 2]
What I want to do is shuffle around the location of the documents, so where we once had:
Document 1 = [1, 1, 1, 0]
Document 2 = [1, 1, 0, 2]
We now might have:
Document 2 = [1, 1, 0, 2]
Document 1 = [1, 1, 1, 0]
Or we might not. It should be shuffled randomly.
Not like this.
How to implement that?
My data structure looks like this:
int z = 0;
for ( Cell< int[] , String , Integer > cell: train_freq_count_against_globo_dict.cellSet() )
{
int[] container_of_feature_vector = cell.getRowKey();
// 'q' CAN'T be shuffled, 'z' MUST be shuffled.
for (int q = 0; q < globo_dict_size; q++)
{
feature_matrix__train[z][q] = container_of_feature_vector[q];
}
// use 1 and -1 not 0 and 1
outputs__train[z] = String.valueOf( cell.getColumnKey() ).equals(LABEL) ? 1.0 : -1.0;
z++;
}
The point of this is to implement stochastic gradient descent.
UPDATE:
static double[][] shuffleArray(double[][] input_array)
{
Random rnd = new Random();
for (int i = input_array.length - 1; i > 0; i--)
{
int index = rnd.nextInt(i + 1);
// Simple swap
double[] container = input_array[index];
input_array[index] = input_array[i];
input_array[i] = container;
}
return input_array;
}