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...
chiastic-security
20.5k4 gold badges43 silver badges70 bronze badges
-
1possible duplicate of From Arraylist to Arraychristopher– christopher2014年09月19日 07:58:10 +00:00Commented Sep 19, 2014 at 7:58
-
Unrelated to the question, but watch your raw types.Mena– Mena2014年09月19日 08:13:10 +00:00Commented Sep 19, 2014 at 8:13
1 Answer 1
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);
chiastic-security
20.5k4 gold badges43 silver badges70 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-java