/** * Provides the fundamental data structures which encode the maxent model * information. This method will usually only be needed by * GISModelWriters. The following values are held in the Object array * which is returned by this method: * <ul> * <li>index 0: opennlp.tools.ml.maxent.Context[] containing the model * parameters * <li>index 1: java.util.Map containing the mapping of model predicates * to unique integers * <li>index 2: java.lang.String[] containing the names of the outcomes, * stored in the index of the array which represents their * unique ids in the model. * </ul> * * @return An Object[] with the values as described above. */ public final Object[] getDataStructures() { Object[] data = new Object[3]; data[0] = evalParams.getParams(); data[1] = pmap; data[2] = outcomeNames; return data; }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
/** * Use this model to evaluate a context and return an array of the likelihood * of each outcome given the specified context and the specified parameters. * * @param context * The integer values of the predicates which have been observed at * the present decision point. * @param values * The values for each of the parameters. * @param prior * The prior distribution for the specified context. * @param model * The set of parametes used in this computation. * @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). */ static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return GISModel.eval(scontexts, values, prior, model); }
/** * Provides the fundamental data structures which encode the maxent model * information. This method will usually only be needed by * GISModelWriters. The following values are held in the Object array * which is returned by this method: * <ul> * <li>index 0: opennlp.tools.ml.maxent.Context[] containing the model * parameters * <li>index 1: java.util.Map containing the mapping of model predicates * to unique integers * <li>index 2: java.lang.String[] containing the names of the outcomes, * stored in the index of the array which represents their * unique ids in the model. * </ul> * * @return An Object[] with the values as described above. */ public final Object[] getDataStructures() { Object[] data = new Object[3]; data[0] = evalParams.getParams(); data[1] = pmap; data[2] = outcomeNames; return data; }
/** * Provides the fundamental data structures which encode the maxent model * information. This method will usually only be needed by * GISModelWriters. The following values are held in the Object array * which is returned by this method: * <ul> * <li>index 0: opennlp.tools.ml.maxent.Context[] containing the model * parameters * <li>index 1: java.util.Map containing the mapping of model predicates * to unique integers * <li>index 2: java.lang.String[] containing the names of the outcomes, * stored in the index of the array which represents their * unique ids in the model. * </ul> * * @return An Object[] with the values as described above. */ public final Object[] getDataStructures() { Object[] data = new Object[3]; data[0] = evalParams.getParams(); data[1] = pmap; data[2] = outcomeNames; return data; }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return eval(scontexts, values, prior, model, normalize); }
/** * Use this model to evaluate a context and return an array of the likelihood * of each outcome given the specified context and the specified parameters. * * @param context * The integer values of the predicates which have been observed at * the present decision point. * @param values * The values for each of the parameters. * @param prior * The prior distribution for the specified context. * @param model * The set of parametes used in this computation. * @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). */ static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return GISModel.eval(scontexts, values, prior, model); }
/** * Use this model to evaluate a context and return an array of the likelihood * of each outcome given the specified context and the specified parameters. * * @param context * The integer values of the predicates which have been observed at * the present decision point. * @param values * The values for each of the parameters. * @param prior * The prior distribution for the specified context. * @param model * The set of parametes used in this computation. * @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). */ static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model) { Context[] scontexts = new Context[context.length]; for (int i = 0; i < context.length; i++) { scontexts[i] = model.getParams()[context[i]]; } return GISModel.eval(scontexts, values, prior, model); }
static double[] eval(Context[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] params = model.getParams(); double[] activeParameters; int[] activeOutcomes;
static double[] eval(Context[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Probabilities<Integer> probabilities = new LogProbabilities<>(); Context[] params = model.getParams(); double[] outcomeTotals = model instanceof NaiveBayesEvalParameters ? ((NaiveBayesEvalParameters) model).getOutcomeTotals() : new double[prior.length];