/** * Use this model to evaluate a context and return an array of the likelihood * of each outcome given that context. * * @param context * The names of the predicates which have been observed at the * present decision point. * @param outsums * This is where the distribution is stored. * @return The normalized probabilities for the outcomes given the context. * The indexes of the double[] are the outcome ids, and the actual * string representation of the outcomes can be obtained from the * method getOutcome(int i). */ public final double[] eval(String[] context, float[] values, double[] outsums) { int[] scontexts = new int[context.length]; for (int i = 0; i < context.length; i++) { Integer ci = pmap.get(context[i]); scontexts[i] = ci == null ? -1 : ci; } prior.logPrior(outsums, scontexts, values); return GISModel.eval(scontexts, values, outsums, evalParams); }
/** * 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. * @param prior * The prior to be used with this model. */ public GISModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant, double correctionParam, Prior prior) { super(params, predLabels, outcomeNames, correctionConstant, correctionParam); this.prior = prior; prior.setLabels(outcomeNames, predLabels); modelType = ModelType.Maxent; }
/** * Use this model to evaluate a context and return an array of the likelihood * of each outcome given that context. * * @param context * The names of the predicates which have been observed at the * present decision point. * @param outsums * This is where the distribution is stored. * @return The normalized probabilities for the outcomes given the context. * The indexes of the double[] are the outcome ids, and the actual * string representation of the outcomes can be obtained from the * method getOutcome(int i). */ public final double[] eval(String[] context, float[] values, double[] outsums) { int[] scontexts = new int[context.length]; for (int i = 0; i < context.length; i++) { Integer ci = pmap.get(context[i]); scontexts[i] = ci == null ? -1 : ci; } prior.logPrior(outsums, scontexts, values); return GISModel.eval(scontexts, values, outsums, evalParams); }
/** * 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. * @param prior * The prior to be used with this model. */ public GISModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant, double correctionParam, Prior prior) { super(params, predLabels, outcomeNames, correctionConstant, correctionParam); this.prior = prior; prior.setLabels(outcomeNames, predLabels); modelType = ModelType.Maxent; }
prior.setLabels(labels, featNames);
prior.setLabels(outcomeLabels,predLabels); numPreds = predLabels.length;
prior.setLabels(outcomeLabels,predLabels); numPreds = predLabels.length;
prior.logPrior(modelDistribution, trainingDataFeatNameIndices[ei], trainingDataFeatValues[ei]); GISModel.eval(trainingDataFeatNameIndices[ei], trainingDataFeatValues[ei], modelDistribution, evalParams);
prior.setLabels(outcomeLabels, predLabels); numPreds = predLabels.length;