public AbstractModel(Context[] params, String[] predLabels, IndexHashTable<String> pmap, String[] outcomeNames) { this.pmap = pmap; this.outcomeNames = outcomeNames; this.evalParams = new EvalParameters(params,outcomeNames.length); }
Context[] params = model.getParams(); int numfeats[] = new int[model.getNumOutcomes()]; int[] activeOutcomes; double[] activeParameters; for (int oid = 0; oid < model.getNumOutcomes(); oid++) { if (model.getCorrectionParam() != 0) { prior[oid] = Math .exp(prior[oid] * model.getConstantInverse() + ((1.0 - ((double) numfeats[oid] / model .getCorrectionConstant())) * model.getCorrectionParam())); } else { prior[oid] = Math.exp(prior[oid] * model.getConstantInverse()); for (int oid = 0; oid < model.getNumOutcomes(); oid++) { prior[oid] /= normal;
/** * 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: * * <li>index 0: opennlp.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. * <li>index 3: java.lang.Integer containing the value of the models * correction constant * <li>index 4: java.lang.Double containing the value of the models * correction parameter * * @return An Object[] with the values as described above. */ public final Object[] getDataStructures() { Object[] data = new Object[5]; data[0] = evalParams.getParams(); data[1] = pmap; data[2] = outcomeNames; data[3] = (int) evalParams.getCorrectionConstant(); data[4] = evalParams.getCorrectionParam(); return data; } }
evalParams = new EvalParameters(params, 0, 1, labels.length); int[] activeOutcomes = new int[labels.length]; int[] labelPattern = new int[labels.length]; return new GISModel(params, featNames, labels, 1, evalParams.getCorrectionParam());
public int getNumOutcomes() { return(evalParams.getNumOutcomes()); }
public static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] params = model.getParams(); double[] activeParameters; int[] activeOutcomes; int numOutcomes = model.getNumOutcomes();
Context[] contextComparing = objModel.evalParams.getParams(); if (this.evalParams.getParams().length != contextComparing.length) return false; for (int i = 0; i < this.evalParams.getParams().length; i++) { if (this.evalParams.getParams()[i].getOutcomes().length != contextComparing[i].getOutcomes().length) return false; for (int j = 0; i < this.evalParams.getParams()[i].getOutcomes().length; i++) { if (this.evalParams.getParams()[i].getOutcomes()[j] != contextComparing[i].getOutcomes()[j]) return false; if (this.evalParams.getParams()[i].getParameters().length != contextComparing[i].getParameters().length) return false; for (int j = 0; i < this.evalParams.getParams()[i].getParameters().length; i++) { if (this.evalParams.getParams()[i].getParameters()[j] != contextComparing[i].getParameters()[j]) return false;
evalParams = new EvalParameters(params,0,1,numOutcomes); int[] activeOutcomes = new int[numOutcomes]; int[] outcomePattern; return new GISModel(params, predLabels, outcomeLabels, 1, evalParams.getCorrectionParam());
/** * 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: * * <li>index 0: opennlp.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. * <li>index 3: java.lang.Integer containing the value of the models * correction constant * <li>index 4: java.lang.Double containing the value of the models * correction parameter * * @return An Object[] with the values as described above. */ public final Object[] getDataStructures() { Object[] data = new Object[5]; data[0] = evalParams.getParams(); data[1] = pmap; data[2] = outcomeNames; data[3] = (int) evalParams.getCorrectionConstant(); data[4] = evalParams.getCorrectionParam(); return data; } }
public int getNumOutcomes() { return(evalParams.getNumOutcomes()); }
public static double[] eval(int[] context, float[] values, double[] prior, EvalParameters model, boolean normalize) { Context[] params = model.getParams(); double[] activeParameters; int[] activeOutcomes; int numOutcomes = model.getNumOutcomes();
Context[] contextComparing = objModel.evalParams.getParams(); if (this.evalParams.getParams().length != contextComparing.length) return false; for (int i = 0; i < this.evalParams.getParams().length; i++) { if (this.evalParams.getParams()[i].getOutcomes().length != contextComparing[i].getOutcomes().length) return false; for (int j = 0; i < this.evalParams.getParams()[i].getOutcomes().length; i++) { if (this.evalParams.getParams()[i].getOutcomes()[j] != contextComparing[i].getOutcomes()[j]) return false; if (this.evalParams.getParams()[i].getParameters().length != contextComparing[i].getParameters().length) return false; for (int j = 0; i < this.evalParams.getParams()[i].getParameters().length; i++) { if (this.evalParams.getParams()[i].getParameters()[j] != contextComparing[i].getParameters()[j]) return false;
evalParams = new EvalParameters(params,0,1,numOutcomes); int[] activeOutcomes = new int[numOutcomes]; int[] outcomePattern; return new GISModel(params, predLabels, outcomeLabels, 1, evalParams.getCorrectionParam());
Context[] params = model.getParams(); int numfeats[] = new int[model.getNumOutcomes()]; int[] activeOutcomes; double[] activeParameters; for (int oid = 0; oid < model.getNumOutcomes(); oid++) { if (model.getCorrectionParam() != 0) { prior[oid] = Math .exp(prior[oid] * model.getConstantInverse() + ((1.0 - ((double) numfeats[oid] / model .getCorrectionConstant())) * model.getCorrectionParam())); } else { prior[oid] = Math.exp(prior[oid] * model.getConstantInverse()); for (int oid = 0; oid < model.getNumOutcomes(); oid++) { prior[oid] /= normal;
public AbstractModel(Context[] params, String[] predLabels, IndexHashTable<String> pmap, String[] outcomeNames) { this.pmap = pmap; this.outcomeNames = outcomeNames; this.evalParams = new EvalParameters(params,outcomeNames.length); }
public double[] eval(String[] context, float[] values) { return eval(context, values, new double[evalParams.getNumOutcomes()]); }
evalParams = new EvalParameters(params, 0, 1, numOutcomes); int[] activeOutcomes = new int[numOutcomes]; int[] outcomePattern; return new GISModel(params, predLabels, outcomeLabels, 1, evalParams.getCorrectionParam());
public AbstractModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant,double correctionParam) { init(predLabels,outcomeNames); this.evalParams = new EvalParameters(params,correctionParam,correctionConstant,outcomeNames.length); }
public final double[] eval(String[] context, float[] values) { return (eval(context, values, new double[evalParams.getNumOutcomes()])); }
public AbstractModel(Context[] params, String[] predLabels, String[] outcomeNames) { init(predLabels,outcomeNames); this.evalParams = new EvalParameters(params,outcomeNames.length); }