/// <summary> /// Uses the classifier to classify an instance (from its featureValues). /// </summary> /// <param name="featureValues">An array of doubles that describe the instance.</param> /// <returns>The string name of the classification of the instance.</returns> public string classify(double[] featureValues) { //if (!classifierBuilt) { _classifier.buildClassifier(_dataSet); classifierBuilt = true; } weka.core.Instance inst = new weka.core.Instance(1, featureValues); inst.setDataset(_dataSet); double result = _classifier.classifyInstance(inst); weka.core.Attribute attribute = _dataSet.attribute(_dataSet.numAttributes() - 1); string resultName = attribute.value((int)result); // Get rid of this line once ARFF files are rewritten if (resultName == "Label") { resultName = "Text"; } //Console.WriteLine(resultName); return(resultName); }