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

chiastic-security
20.5k4 gold badges43 silver badges70 bronze badges
asked Sep 19, 2014 at 7:55
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);
chiastic-security
20.5k4 gold badges43 silver badges70 bronze badges
answered Sep 19, 2014 at 8:06
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.