use of edu.neu.ccs.pyramid.optimization.ConjugateGradientDescent in project pyramid by cheng-li.
the class LogisticRegressionTest method test2.
private static void test2() throws Exception {
ClfDataSet dataSet = TRECFormat.loadClfDataSet(new File(DATASETS, "/imdb/3/train.trec"), DataSetType.CLF_SPARSE, true);
ClfDataSet testSet = TRECFormat.loadClfDataSet(new File(DATASETS, "/imdb/3/test.trec"), DataSetType.CLF_SPARSE, true);
System.out.println(dataSet.getMetaInfo());
LogisticRegression logisticRegression = new LogisticRegression(dataSet.getNumClasses(), dataSet.getNumFeatures());
LogisticLoss function = new LogisticLoss(logisticRegression, dataSet, 0.1, true);
ConjugateGradientDescent conjugateGradientDescent = new ConjugateGradientDescent(function);
conjugateGradientDescent.getLineSearcher().setInitialStepLength(0.01);
conjugateGradientDescent.optimize();
System.out.println("train: " + Accuracy.accuracy(logisticRegression, dataSet));
System.out.println("test: " + Accuracy.accuracy(logisticRegression, testSet));
}
Aggregations