public QNModel(String[] predNames, String[] outcomeNames, Context[] params, double[] parameters) { super(params, predNames, outcomeNames); this.prior = new UniformPrior(); this.modelType = ModelType.MaxentQn; this.parameters = parameters; }
public QNModel(String[] predNames, String[] outcomeNames, Context[] params, double[] parameters) { super(params, predNames, outcomeNames); this.prior = new UniformPrior(); this.modelType = ModelType.MaxentQn; this.parameters = parameters; }
/** * Creates a new model with the specified parameters, outcome names, and * predicate/feature labels. * * @param params * The parameters of the model. * @param predLabels * The names of the predicates used in this model. * @param outcomeNames * The names of the outcomes this model predicts. * @param correctionConstant * The maximum number of active features which occur in an event. * @param correctionParam * The parameter associated with the correction feature. */ public GISModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant, double correctionParam) { this(params, predLabels, outcomeNames, correctionConstant, correctionParam, new UniformPrior()); }
/** * Creates a new model with the specified parameters, outcome names, and * predicate/feature labels. * * @param params * The parameters of the model. * @param predLabels * The names of the predicates used in this model. * @param outcomeNames * The names of the outcomes this model predicts. * @param correctionConstant * The maximum number of active features which occur in an event. * @param correctionParam * The parameter associated with the correction feature. */ public GISModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant, double correctionParam) { this(params, predLabels, outcomeNames, correctionConstant, correctionParam, new UniformPrior()); }
/** * Train a model using the GIS algorithm. * * @param iterations The number of GIS iterations to perform. * @param di The data indexer used to compress events in memory. * @return The newly trained model, which can be used immediately or saved * to disk using an opennlp.maxent.io.GISModelWriter object. */ public GISModel trainModel(int iterations, DataIndexer di, int cutoff) { return trainModel(iterations,di,new UniformPrior(),cutoff,1); }
/** * Train a model using the GIS algorithm. * * @param iterations * The number of GIS iterations to perform. * @param di * The data indexer used to compress events in memory. * @return The newly trained model, which can be used immediately or saved to * disk using an opennlp.maxent.io.GISModelWriter object. */ public GISModel trainModel(int iterations, DataIndexer di, int cutoff) { return trainModel(iterations, di, new UniformPrior(), cutoff, 1); }
/** * Train a model using the GIS algorithm. * * @param iterations The number of GIS iterations to perform. * @param di The data indexer used to compress events in memory. * @return The newly trained model, which can be used immediately or saved * to disk using an opennlp.maxent.io.GISModelWriter object. */ public GISModel trainModel(int iterations, DataIndexer di, int cutoff) { return trainModel(iterations,di,new UniformPrior(),cutoff,1); }
private MaxEntClassifier train(EventStream es) { Prior prior = new UniformPrior(); DataIndexer di = new OnePassRealValueDataIndexer(es, cutoff, true); GISTrainer gisTrainer = new GISTrainer(); gisTrainer.setSmoothing(useSmoothing); gisTrainer.setSmoothingObservation(smoothingObservation); model = gisTrainer.trainModel(iterations, di, prior, cutoff, nthreads); return this; }
trainer.setSmoothingObservation(SMOOTHING_OBSERVATION); if (modelPrior == null) { modelPrior = new UniformPrior();
trainer.setSmoothingObservation(SMOOTHING_OBSERVATION); if (modelPrior == null) { modelPrior = new UniformPrior();
public QNModel(LogLikelihoodFunction monitor, double[] parameters) { super(null, monitor.getPredLabels(), monitor.getOutcomeLabels()); int[][] outcomePatterns = monitor.getOutcomePatterns(); Context[] params = new Context[monitor.getPredLabels().length]; for (int ci = 0; ci < params.length; ci++) { int[] outcomePattern = outcomePatterns[ci]; double[] alpha = new double[outcomePattern.length]; for (int oi = 0; oi < outcomePattern.length; oi++) { alpha[oi] = parameters[ci + (outcomePattern[oi] * monitor.getPredLabels().length)]; } params[ci] = new Context(outcomePattern, alpha); } this.evalParams = new EvalParameters(params, monitor.getOutcomeLabels().length); this.prior = new UniformPrior(); this.modelType = ModelType.MaxentQn; this.parameters = parameters; }
public QNModel(LogLikelihoodFunction monitor, double[] parameters) { super(null, monitor.getPredLabels(), monitor.getOutcomeLabels()); int[][] outcomePatterns = monitor.getOutcomePatterns(); Context[] params = new Context[monitor.getPredLabels().length]; for (int ci = 0; ci < params.length; ci++) { int[] outcomePattern = outcomePatterns[ci]; double[] alpha = new double[outcomePattern.length]; for (int oi = 0; oi < outcomePattern.length; oi++) { alpha[oi] = parameters[ci + (outcomePattern[oi] * monitor.getPredLabels().length)]; } params[ci] = new Context(outcomePattern, alpha); } this.evalParams = new EvalParameters(params, monitor.getOutcomeLabels().length); this.prior = new UniformPrior(); this.modelType = ModelType.MaxentQn; this.parameters = parameters; }