Reputation: 13
i created a program for read a WEKA file (.arff) and do "Calinski-Harabasz"... The problem is, i created a Arraylist(myA) of ArrayList(values) from the data source of weka:
ArrayList<ArrayList<Double>> myA = new ArrayList();
for(int i=0;i< data.numAttributes();i++)
{
ArrayList<Double> este = new ArrayList();
double[] values = data.attributeToDoubleArray(i);
for (int j = 0; j < values.length; j++)
este.add(values[j]);
myA.add(este);
}
now I have some like this:
ArrayList (3-list) of ArrayList (9-values)
2,3,2,5,2,1,4,1,3
2,4,3,5,2,1,4,5,2
0,0,0,1,1,1,1,2,2
Can I convert this to array?? something like array of array???
double[][] myArray = {lis1,lis2,lis3}
double[] list1 = {2,3,2,5,2,1,4,1,3}
double[] list2 = {2,4,3,5,2,1,4,5,2}
double[] list3 = {0,0,0,1,1,1,1,2,2}
My method "Calinski-Harabasz" only works fine with arrays...
Upvotes: 1
Views: 154
Reputation: 2950
If you want an array, why do you construct an ArrayList
, especially since your data
object already gives you arrays apparently?
double[][] a = new double[data.numAttributes()][];
for (int i=0; i < data.numAttributes(); i++)
a[i] = data.attributeToDoubleArray(i);
Upvotes: 2