se.lth.cs.nlp.nlputils.ml
Class NumericEncoding

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.ml.NumericEncoding
All Implemented Interfaces:
Serializable

public class NumericEncoding
extends Object
implements Serializable

Mapping from symbolic feature values to numeric values.

Author:
Richard Johansson (richard@cs.lth.se)
See Also:
Serialized Form

Constructor Summary
NumericEncoding(int n_features, HashMap<String,Integer>[] maps, HashMap<String,Integer> outValueNumbers, int[] types, int[] indices)
           
 
Method Summary
static NumericEncoding createEncoding(String inFile, HashMap<String,Integer> predefined)
          Creates a NumericEncoding from a training file.
 Object decodeTarget(int i)
          Decodes a target value.
 int[] encode(FeatureList features)
          Encodes a feature list.
 int[] encodeStrings(String[] ss)
          Encodes a list of symbolic strings.
 int encodeTarget(Object t)
          Encodes a target value.
 int[] encodeTargets(Collection classes)
          Encodes a collection of target values.
 int getNFeatures()
          Returns the number of features.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumericEncoding

public NumericEncoding(int n_features,
                       HashMap<String,Integer>[] maps,
                       HashMap<String,Integer> outValueNumbers,
                       int[] types,
                       int[] indices)
Method Detail

encode

public int[] encode(FeatureList features)
Encodes a feature list.

Parameters:
features - the feature list.
Returns:
the encoded feature list.

encodeStrings

public int[] encodeStrings(String[] ss)
Encodes a list of symbolic strings.

Parameters:
ss - the features.
Returns:
the encoded features.

encodeTarget

public int encodeTarget(Object t)
Encodes a target value.

Parameters:
t - the target value.
Returns:
the encoded target value.

encodeTargets

public int[] encodeTargets(Collection classes)
Encodes a collection of target values.

Parameters:
classes - the target values.
Returns:
the encoded target values.

decodeTarget

public Object decodeTarget(int i)
Decodes a target value.

Parameters:
i - the numerical target value.
Returns:
the decoded target value.

createEncoding

public static NumericEncoding createEncoding(String inFile,
                                             HashMap<String,Integer> predefined)
Creates a NumericEncoding from a training file.

Parameters:
inFile - the file to process.
predefined - a mapping of predefined target values. May be null.
Returns:
the created NumericEncoding.

getNFeatures

public int getNFeatures()
Returns the number of features.

Returns:
the number of features.