Package nltk :: Package classify :: Module maxent :: Class GISEncoding
[hide private]
[frames] | no frames]

Class GISEncoding

source code

             object --+        
                      |        
 MaxentFeatureEncodingI --+    
                          |    
BinaryMaxentFeatureEncoding --+
                              |
                             GISEncoding

A binary feature encoding which adds one new joint-feature to the joint-features defined by BinaryMaxentFeatureEncoding: a correction feature, whose value is chosen to ensure that the sparse vector always sums to a constant non-negative number. This new feature is used to ensure two preconditions for the GIS training algorithm:

Instance Methods [hide private]
 
__init__(self, labels, mapping, unseen_features=False, alwayson_features=False, C=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
list of (int, number)
encode(self, featureset, label)
Given a (featureset, label) pair, return the corresponding vector of joint-feature values.
source code
int
length(self)
Returns: The size of the fixed-length joint-feature vectors that are generated by this encoding.
source code
str
describe(self, f_id)
Returns: A string describing the value of the joint-feature whose index in the generated feature vectors is fid.
source code

Inherited from BinaryMaxentFeatureEncoding: labels

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Methods [hide private]

Inherited from BinaryMaxentFeatureEncoding: train

Instance Variables [hide private]
  _C
The non-negative constant that all encoded feature vectors will sum to.
Properties [hide private]
  C
The non-negative constant that all encoded feature vectors will sum to.

Inherited from object: __class__

Method Details [hide private]

__init__(self, labels, mapping, unseen_features=False, alwayson_features=False, C=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • C - The correction constant. The value of the correction feature is based on this value. In particular, its value is C - sum([v for (f,v) in encoding]).
Overrides: BinaryMaxentFeatureEncoding.__init__

encode(self, featureset, label)

source code 

Given a (featureset, label) pair, return the corresponding vector of joint-feature values. This vector is represented as a list of (index, value) tuples, specifying the value of each non-zero joint-feature.

Returns: list of (int, number)
Overrides: BinaryMaxentFeatureEncoding.encode

length(self)

source code 
Returns: int
The size of the fixed-length joint-feature vectors that are generated by this encoding.
Overrides: BinaryMaxentFeatureEncoding.length

describe(self, f_id)

source code 
Returns: str
A string describing the value of the joint-feature whose index in the generated feature vectors is fid.
Overrides: BinaryMaxentFeatureEncoding.describe

Property Details [hide private]

C

The non-negative constant that all encoded feature vectors will sum to.

Get Method:
unreachable(self)