Hi Yu, Serialisation of the model is definitely a great feature. The simplest way to do it is to wait for the end-of-stream event and serialise the model. To start with, please have a look at this email thread http://mail-archives.apache.org/mod_mbox/incubator-samoa-dev/201509.mbox/%3ccaggccmtqoboednu9_t+pnt0nosb-3rzbakrf5sks65wlwjr...@mail.gmail.com%3e
It's definitely on the roadmap, and if you want to take a stab at it, it would be great. Cheers, -- Gianmarco On 18 January 2016 at 05:42, Yu Gong (JIRA) <[email protected]> wrote: > > [ > https://issues.apache.org/jira/browse/SAMOA-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15104081#comment-15104081 > ] > > Yu Gong commented on SAMOA-54: > ------------------------------ > > For example, I can define an interface of Model which can be serialized, > and contains the method as predict. > > public interface Model extends Serializable { > double[] predict(Instance inst); > } > > And for HoeffdingTreeModel, I can define it as: > > public class HoeffdingTreeModel implements Model { > private Instances dataset; > private Node treeRoot; > > public HoeffdingTreeModel(Instances dataset, Node treeRoot) { > this.dataset = dataset; > this.treeRoot = treeRoot; > } > > public HoeffdingTreeModel() { > } > > @Override > public double[] predict(Instance inst) { > double[] prediction; > // inst.setDataset(dataset); > > FoundNode foundNode; > if (treeRoot != null) { > foundNode = treeRoot.filterInstanceToLeaf(inst, null, -1); > Node leafNode = foundNode.getNode(); > if (leafNode == null) { > leafNode = foundNode.getParent(); > } > prediction = leafNode.getClassVotes(inst, null); > } else { > int numClasses = dataset.numClasses(); > prediction = new double[numClasses]; > } > return prediction; > } > } > > I can create the HoeffdingTreeModel object in > org.apache.samoa.learners.classifiers.trees.ModelAggregatorProcessor, and > output the object. > > Can you give me some advice about it? Thanks a lot. > > > dump or serialize SAMOA learned model > > ------------------------------------- > > > > Key: SAMOA-54 > > URL: https://issues.apache.org/jira/browse/SAMOA-54 > > Project: SAMOA > > Issue Type: New Feature > > Components: SAMOA-API > > Reporter: Yu Gong > > > > If I can dump or serialize SAMOA learned model, I could use SAMOA model > in an external task. I think it's important. > > > > -- > This message was sent by Atlassian JIRA > (v6.3.4#6332) >
