Search in sources :

Example 1 with MLLogisticRegression

use of edu.neu.ccs.pyramid.multilabel_classification.multi_label_logistic_regression.MLLogisticRegression in project pyramid by cheng-li.

the class MLACPlattScalingTest method test2.

private static void test2() throws Exception {
    MultiLabelClfDataSet dataSet = TRECFormat.loadMultiLabelClfDataSet(new File(DATASETS, "ohsumed/3/train.trec"), DataSetType.ML_CLF_SPARSE, true);
    List<MultiLabel> assignments = DataSetUtil.gatherMultiLabels(dataSet);
    MLLogisticTrainer trainer = MLLogisticTrainer.getBuilder().setGaussianPriorVariance(10000).build();
    MLLogisticRegression logisticRegression = trainer.train(dataSet, assignments);
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    MLACPlattScaling plattScaling = new MLACPlattScaling(dataSet, logisticRegression);
    for (int i = 0; i < 10; i++) {
        System.out.println(Arrays.toString(logisticRegression.predictClassScores(dataSet.getRow(i))));
        System.out.println(Arrays.toString(logisticRegression.predictClassProbs(dataSet.getRow(i))));
        System.out.println(Arrays.toString(plattScaling.predictClassProbs(dataSet.getRow(i))));
        System.out.println("======================");
    }
}
Also used : MLLogisticTrainer(edu.neu.ccs.pyramid.multilabel_classification.multi_label_logistic_regression.MLLogisticTrainer) File(java.io.File) MLLogisticRegression(edu.neu.ccs.pyramid.multilabel_classification.multi_label_logistic_regression.MLLogisticRegression) StopWatch(org.apache.commons.lang3.time.StopWatch)

Aggregations

MLLogisticRegression (edu.neu.ccs.pyramid.multilabel_classification.multi_label_logistic_regression.MLLogisticRegression)1 MLLogisticTrainer (edu.neu.ccs.pyramid.multilabel_classification.multi_label_logistic_regression.MLLogisticTrainer)1 File (java.io.File)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1