I have to import different tables (here the Customer table) with the help of Hibernate and transform them into a readable format for the Weka API. Currently it's possible to get get database result with
List<Object[]> myResult = SessionUtils.getSessionFactory().getCurrentSession().createQuery(
"from Customer")
.list();
There I get an array list with Objects of the type "Customer".
In another class it's possible to read an arff file with my WEKA Code and analyse the data the way I want
Instances ins = new Instances(new BufferedReader(new FileReader(".../Customer.arff")));
Is there an easy way to transform myResult into the format I need it in "Instances ins"? Please ask if you need more information. Thanks for reading!
You can create Instance-Objects like any other Java Object. There's an example for that in the javadoc of the Instance - Class:
// Create empty instance with three attribute values
Instance inst = new Instance(3);
// Set instance's values for the attributes "length", "weight", and "position"
inst.setValue(length, 5.3);
inst.setValue(weight, 300);
inst.setValue(position, "first");
To convert your Collection to an Intances-Object: Iterate through your myResult
-List, create a new Instance
-Object for every Customer
and add it to your Instances
-Object via the add-method.