Example usage for weka.core SparseInstance setClassValue

List of usage examples for weka.core SparseInstance setClassValue

Introduction

In this page you can find the example usage for weka.core SparseInstance setClassValue.

Prototype


@Override
public void setClassValue(double value) 

Source Link

Document

Sets the class value of an instance to the given value (internal floating-point format).

Usage

From source file:edu.cmu.lti.oaqa.baseqa.providers.ml.classifiers.WekaProvider.java

License:Apache License

private static Instance newInstance(Map<String, Double> features, String label, double weight,
        Instances dataset) {/*from  w  ww. j av  a2 s .c  om*/
    double[] values = new double[dataset.numAttributes()];
    for (Map.Entry<String, Double> entry : features.entrySet()) {
        Attribute attribute = dataset.attribute(entry.getKey());
        if (attribute == null)
            continue;
        values[attribute.index()] = entry.getValue();
    }
    SparseInstance instance = new SparseInstance(weight, values);
    instance.setDataset(dataset);
    if (label != null)
        instance.setClassValue(label);
    return instance;
}