Search in sources :

Example 1 with MaxentModelTrainer

use of com.joliciel.talismane.machineLearning.maxent.MaxentModelTrainer in project talismane by joliciel-informatique.

the class ModelTrainerFactory method constructTrainer.

/**
 * Get a classification model trainer corresponding to a given outcome type
 * and a given algorithm.<br>
 * <br>
 * It is assumed the config file passed will be a local configuration, whose
 * root is equivalent to the talismane.machine-learning key in reference.conf
 */
public ClassificationModelTrainer constructTrainer(Config config) {
    config.checkValid(ConfigFactory.defaultReference().getConfig("talismane.machine-learning.generic"));
    MachineLearningAlgorithm algorithm = MachineLearningAlgorithm.valueOf(config.getString("algorithm"));
    ClassificationModelTrainer modelTrainer = null;
    switch(algorithm) {
        case MaxEnt:
            MaxentModelTrainer maxentModelTrainer = new MaxentModelTrainer();
            modelTrainer = maxentModelTrainer;
            break;
        case LinearSVM:
        case LinearSVMOneVsRest:
            LinearSVMModelTrainer linearSVMModelTrainer = new LinearSVMModelTrainer();
            modelTrainer = linearSVMModelTrainer;
            break;
        case Perceptron:
            PerceptronClassificationModelTrainer perceptronModelTrainer = new PerceptronClassificationModelTrainer();
            modelTrainer = perceptronModelTrainer;
            break;
        default:
            throw new JolicielException("Machine learning algorithm not yet supported: " + algorithm);
    }
    modelTrainer.setParameters(config);
    return modelTrainer;
}
Also used : LinearSVMModelTrainer(com.joliciel.talismane.machineLearning.linearsvm.LinearSVMModelTrainer) JolicielException(com.joliciel.talismane.utils.JolicielException) PerceptronClassificationModelTrainer(com.joliciel.talismane.machineLearning.perceptron.PerceptronClassificationModelTrainer) PerceptronClassificationModelTrainer(com.joliciel.talismane.machineLearning.perceptron.PerceptronClassificationModelTrainer) MaxentModelTrainer(com.joliciel.talismane.machineLearning.maxent.MaxentModelTrainer)

Aggregations

LinearSVMModelTrainer (com.joliciel.talismane.machineLearning.linearsvm.LinearSVMModelTrainer)1 MaxentModelTrainer (com.joliciel.talismane.machineLearning.maxent.MaxentModelTrainer)1 PerceptronClassificationModelTrainer (com.joliciel.talismane.machineLearning.perceptron.PerceptronClassificationModelTrainer)1 JolicielException (com.joliciel.talismane.utils.JolicielException)1