Search in sources :

Example 1 with GeneralF1Predictor

use of edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor in project pyramid by cheng-li.

the class InstanceF1Predictor method predict.

@Override
public MultiLabel predict(Vector vector) {
    double[] probs = imlGradientBoosting.predictAllAssignmentProbsWithConstraint(vector);
    List<Double> probList = Arrays.stream(probs).mapToObj(a -> a).collect(Collectors.toList());
    GeneralF1Predictor generalF1Predictor = new GeneralF1Predictor();
    return generalF1Predictor.predict(imlGradientBoosting.getNumClasses(), imlGradientBoosting.getAssignments(), probList);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) MultiLabel(edu.neu.ccs.pyramid.dataset.MultiLabel) Vector(org.apache.mahout.math.Vector) PluginPredictor(edu.neu.ccs.pyramid.multilabel_classification.PluginPredictor) Collectors(java.util.stream.Collectors) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)

Example 2 with GeneralF1Predictor

use of edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor in project pyramid by cheng-li.

the class InstanceF1Predictor method showPredictBySupport.

public GeneralF1Predictor.Analysis showPredictBySupport(Vector vector, MultiLabel truth) {
    // System.out.println("support procedure");
    List<MultiLabel> support = cmlcrf.getSupportCombinations();
    double[] probs = cmlcrf.predictCombinationProbs(vector);
    GeneralF1Predictor generalF1Predictor = new GeneralF1Predictor();
    MultiLabel prediction = generalF1Predictor.predict(cmlcrf.getNumClasses(), support, probs);
    GeneralF1Predictor.Analysis analysis = GeneralF1Predictor.showSupportPrediction(support, probs, truth, prediction, cmlcrf.getNumClasses());
    return analysis;
}
Also used : MultiLabel(edu.neu.ccs.pyramid.dataset.MultiLabel) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)

Example 3 with GeneralF1Predictor

use of edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor in project pyramid by cheng-li.

the class PluginF1 method predictBySamplingNonEmpty.

private MultiLabel predictBySamplingNonEmpty(Vector vector) {
    List<MultiLabel> samples = cbm.samples(vector, numSamples);
    List<MultiLabel> nonZeros = samples.stream().filter(a -> a.getNumMatchedLabels() > 0).collect(Collectors.toList());
    GeneralF1Predictor generalF1Predictor = new GeneralF1Predictor();
    generalF1Predictor.setMaxSize(maxSize);
    return generalF1Predictor.predict(cbm.getNumClasses(), nonZeros);
}
Also used : java.util(java.util) ConcurrentHashMultiset(com.google.common.collect.ConcurrentHashMultiset) Multiset(com.google.common.collect.Multiset) MultiLabel(edu.neu.ccs.pyramid.dataset.MultiLabel) Vector(org.apache.mahout.math.Vector) DataSetUtil(edu.neu.ccs.pyramid.dataset.DataSetUtil) PluginPredictor(edu.neu.ccs.pyramid.multilabel_classification.PluginPredictor) Matrix(org.apache.mahout.math.Matrix) Collectors(java.util.stream.Collectors) Pair(edu.neu.ccs.pyramid.util.Pair) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor) MultiLabel(edu.neu.ccs.pyramid.dataset.MultiLabel) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)

Example 4 with GeneralF1Predictor

use of edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor in project pyramid by cheng-li.

the class PluginF1 method predictBySampling.

private MultiLabel predictBySampling(Vector vector) {
    List<MultiLabel> samples = cbm.samples(vector, numSamples);
    GeneralF1Predictor generalF1Predictor = new GeneralF1Predictor();
    generalF1Predictor.setMaxSize(maxSize);
    return generalF1Predictor.predict(cbm.getNumClasses(), samples);
// unique the sample set and apply GFM
// List<MultiLabel> uniqueSamples = new ArrayList(new HashSet(samples));
// List<Double> probs = cbm.predictAssignmentProbs(vector, uniqueSamples);
// return GeneralF1Predictor.predict(cbm.getNumClasses(), uniqueSamples, probs);
}
Also used : MultiLabel(edu.neu.ccs.pyramid.dataset.MultiLabel) GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)

Example 5 with GeneralF1Predictor

use of edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor in project pyramid by cheng-li.

the class PluginF1 method predictBySupport.

private MultiLabel predictBySupport(Vector vector) {
    double[] probs = cbm.predictAssignmentProbs(vector, support, piThreshold);
    GeneralF1Predictor generalF1Predictor = new GeneralF1Predictor();
    generalF1Predictor.setMaxSize(maxSize);
    return generalF1Predictor.predict(cbm.getNumClasses(), support, probs);
}
Also used : GeneralF1Predictor(edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)

Aggregations

GeneralF1Predictor (edu.neu.ccs.pyramid.multilabel_classification.plugin_rule.GeneralF1Predictor)8 MultiLabel (edu.neu.ccs.pyramid.dataset.MultiLabel)6 PluginPredictor (edu.neu.ccs.pyramid.multilabel_classification.PluginPredictor)2 Collectors (java.util.stream.Collectors)2 Vector (org.apache.mahout.math.Vector)2 ConcurrentHashMultiset (com.google.common.collect.ConcurrentHashMultiset)1 Multiset (com.google.common.collect.Multiset)1 DataSetUtil (edu.neu.ccs.pyramid.dataset.DataSetUtil)1 Pair (edu.neu.ccs.pyramid.util.Pair)1 java.util (java.util)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Matrix (org.apache.mahout.math.Matrix)1