Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load Instances via PatientService and store into XML (XRFF)
import weka.core.converters.Loader;
import weka.core.converters.Saver;
import weka.core.converters.ArffLoader;
import weka.core.converters.XrffSaver;
IPatientService ps = ... //get IPatientService
Data d = ... //get Data entity
Path pathToArff = locateFile(Data d);
Path pathToXML = ... //get it!
try(InputStream in = Files.newInputStream(pathToArff); OutputStream out = Files.newOutputStream(pathToXML) {
Loader loader = new ArffLoader();
Instances dataset = loader.getDataSet();
Saver saver = new XrffSaver();
//This won't work with Weka 3.7.3, fixed in 3.7.5. Needs update
//As a workaround use
} catch(IOException e) {
//handle it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment