/** * Set target distributions using "Schapire" heuristic described in * "Learning from Labeled Features using Generalized Expectation Criteria" * Gregory Druck, Gideon Mann, Andrew McCallum. * * @param labeledFeatures HashMap of feature indices to lists of label indices for that feature. * @param numLabels Total number of labels. * @param majorityProb Probability mass divided among majority labels. * @return Constraints (map of feature index to target distribution), with target * distributions set using heuristic. */ public static HashMap<Integer,double[]> setTargetsUsingHeuristic(HashMap<Integer,ArrayList<Integer>> labeledFeatures, int numLabels, double majorityProb) { HashMap<Integer,double[]> constraints = new HashMap<Integer,double[]>(); Iterator<Integer> keyIter = labeledFeatures.keySet().iterator(); while (keyIter.hasNext()) { int fi = keyIter.next(); ArrayList<Integer> labels = labeledFeatures.get(fi); constraints.put(fi, getHeuristicPrior(labels,numLabels,majorityProb)); } return constraints; }
/** * Set target distributions using "Schapire" heuristic described in * "Learning from Labeled Features using Generalized Expectation Criteria" * Gregory Druck, Gideon Mann, Andrew McCallum. * * @param labeledFeatures HashMap of feature indices to lists of label indices for that feature. * @param numLabels Total number of labels. * @param majorityProb Probability mass divided among majority labels. * @return Constraints (map of feature index to target distribution), with target * distributions set using heuristic. */ public static HashMap<Integer,double[]> setTargetsUsingHeuristic(HashMap<Integer,ArrayList<Integer>> labeledFeatures, int numLabels, double majorityProb) { HashMap<Integer,double[]> constraints = new HashMap<Integer,double[]>(); Iterator<Integer> keyIter = labeledFeatures.keySet().iterator(); while (keyIter.hasNext()) { int fi = keyIter.next(); ArrayList<Integer> labels = labeledFeatures.get(fi); constraints.put(fi, getHeuristicPrior(labels,numLabels,majorityProb)); } return constraints; }
/** * Set target distributions using "Schapire" heuristic described in * "Learning from Labeled Features using Generalized Expectation Criteria" * Gregory Druck, Gideon Mann, Andrew McCallum. * * @param labeledFeatures HashMap of feature indices to lists of label indices for that feature. * @param numLabels Total number of labels. * @param majorityProb Probability mass divided among majority labels. * @return Constraints (map of feature index to target distribution), with target * distributions set using heuristic. */ public static HashMap<Integer,double[]> setTargetsUsingHeuristic(HashMap<Integer,ArrayList<Integer>> labeledFeatures, int numLabels, double majorityProb) { HashMap<Integer,double[]> constraints = new HashMap<Integer,double[]>(); Iterator<Integer> keyIter = labeledFeatures.keySet().iterator(); while (keyIter.hasNext()) { int fi = keyIter.next(); ArrayList<Integer> labels = labeledFeatures.get(fi); constraints.put(fi, getHeuristicPrior(labels,numLabels,majorityProb)); } return constraints; }