The Data Mining Forum                             open-source data mining software data science journal data mining conferences machine learning in software engineering MLISE 2021 utility mining workshop at ICDM 2021
This forum is about data mining, data science and big data: algorithms, source code, datasets, implementations, optimizations, etc. You are welcome to post call for papers, data mining job ads, link to source code of data mining algorithms or anything else related to data mining. The forum is hosted by P. Fournier-Viger. No registration is required to use this forum!.  
saving to file and loading a pretrained sequence prediction model with CPT / CPT+ / AKOM / PPM / TDAG etc in SPMF
Date: February 12, 2021 12:05AM

Hi all,

For all of those using CPT, CPT+, AKOM, PPM, DG and other sequence prediction models of SPMF, in the new version 2.44, I have added some example in the code about how to save a pretrained model to a file and then load it again. It is very simple. For example, in, the code for saving a trained CPT model and loading it from file to do a prediction looks like this:

// ******* IF we want to save the trained model to a file ******* ///
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream("model.ser" ) ) ;
// ****** Then, we can also load the trained model from the file ****** ///
ObjectInputStream stream2 = new ObjectInputStream(new FileInputStream("model.ser" ) ) ;
Predictor predictionModel2 = (Predictor) stream2.readObject();

// and then make a prediction
Sequence thePrediction2 = predictionModel2.Predict(sequence);
System.out.println("For the sequence <(1),(4)>, the prediction for the next symbol is: +" + thePrediction2);

That is easy ! :-)

Edited 5 time(s). Last edit at 02/12/2021 12:08AM by webmasterphilfv.

Options: ReplyQuote

This forum is powered by Phorum and provided by P. Fournier-Viger (© 2012).
Terms of use.