public ConfidencePredictingClassifierTrainer (ClassifierTrainer underlyingClassifierTrainer, InstanceList validationSet, Pipe confidencePredictingPipe) { this.confidencePredictingPipe = confidencePredictingPipe; this.confidencePredictingClassifierTrainer = new MaxEntTrainer(); this.validationSet = validationSet; //this.confidencePredictingClassifierTrainer = new DecisionTreeTrainer(); //this.confidencePredictingClassifierTrainer = new NaiveBayesTrainer(); this.underlyingClassifierTrainer = underlyingClassifierTrainer; }
public MaxEnt train (InstanceList trainingSet) { return train (trainingSet, numIterations); }
public MaxEntOptimizableByLabelLikelihood getOptimizable (InstanceList trainingSet) { return getOptimizable(trainingSet, getClassifier()); }
final MaxEntTrainer maxEntTrainer = new MaxEntTrainer(); LOGGER.info("JNET ME training ..."); Classifier me = null; if (number_iterations == 0) me = maxEntTrainer.train(tokenData); else me = maxEntTrainer.train(tokenData, number_iterations); model = me;
public void testTrainedMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); MaxEnt me = (MaxEnt)trainer.train(ilist); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist, me); TestOptimizable.testValueAndGradientCurrentParameters (maxable); }
public void testSetGetParameters () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testGetSetParameters (maxable); }
public ClassifierTrainer<MaxEnt> createTrainer(String... args) { MaxEntTrainer trainer = new MaxEntTrainer(); if (args != null) { if (args.length % 2 != 0) { throw new IllegalArgumentException("each argument must be supplied with a value: " + getUsageMessage()); } for (int i = 0; i < args.length; i += 2) { String optionName = args[i]; String optionValue = args[i + 1]; if (optionName.equals("--numIterations")) { int numIterations = Integer.parseInt(optionValue); if (numIterations > 0) trainer.setNumIterations(numIterations); else throw new IllegalArgumentException("numIterations must be positive. " + getUsageMessage()); } else if (optionName.equals("--gaussianPriorVariance")) trainer.setGaussianPriorVariance(Double.parseDouble(optionValue)); else throw new IllegalArgumentException(String.format( "the argument %1$s is invalid. ", optionName) + getUsageMessage()); } } return trainer; }
/** This method is called by the train method. * This is the main entry point for the optimizable and optimizer * compontents. */ public Optimizer getOptimizer (InstanceList trainingSet) { // If the data is not set, or has changed, // initialize the optimizable object and // replace the optimizer. if (trainingSet != this.trainingSet || optimizable == null) { getOptimizable(trainingSet); optimizer = null; } // Build a new optimizer if (optimizer == null) { // If l1Weight is 0, this devolves to // standard L-BFGS, but the implementation // may be faster. optimizer = new LimitedMemoryBFGS(optimizable); //OrthantWiseLimitedMemoryBFGS(optimizable, l1Weight); } return optimizer; }
public MaxEnt train (InstanceList trainingSet, int numIterations) getOptimizer (trainingSet); // This will set this.optimizer, this.optimizable getOptimizer(trainingSet); try { finishedTraining = optimizer.optimize ();
final MaxEntTrainer maxEntTrainer = new MaxEntTrainer(); LOGGER.info("JNET ME training ..."); Classifier me = null; if (number_iterations == 0) me = maxEntTrainer.train(tokenData); else me = maxEntTrainer.train(tokenData, number_iterations); model = me;
public void testTrainedMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); MaxEnt me = (MaxEnt)trainer.train(ilist); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist, me); TestOptimizable.testValueAndGradientCurrentParameters (maxable); }
public void testSetGetParameters () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1", "class2"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testGetSetParameters (maxable); }
public ClassifierTrainer<MaxEnt> createTrainer(String... args) { MaxEntTrainer trainer = new MaxEntTrainer(); if (args != null) { if (args.length % 2 != 0) { throw new IllegalArgumentException("each argument must be supplied with a value: " + getUsageMessage()); } for (int i = 0; i < args.length; i += 2) { String optionName = args[i]; String optionValue = args[i + 1]; if (optionName.equals("--numIterations")) { int numIterations = Integer.parseInt(optionValue); if (numIterations > 0) trainer.setNumIterations(numIterations); else throw new IllegalArgumentException("numIterations must be positive. " + getUsageMessage()); } else if (optionName.equals("--gaussianPriorVariance")) trainer.setGaussianPriorVariance(Double.parseDouble(optionValue)); else throw new IllegalArgumentException(String.format( "the argument %1$s is invalid. ", optionName) + getUsageMessage()); } } return trainer; }
/** This method is called by the train method. * This is the main entry point for the optimizable and optimizer * compontents. */ public Optimizer getOptimizer (InstanceList trainingSet) { // If the data is not set, or has changed, // initialize the optimizable object and // replace the optimizer. if (trainingSet != this.trainingSet || optimizable == null) { getOptimizable(trainingSet); optimizer = null; } // Build a new optimizer if (optimizer == null) { // If l1Weight is 0, this devolves to // standard L-BFGS, but the implementation // may be faster. optimizer = new LimitedMemoryBFGS(optimizable); //OrthantWiseLimitedMemoryBFGS(optimizable, l1Weight); } return optimizer; }
public MaxEnt train (InstanceList trainingSet, int numIterations) getOptimizer (trainingSet); // This will set this.optimizer, this.optimizable getOptimizer(trainingSet); try { finishedTraining = optimizer.optimize ();
final MaxEntTrainer maxEntTrainer = new MaxEntTrainer(); LOGGER.info("JNET ME training ..."); Classifier me = null; if (number_iterations == 0) me = maxEntTrainer.train(tokenData); else me = maxEntTrainer.train(tokenData, number_iterations); model = me;
public MaxEntSequenceConfidenceEstimator (Transducer model, double gaussianVariance) { super(model); meTrainer = new MaxEntTrainer (gaussianVariance); }
public void testRandomMaximizable () { MaxEntTrainer trainer = new MaxEntTrainer(); Alphabet fd = dictOfSize (6); String[] classNames = new String[] {"class0", "class1"}; InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20); Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist); TestOptimizable.testValueAndGradient (maxable); }
public MaxEnt train (InstanceList trainingSet) { return train (trainingSet, numIterations); }
public MaxEntOptimizableByLabelLikelihood getOptimizable (InstanceList trainingSet) { return getOptimizable(trainingSet, getClassifier()); }