All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.etsy.conjecture.data.MulticlassLabeledInstance Maven / Gradle / Ivy

There is a newer version: 0.2.3
Show newest version
package com.etsy.conjecture.data;

import java.util.Map;

public class MulticlassLabeledInstance extends
        AbstractInstance implements
        LabeledInstance {

    protected MulticlassLabel label;

    public MulticlassLabel getLabel() {
        return label;
    }

    public MulticlassLabeledInstance(String label) {
        this(new MulticlassLabel(label), 1.0);
    }

    public MulticlassLabeledInstance(String label, double weight) {
        this(new MulticlassLabel(label), weight);
    }

    public MulticlassLabeledInstance(String label, Map instance) {
        this(new MulticlassLabel(label), instance, 1.0);
    }

    public MulticlassLabeledInstance(String label,
            Map instance, double weight) {
        this(new MulticlassLabel(label), instance, weight);
    }

    public MulticlassLabeledInstance(String label, StringKeyedVector vec) {
        this(new MulticlassLabel(label), vec.getMap(), 1.0);
    }

    public MulticlassLabeledInstance(String label, StringKeyedVector vec,
            double weight) {
        this(new MulticlassLabel(label), vec.getMap(), weight);
    }

    public MulticlassLabeledInstance(MulticlassLabel label) {
        this(label, 1.0);
    }

    public MulticlassLabeledInstance(MulticlassLabel label, double weight) {
        super(weight);
        this.label = label;
    }

    public MulticlassLabeledInstance(MulticlassLabel label,
            Map instance) {
        this(label, instance, 1.0);
    }

    public MulticlassLabeledInstance(MulticlassLabel label,
            Map instance, double weight) {
        super(instance, weight);
        this.label = label;
    }

    public MulticlassLabeledInstance(MulticlassLabel label,
            StringKeyedVector vec) {
        this(label, vec.getMap(), 1.0);
    }

    public MulticlassLabeledInstance(MulticlassLabel label,
            StringKeyedVector vec, double weight) {
        this(label, vec.getMap(), weight);
    }

    public BinaryLabeledInstance toBinaryInstance(String category) {
        double tmpLabel = 0d;
        if (category.equals(this.label.getLabel())) {
            tmpLabel = 1d;
        }
        return new BinaryLabeledInstance(tmpLabel, getVector());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy