__init__(self,
func,
length,
labels)
(Constructor)
| source code
|
Construct a new feature encoding based on the given function.
- Parameters:
func ((callable)) - A function that takes two arguments, a featureset and a label,
and returns the sparse joint feature vector that encodes them:
>>> func(featureset, label) -> feature_vector
This sparse joint feature vector (feature_vector)
is a list of (index,value) tuples.
length (int) - The size of the fixed-length joint-feature vectors that are
generated by this encoding.
labels (list) - A list of the "known labels" for this encoding -- i.e.,
all labels l such that
self.encode(fs,l) can be a nonzero joint-feature
vector for some value of fs.
- Overrides:
object.__init__
|