public void addMissingValue(String value){ addValue(Value.Property.MISSING, value); }
public void addEntry(Entry entry){ List<Entry> entries = getEntries(); entries.add(entry); }
static public FeatureMap loadFeatureMap(InputStream is) throws IOException { FeatureMap featureMap = new FeatureMap(); Iterator<String> lines = parseFeatureMap(is); for(int i = 0; lines.hasNext(); i++){ String line = lines.next(); StringTokenizer st = new StringTokenizer(line, "\t"); if(st.countTokens() != 3){ throw new IllegalArgumentException(line); } String id = st.nextToken(); String name = st.nextToken(); String type = st.nextToken(); if(Integer.parseInt(id) != i){ throw new IllegalArgumentException(id); } featureMap.addEntry(name, type); } return featureMap; }
featureMap.addMissingValue(ValueUtil.formatValue(missing.asScalar())); List<Feature> features = featureMap.encodeFeatures(encoder);
public PMML encodePMML(FieldName targetField, List<String> targetCategories, FeatureMap featureMap, Map<String, ?> options){ XGBoostEncoder encoder = new XGBoostEncoder(); if(targetField == null){ targetField = FieldName.create("_target"); } Label label = this.obj.encodeLabel(targetField, targetCategories, encoder); List<Feature> features = featureMap.encodeFeatures(encoder); Schema schema = new Schema(label, features); MiningModel miningModel = encodeMiningModel(options, schema); PMML pmml = encoder.encodePMML(miningModel); return pmml; }
public void addEntry(String name, String type){ String value = null; if(("i").equals(type)){ int equals = name.indexOf('='); if(equals < 0){ throw new IllegalArgumentException(name); } value = name.substring(equals + 1); name = name.substring(0, equals); } Entry entry = new Entry(name, value, type); addEntry(entry); }
private void run() throws Exception { Learner learner; ByteOrder byteOrder = ByteOrderUtil.forValue(this.byteOrder); try(InputStream is = new FileInputStream(this.modelInput)){ learner = XGBoostUtil.loadLearner(is, byteOrder, this.charset); } FeatureMap featureMap; try(InputStream is = new FileInputStream(this.fmapInput)){ featureMap = XGBoostUtil.loadFeatureMap(is); } if(this.missingValue != null){ featureMap.addMissingValue(this.missingValue); } Map<String, Object> options = new LinkedHashMap<>(); options.put(HasXGBoostOptions.OPTION_COMPACT, this.compact); options.put(HasXGBoostOptions.OPTION_NTREE_LIMIT, this.ntreeLimit); PMML pmml = learner.encodePMML(this.targetName != null ? FieldName.create(this.targetName) : null, this.targetCategories, featureMap, options); try(OutputStream os = new FileOutputStream(this.pmmlOutput)){ MetroJAXBUtil.marshalPMML(pmml, os); } } }
static public FeatureMap loadFeatureMap(InputStream is) throws IOException { FeatureMap featureMap = new FeatureMap(); Iterator<String> lines = parseFeatureMap(is); for(int i = 0; lines.hasNext(); i++){ String line = lines.next(); StringTokenizer st = new StringTokenizer(line, "\t"); if(st.countTokens() != 3){ throw new IllegalArgumentException(line); } String id = st.nextToken(); String name = st.nextToken(); String type = st.nextToken(); if(Integer.parseInt(id) != i){ throw new IllegalArgumentException(id); } featureMap.addEntry(name, type); } return featureMap; }
public PMML encodePMML(FieldName targetField, List<String> targetCategories, FeatureMap featureMap, Map<String, ?> options){ XGBoostEncoder encoder = new XGBoostEncoder(); if(targetField == null){ targetField = FieldName.create("_target"); } Label label = this.obj.encodeLabel(targetField, targetCategories, encoder); List<Feature> features = featureMap.encodeFeatures(encoder); Schema schema = new Schema(label, features); MiningModel miningModel = encodeMiningModel(options, schema); PMML pmml = encoder.encodePMML(miningModel); return pmml; }
public void addEntry(String name, String type){ String value = null; if(("i").equals(type)){ int equals = name.indexOf('='); if(equals < 0){ throw new IllegalArgumentException(name); } value = name.substring(equals + 1); name = name.substring(0, equals); } Entry entry = new Entry(name, value, type); addEntry(entry); }
private void run() throws Exception { Learner learner; ByteOrder byteOrder = ByteOrderUtil.forValue(this.byteOrder); try(InputStream is = new FileInputStream(this.modelInput)){ learner = XGBoostUtil.loadLearner(is, byteOrder, this.charset); } FeatureMap featureMap; try(InputStream is = new FileInputStream(this.fmapInput)){ featureMap = XGBoostUtil.loadFeatureMap(is); } if(this.missingValue != null){ featureMap.addMissingValue(this.missingValue); } Map<String, Object> options = new LinkedHashMap<>(); options.put(HasXGBoostOptions.OPTION_COMPACT, this.compact); options.put(HasXGBoostOptions.OPTION_NTREE_LIMIT, this.ntreeLimit); PMML pmml = learner.encodePMML(this.targetName != null ? FieldName.create(this.targetName) : null, this.targetCategories, featureMap, options); try(OutputStream os = new FileOutputStream(this.pmmlOutput)){ MetroJAXBUtil.marshalPMML(pmml, os); } } }
static private FeatureMap loadFeatureMap(RGenericVector fmap){ RIntegerVector id = (RIntegerVector)fmap.getValue(0); RIntegerVector name = (RIntegerVector)fmap.getValue(1); RIntegerVector type = (RIntegerVector)fmap.getValue(2); if(!name.isFactor() || !type.isFactor()){ throw new IllegalArgumentException(); } FeatureMap featureMap = new FeatureMap(); for(int i = 0; i < id.size(); i++){ if(i != id.getValue(i)){ throw new IllegalArgumentException(); } featureMap.addEntry(name.getFactorValue(i), type.getFactorValue(i)); } return featureMap; }
public void addValidValue(String value){ addValue(Value.Property.VALID, value); }
public void addEntry(Entry entry){ List<Entry> entries = getEntries(); entries.add(entry); }
public void addInvalidValue(String value){ addValue(Value.Property.INVALID, value); }
List<Entry> entries = getEntries(); for(Entry entry : entries){ FieldName name = FieldName.create(entry.getName());
public void addInvalidValue(String value){ addValue(Value.Property.INVALID, value); }
List<Entry> entries = getEntries(); for(Entry entry : entries){ FieldName name = FieldName.create(entry.getName());
public void addMissingValue(String value){ addValue(Value.Property.MISSING, value); }
public void addValidValue(String value){ addValue(Value.Property.VALID, value); }