public double updateModel(DataStream<DataInstance> dataStream){ if (!initialized) initLearning(); return this.learningAlgorithm.updateModel(dataStream); }
public double updateModel(DataOnMemory<DataInstance> datBatch){ if (!initialized) initLearning(); return learningAlgorithm.updateModel(datBatch); }
@Override public double updateModel(DataStream<DataInstance> dataStream){ if (!initialized) initLearning(); return BatchSpliteratorByID. streamOverDocuments(dataStream, this.windowSize).sequential().mapToDouble(batch -> { System.out.println("Batch: "+ batch.getNumberOfDataInstances()); return this.learningAlgorithm.updateModel(batch); }).sum(); }
public static void main(String[] args) throws Exception { //We can open the data stream using the static class DataStreamLoader DataStream<DataInstance> data = DataStreamLoader.open("datasets/simulated/WasteIncineratorSample.arff"); //We create a ParameterLearningAlgorithm object with the MaximumLikehood builder ParameterLearningAlgorithm parameterLearningAlgorithm = new ParallelMaximumLikelihood(); //We fix the DAG structure parameterLearningAlgorithm.setDAG(getNaiveBayesStructure(data,0)); //We should invoke this method before processing any data parameterLearningAlgorithm.initLearning(); //Then we show how we can perform parameter learnig by a sequential updating of data batches. for (DataOnMemory<DataInstance> batch : data.iterableOverBatches(100)){ parameterLearningAlgorithm.updateModel(batch); } //And we get the model BayesianNetwork bnModel = parameterLearningAlgorithm.getLearntBayesianNetwork(); //We print the model System.out.println(bnModel.toString()); }
/** * Updates the classifier with the given instance. * * @param instance the new training instance to include in the model * @exception Exception if the instance could not be incorporated in the * model. */ public void updateClassifier(Instance instance) throws Exception { DataOnMemoryListContainer<DataInstance> batch_ = new DataOnMemoryListContainer(attributes_); batch_.add(new DataInstanceFromDataRow(new DataRowWeka(instance, this.attributes_))); parameterLearningAlgorithm_.updateModel(batch_); bnModel_ = parameterLearningAlgorithm_.getLearntBayesianNetwork(); inferenceAlgorithm_.setModel(bnModel_); }
/** * Updates the classifier with the given instance. * * @param instance the new training instance to include in the model * @exception Exception if the instance could not be incorporated in the * model. */ public void updateClassifier(Instance instance) throws Exception { DataOnMemoryListContainer<DataInstance> batch_ = new DataOnMemoryListContainer(attributes_); batch_.add(new DataInstanceFromDataRow(new DataRowWeka(instance, this.attributes_))); parameterLearningAlgorithm_.updateModel(batch_); bnModel_ = parameterLearningAlgorithm_.getLearntBayesianNetwork(); inferenceAlgorithm_.setModel(bnModel_); }
/** * {@inheritDoc} */ @Override public void trainOnInstanceImpl(Instance instance) { DataInstance dataInstance = new DataInstanceFromDataRow(new DataRowWeka(instance, this.attributes_)); if(batch_.getNumberOfDataInstances() < getBatchSize_()-1) { //store batch_.add(dataInstance); }else{ //store & learn batch_.add(dataInstance); if(bnModel_==null) { //parameterLearningAlgorithm_.setParallelMode(isParallelMode_()); parameterLearningAlgorithm_.setDAG(dag); parameterLearningAlgorithm_.initLearning(); parameterLearningAlgorithm_.updateModel(batch_); }else{ parameterLearningAlgorithm_.updateModel(batch_); } bnModel_ = parameterLearningAlgorithm_.getLearntBayesianNetwork(); predictions_.setModel(bnModel_); batch_ = new DataOnMemoryListContainer(attributes_); } }
/** * {@inheritDoc} */ @Override public void trainOnInstanceImpl(Instance instance) { DataInstance dataInstance = new DataInstanceFromDataRow(new DataRowWeka(instance, this.attributes_)); if(batch_.getNumberOfDataInstances() < getBatchSize_()-1) { //store batch_.add(dataInstance); }else{ //store & learn batch_.add(dataInstance); if(bnModel_==null) { //parameterLearningAlgorithm_.setParallelMode(isParallelMode_()); parameterLearningAlgorithm_.setDAG(dag); parameterLearningAlgorithm_.initLearning(); parameterLearningAlgorithm_.updateModel(batch_); }else{ parameterLearningAlgorithm_.updateModel(batch_); } bnModel_ = parameterLearningAlgorithm_.getLearntBayesianNetwork(); predictions_.setModel(bnModel_); batch_ = new DataOnMemoryListContainer(attributes_); } }
((SVB)parameterLearningAlgorithm_).setWindowsSize(timeWindowOption.getValue()); parameterLearningAlgorithm_.initLearning(); parameterLearningAlgorithm_.updateModel(batch_); }else { parameterLearningAlgorithm_.updateModel(batch_);