public PerceptronModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
public NaiveBayesModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; @SuppressWarnings("unchecked") Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
public PerceptronModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
public PerceptronModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
public NaiveBayesModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; @SuppressWarnings("unchecked") Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
public NaiveBayesModelWriter(AbstractModel model) { Object[] data = model.getDataStructures(); this.numOutcomes = model.getNumOutcomes(); PARAMS = (Context[]) data[0]; @SuppressWarnings("unchecked") Map<String, Context> pmap = (Map<String, Context>) data[1]; OUTCOME_LABELS = (String[]) data[2]; PARAMS = new Context[pmap.size()]; PRED_LABELS = new String[pmap.size()]; int i = 0; for (Map.Entry<String, Context> pred : pmap.entrySet()) { PRED_LABELS[i] = pred.getKey(); PARAMS[i] = pred.getValue(); i++; } }
protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
protected void validatePOSDictionary(POSDictionary posDict, AbstractModel posModel) throws InvalidFormatException { Set<String> dictTags = new HashSet<>(); for (String word : posDict) { Collections.addAll(dictTags, posDict.getTags(word)); } Set<String> modelTags = new HashSet<>(); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i)); } if (!modelTags.containsAll(dictTags)) { StringBuilder unknownTag = new StringBuilder(); for (String d : dictTags) { if (!modelTags.contains(d)) { unknownTag.append(d).append(" "); } } throw new InvalidFormatException("Tag dictionary contains tags " + "which are unknown by the model! The unknown tags are: " + unknownTag.toString()); } }
.getArtifact(FeaturizerModel.FEATURIZER_MODEL_ENTRY_NAME); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i));
.getArtifact(FeaturizerModel.FEATURIZER_MODEL_ENTRY_NAME); for (int i = 0; i < posModel.getNumOutcomes(); i++) { modelTags.add(posModel.getOutcome(i));