Can set value to Dataset from array, list, etc?

The engine.
Post Reply
musicpxg
Posts: 19
Joined: Sat Feb 16, 2013 6:24 am

Can set value to Dataset from array, list, etc?

Post by musicpxg »

Hi,

I find there seems only a way to read data to Dataset, i.e. readFile(). Is it possible to set values to Dataset from Arraylist, etc? I do not like to save the arraylist to hard disk as .text and then readed by Dataset.readFile();

Thank you!
Best wishes,
Yang
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Can set value to Dataset from array, list, etc?

Post by shooltz[BayesFusion] »

There's no direct support for Java collections, but you can build your dataset with the following methods defined in the DataSet class: addIntVariable, addFloatVariable, addEmptyRecord, setInt, setFloat, setMissing.

Define the structure of your dataset with addXXXVariable calls. To add rows, call addEmptyRecord followed by setInt or setFloat.
musicpxg
Posts: 19
Joined: Sat Feb 16, 2013 6:24 am

Re: Can set value to Dataset from array, list, etc?

Post by musicpxg »

shooltz wrote:There's no direct support for Java collections, but you can build your dataset with the following methods defined in the DataSet class: addIntVariable, addFloatVariable, addEmptyRecord, setInt, setFloat, setMissing.

Define the structure of your dataset with addXXXVariable calls. To add rows, call addEmptyRecord followed by setInt or setFloat.
Dear Shooltz,

Thank you very much for your fast reply!
I find there is a wrapper for Java to generate .jar. Can I add a new function in the wrapper and then regenerate the smile.jar?

Thank you!
Best wishes,
Yang
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Can set value to Dataset from array, list, etc?

Post by shooltz[BayesFusion] »

musicpxg wrote:I find there is a wrapper for Java to generate .jar. Can I add a new function in the wrapper and then regenerate the smile.jar?
You can do that, but you'd loose your changes when new version of jSMILE is posted. Why don't you create a class derived from DataSet or an utility class or set of classes providing the functionality on top of the DataSet?
musicpxg
Posts: 19
Joined: Sat Feb 16, 2013 6:24 am

Re: Can set value to Dataset from array, list, etc?

Post by musicpxg »

shooltz wrote:
musicpxg wrote:I find there is a wrapper for Java to generate .jar. Can I add a new function in the wrapper and then regenerate the smile.jar?
You can do that, but you'd loose your changes when new version of jSMILE is posted. Why don't you create a class derived from DataSet or an utility class or set of classes providing the functionality on top of the DataSet?
Hi Shooltz,

Yes, you are right! I will have a try.

Thank you!
Regards,
Yang
Post Reply