org.mymedialite.io
Class Model

java.lang.Object
  extended by org.mymedialite.io.Model

public class Model
extends java.lang.Object

Class containing static routines for reading and writing recommender models.


Method Summary
static java.io.BufferedReader getReader(java.lang.String filename, java.lang.Class<?> recommenderType)
          Get a reader object to read in model parameters of a recommender
static java.io.PrintWriter getWriter(java.lang.String filename, java.lang.Class<?> recommenderType, java.lang.String version)
          Get a writer object to save the model parameters of a recommender engine.
static void load(IRecommender recommender, java.lang.String filename)
          Load the model parameters of a recommender from a file.
static IRecommender load(java.lang.String filename)
          Load a recommender from a file, including object creation.
static void save(IRecommender recommender, java.lang.String filename)
          Save the model parameters of a recommender to a file.
static void save(IRecommender recommender, java.lang.String filename, int iteration)
          Save the model parameters of a recommender (in a given iteration of the training) to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

save

public static void save(IRecommender recommender,
                        java.lang.String filename)
                 throws java.io.IOException
Save the model parameters of a recommender to a file. Does not save if filename is an empty string.

Parameters:
recommender - the recommender to store
filename - the filename (may include relative paths)
Throws:
java.io.IOException

save

public static void save(IRecommender recommender,
                        java.lang.String filename,
                        int iteration)
                 throws java.io.IOException
Save the model parameters of a recommender (in a given iteration of the training) to a file. Does not save if filename is an empty string.

Parameters:
recommender - the to save
filename - the filename template
iteration - the iteration (will be appended to the filename)
Throws:
java.io.IOException

load

public static void load(IRecommender recommender,
                        java.lang.String filename)
                 throws java.io.IOException
Load the model parameters of a recommender from a file.

Parameters:
recommender - the to load
filename - the filename template
Throws:
java.io.IOException

load

public static IRecommender load(java.lang.String filename)
                         throws java.io.IOException
Load a recommender from a file, including object creation.

Parameters:
filename - the name of the model file
Returns:
the recommender loaded from the file
Throws:
java.io.IOException

getReader

public static java.io.BufferedReader getReader(java.lang.String filename,
                                               java.lang.Class<?> recommenderType)
                                        throws java.io.IOException
Get a reader object to read in model parameters of a recommender

Parameters:
filename - the filename of the model file
recommenderType - the expected recommender type
Returns:
a BufferedReader
Throws:
java.io.IOException

getWriter

public static java.io.PrintWriter getWriter(java.lang.String filename,
                                            java.lang.Class<?> recommenderType,
                                            java.lang.String version)
                                     throws java.io.IOException
Get a writer object to save the model parameters of a recommender engine.

Parameters:
filename - the filename of the model file
recommenderType - the engine type
version - the version string (for backwards compatibility)
Returns:
a PrintWriter
Throws:
java.io.IOException