1

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...

2
  • 1
    possible duplicate of From Arraylist to Array Commented Sep 19, 2014 at 7:58
  • Unrelated to the question, but watch your raw types. Commented Sep 19, 2014 at 8:13

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.