Example usage for edu.stanford.nlp.classify LinearClassifierFactory LinearClassifierFactory

List of usage examples for edu.stanford.nlp.classify LinearClassifierFactory LinearClassifierFactory

Introduction

In this page you can find the example usage for edu.stanford.nlp.classify LinearClassifierFactory LinearClassifierFactory.

Prototype

public LinearClassifierFactory() 

Source Link

Usage

From source file:gr.aueb.cs.nlp.wordtagger.classifier.MaxEntClassifier.java

License:Open Source License

/**
 * Constructor for more parameters./*from   www .j av  a  2s.c  o m*/
 * @param verbose, whether the classifier should log while training
 * @param maxIterations, the maximum iterations, after which the classifier should stop.
 * @param memStates, the number of previous estimate vector pairs to store
 * @param tolerance, early stopping, checking the Loss Function at every iteration,
 * and then stopping the algorithm, if it is smaller than tolerance.
 */
public MaxEntClassifier(boolean verbose, int maxIterations, int memStates, double tolerance) {
    LinearClassifierFactory<String, String> factory = new LinearClassifierFactory<>();
    factory.setTol(tolerance);
    Factory<Minimizer<DiffFunction>> minimizerCreator = customQN(verbose, maxIterations, memStates);
    factory.setMinimizerCreator(minimizerCreator);
    this.classifierFactory = factory;
}

From source file:gr.aueb.cs.nlp.wordtagger.classifier.SVMWindows64Factory.java

License:Open Source License

/**
 * Builds a sigmoid model to turn the classifier outputs into probabilities.
 *///w ww  . j a v  a2 s.  c  om
private LinearClassifier<L, L> fitSigmoid(SVMLightClassifier<L, F> classifier, GeneralDataset<L, F> dataset) {
    RVFDataset<L, L> plattDataset = new RVFDataset<L, L>();
    for (int i = 0; i < dataset.size(); i++) {
        RVFDatum<L, F> d = dataset.getRVFDatum(i);
        Counter<L> scores = classifier.scoresOf((Datum<L, F>) d);
        scores.incrementCount(null);
        plattDataset.add(new RVFDatum<L, L>(scores, d.label()));
    }
    LinearClassifierFactory<L, L> factory = new LinearClassifierFactory<L, L>();
    factory.setPrior(new LogPrior(LogPrior.LogPriorType.NULL));
    return factory.trainClassifier(plattDataset);
}