Optasia wrapper for classifier processor
- public class ClassifierProcessor : Processor
- {
- public override IEnumerable<Row> Process(RowSet input, Row outputRow, string[] args)
- {
- //Initialize the classifier
- classifierM c = new classifierM(CLAS.LIBLINEAR, args[0]);
-
- //For each input row corresponding to a feature vector, apply the classifier
- foreach (Row row in input.Rows)
- {
- //Decode double vector
- List<float> feat = Optasia.Decode(row[row.Count - 1].Binary);
- //Call the classifier
- var result = c.predict(feat);
- //Return probabilistic results
- foreach (var pair in result)
- {
- outputRow[0].Set((int)row[0].Value);
- outputRow[1].Set((int)row[1].Value);
- outputRow[2].Set(pair.Key);
- outputRow[3].Set(pair.Value);
- yield return outputRow;
- }
- }
- }
- }