Search code examples
encodingmahoutml

How to encode a boolean feature value in mahout?


I have a boolean feature whose value can be 0 or 1 and I am currently using a ContinuousValueEncoder to encode it into a vector because I don't see a more suitable encoder in mahout. Is this right? If not, what should I be using instead?

Thanks


Solution

  • You can use the "addToVector(String originalForm, double weight, Vector data)" and pass the binary value as the weight. More here: https://builds.apache.org/job/Mahout-Quality/javadoc/org/apache/mahout/vectorizer/encoders/FeatureVectorEncoder.html#addToVector(java.lang.String, double, org.apache.mahout.math.Vector)