org.apache.mahout.classifier.naivebayes
Class NaiveBayesModel

java.lang.Object
  extended by org.apache.mahout.classifier.naivebayes.NaiveBayesModel
All Implemented Interfaces:
com.google.gson.JsonDeserializer<NaiveBayesModel>, com.google.gson.JsonSerializer<NaiveBayesModel>, java.lang.Cloneable

public class NaiveBayesModel
extends java.lang.Object
implements com.google.gson.JsonDeserializer<NaiveBayesModel>, com.google.gson.JsonSerializer<NaiveBayesModel>, java.lang.Cloneable

NaiveBayesModel holds the weight Matrix, the feature and label sums and the weight normalizer vectors.


Constructor Summary
NaiveBayesModel(Matrix matrix, Vector featureSum, Vector labelSum, Vector thetaNormalizer, float alphaI)
           
 
Method Summary
 NaiveBayesModel deserialize(com.google.gson.JsonElement json, java.lang.reflect.Type type, com.google.gson.JsonDeserializationContext context)
           
static NaiveBayesModel fromJson(java.lang.String json)
          Decode this NaiveBayesModel from a JSON string
static NaiveBayesModel fromMRTrainerOutput(org.apache.hadoop.fs.Path output, org.apache.hadoop.conf.Configuration conf)
           
 float getAlphaI()
           
 Vector getFeatureSum()
           
 Vector getLabelSum()
           
static java.lang.String getModelName()
           
 int getNumLabels()
           
 Vector getPerlabelThetaNormalizer()
           
 double getTotalSum()
           
 double getVocabCount()
           
 Matrix getWeightMatrix()
           
 com.google.gson.JsonElement serialize(NaiveBayesModel model, java.lang.reflect.Type type, com.google.gson.JsonSerializationContext context)
           
 void setAlphaI(float alphaI)
           
 void setFeatureSum(Vector featureSum)
           
 void setPerlabelThetaNormalizer(Vector perlabelThetaNormalizer)
           
 void setTotalSum(double totalSum)
           
 void setVocabCount(double vocabCount)
           
 void setWeightMatrix(Matrix weightMatrix)
           
 java.lang.String toJson()
          Encode this NaiveBayesModel as a JSON string
static void validate(NaiveBayesModel model)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NaiveBayesModel

public NaiveBayesModel(Matrix matrix,
                       Vector featureSum,
                       Vector labelSum,
                       Vector thetaNormalizer,
                       float alphaI)
Method Detail

setPerlabelThetaNormalizer

public void setPerlabelThetaNormalizer(Vector perlabelThetaNormalizer)

setFeatureSum

public void setFeatureSum(Vector featureSum)

setWeightMatrix

public void setWeightMatrix(Matrix weightMatrix)

setAlphaI

public void setAlphaI(float alphaI)

setVocabCount

public void setVocabCount(double vocabCount)

setTotalSum

public void setTotalSum(double totalSum)

getLabelSum

public Vector getLabelSum()

getPerlabelThetaNormalizer

public Vector getPerlabelThetaNormalizer()

getFeatureSum

public Vector getFeatureSum()

getWeightMatrix

public Matrix getWeightMatrix()

getAlphaI

public float getAlphaI()

getVocabCount

public double getVocabCount()

getTotalSum

public double getTotalSum()

getNumLabels

public int getNumLabels()

getModelName

public static java.lang.String getModelName()

fromMRTrainerOutput

public static NaiveBayesModel fromMRTrainerOutput(org.apache.hadoop.fs.Path output,
                                                  org.apache.hadoop.conf.Configuration conf)
                                           throws java.io.IOException
Throws:
java.io.IOException

toJson

public java.lang.String toJson()
Encode this NaiveBayesModel as a JSON string

Returns:
String containing the JSON of this model

fromJson

public static NaiveBayesModel fromJson(java.lang.String json)
Decode this NaiveBayesModel from a JSON string

Parameters:
json - String containing JSON representation of this model
Returns:
Initialized model

serialize

public com.google.gson.JsonElement serialize(NaiveBayesModel model,
                                             java.lang.reflect.Type type,
                                             com.google.gson.JsonSerializationContext context)
Specified by:
serialize in interface com.google.gson.JsonSerializer<NaiveBayesModel>

deserialize

public NaiveBayesModel deserialize(com.google.gson.JsonElement json,
                                   java.lang.reflect.Type type,
                                   com.google.gson.JsonDeserializationContext context)
                            throws com.google.gson.JsonParseException
Specified by:
deserialize in interface com.google.gson.JsonDeserializer<NaiveBayesModel>
Throws:
com.google.gson.JsonParseException

validate

public static void validate(NaiveBayesModel model)


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.