public void setAlphabet (Alphabet d) { this.size = d.size(); this.counts = new double[size]; this.dictionary = d; }
public Logged (double[] probabilities, Alphabet dictionary, boolean areLoggedAlready) { this (probabilities, dictionary, (dictionary == null ? probabilities.length : dictionary.size()), areLoggedAlready); }
public Logged (double[] probabilities, Alphabet dictionary, int size, boolean areLoggedAlready) { super (probabilities, dictionary, size, true, !areLoggedAlready); assert (dictionary == null || dictionary.size() == size); if (!areLoggedAlready) for (int i = 0; i < size; i++) values[i] = Math.log (values[i]); }
public CRF4 (Alphabet inputAlphabet, Alphabet outputAlphabet) { inputAlphabet.stopGrowth(); logger.info ("CRF input dictionary size = "+inputAlphabet.size()); //xxx outputAlphabet.stopGrowth(); this.inputAlphabet = inputAlphabet; this.outputAlphabet = outputAlphabet; //this.defaultFeatureIndex = inputAlphabet.size(); }
public Dirichlet (double[] alphas, Alphabet dict) { if (dict != null && alphas.length != dict.size()) throw new IllegalArgumentException ("alphas and dict sizes do not match."); this.alphas = alphas; this.dict = dict; if (dict != null) dict.stopGrowth(); }
public HMM (Alphabet inputAlphabet, Alphabet outputAlphabet) { inputAlphabet.stopGrowth(); logger.info ("HMM input dictionary size = "+inputAlphabet.size()); this.inputAlphabet = inputAlphabet; this.outputAlphabet = outputAlphabet; }
public CRF2 (Alphabet inputAlphabet, Alphabet outputAlphabet) { inputAlphabet.stopGrowth(); logger.info ("CRF input dictionary size = "+inputAlphabet.size()); //xxx outputAlphabet.stopGrowth(); this.inputAlphabet = inputAlphabet; this.outputAlphabet = outputAlphabet; //this.defaultFeatureIndex = inputAlphabet.size(); }
public void addFullyConnectedStatesForLabels () { String[] labels = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { labels[i] = (String) outputAlphabet.lookupObject(i); } addFullyConnectedStates (labels); }
public FeatureSelection (RankedFeatureVector rsv, int numFeatures) { this.dictionary = rsv.getAlphabet(); this.selectedFeatures = new BitSet (dictionary.size()); int numSelections = Math.min (numFeatures, dictionary.size()); for (int i = 0; i < numSelections; i++) selectedFeatures.set (rsv.getIndexAtRank(i)); }
public void addSelfTransitioningStateForAllLabels (String name) { String[] labels = new String[outputAlphabet.size()]; String[] destinationNames = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { logger.info ("CRF: outputAlphabet.lookup class = "+ outputAlphabet.lookupObject(i).getClass().getName()); labels[i] = (String) outputAlphabet.lookupObject(i); destinationNames[i] = name; } addState (name, 0.0, 0.0, destinationNames, labels); }
public void setParameter (int classIndex, int featureIndex, double value) { parameters[classIndex*(getAlphabet().size()+1) + featureIndex] = value; }
public void addSelfTransitioningStateForAllLabels (String name) { String[] labels = new String[outputAlphabet.size()]; String[] destinationNames = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { System.out.println ("CRF: outputAlphabet.lookup class = "+ outputAlphabet.lookupObject(i).getClass().getName()); labels[i] = (String) outputAlphabet.lookupObject(i); destinationNames[i] = name; } addState (name, 0.0, 0.0, destinationNames, labels); }
public MaxEnt (Pipe dataPipe, double[] parameters, FeatureSelection featureSelection, FeatureSelection[] perClassFeatureSelection) { super (dataPipe); assert (featureSelection == null || perClassFeatureSelection == null); this.parameters = parameters; this.featureSelection = featureSelection; this.perClassFeatureSelection = perClassFeatureSelection; this.defaultFeatureIndex = dataPipe.getDataAlphabet().size(); // assert (parameters.getNumCols() == defaultFeatureIndex+1); }
public void addFullyConnectedStatesForLabels () { String[] labels = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { logger.info ("CRF: outputAlphabet.lookup class = "+ outputAlphabet.lookupObject(i).getClass().getName()); labels[i] = (String) outputAlphabet.lookupObject(i); } addFullyConnectedStates (labels); }
public void addFullyConnectedStatesForLabels () { String[] labels = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { System.out.println ("CRF: outputAlphabet.lookup class = "+ outputAlphabet.lookupObject(i).getClass().getName()); labels[i] = (String) outputAlphabet.lookupObject(i); } addFullyConnectedStates (labels); }
public void addFullyConnectedStatesForLabels () { String[] labels = new String[outputAlphabet.size()]; // This is assuming the the entries in the outputAlphabet are Strings! for (int i = 0; i < outputAlphabet.size(); i++) { logger.info ("CRF: outputAlphabet.lookup class = "+ outputAlphabet.lookupObject(i).getClass().getName()); labels[i] = (String) outputAlphabet.lookupObject(i); } addFullyConnectedStates (labels); }
public CRF (Pipe inputPipe, Pipe outputPipe) { this.inputPipe = inputPipe; this.outputPipe = outputPipe; this.inputAlphabet = inputPipe.getDataAlphabet(); this.outputAlphabet = inputPipe.getTargetAlphabet(); this.defaultFeatureIndex = inputAlphabet.size(); //inputAlphabet.stopGrowth(); }
public PerLabelFeatureCounts (InstanceList ilist) { dataAlphabet = ilist.getDataAlphabet(); targetAlphabet = ilist.getTargetAlphabet(); double[][] counts = calcFeatureCounts (ilist); fc = new FeatureCounts[targetAlphabet.size()]; for (int i = 0; i < fc.length; i++) fc[i] = new FeatureCounts (dataAlphabet, counts[i]); }
public Classifier trainPairwiseClassifier (ArrayList[] nodes, Pipe p) { InstanceList ilist = new InstanceList (p); for (int i=0; i < nodes.length; i++) ilist.add (CitationUtils.makePairs (p, nodes[i])); System.err.println ("Training size: " + ilist.size() + "\tNum features: " + ilist.getDataAlphabet().size()); MaxEnt me = (MaxEnt)(new MaxEntTrainer().train(ilist, null, null, null, null)); ilist.getDataAlphabet().stopGrowth(); Trial t = new Trial(me, ilist); System.out.println("Pairwise classifier: -> Training F1 on \"yes\" is: " + t.labelF1("yes")); System.out.println("Pairwise classifier: -> Training F1 on \"no\" is: " + t.labelF1("no")); return me; }