amidst / toolbox

A Java Toolbox for Scalable Probabilistic Machine Learning
http://www.amidsttoolbox.com
Apache License 2.0
119 stars 35 forks source link

Save an load a DBN in hugin format #54

Open rcabanasdepaz opened 7 years ago

rcabanasdepaz commented 7 years ago

It seems that the code for saving a DBN in hugin format is not correct. In the following code, I save a DBN and then I try to load it.

    //Load the data stream
    String path = "datasets/simulated/";
    String filename = path+"BCC_month0.arff";
    DataStream<DynamicDataInstance> data =
            DynamicDataStreamLoader.loadFromFile(filename);

    //Learn the dynamic model
    DynamicModel model =
            new HiddenMarkovModel(data.getAttributes());
    model.updateModel(data);

    // Print the BN and save it
    DynamicBayesianNetwork dbn = model.getModel();
    System.out.println(dbn);
    DynamicBayesianNetworkWriter
            .save(dbn, "networks/simulated/BCCDBN.dbn");

    DynamicBayesianNetworkWriterToHugin
            .save(dbn, "networks/simulated/BCCDBN.oobn");

    //Load the DBN
    DBNLoaderFromHugin.loadFromFile("networks/simulated/BCCDBN.oobn");

I get the following exception:

Parse error in line 1: expected `class' keyword Exception in thread "main" COM.hugin.HAPI.ExceptionParse: An error occurred during parsing. If a parse error handling function was specified, it will have been called with a description of the error and its location in the source. at COM.hugin.HAPI.ExceptionHugin.throwException(ExceptionHugin.java:107) at COM.hugin.HAPI.ClassCollection.parseClasses(ClassCollection.java:107) at eu.amidst.huginlink.io.DBNLoaderFromHugin.loadFromFile(DBNLoaderFromHugin.java:39) at eu.amidst.tutorial.usingAmidst.more_examples.DynamicModelLearning.main(DynamicModelLearning.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)