/** * @param pmml PMML representation of Clusters * @return List of {@link ClusterInfo} */ public static List<ClusterInfo> read(PMML pmml) { Model model = pmml.getModels().get(0); Preconditions.checkArgument(model instanceof ClusteringModel); ClusteringModel clusteringModel = (ClusteringModel) model; return clusteringModel.getClusters().stream().map(cluster -> new ClusterInfo(Integer.parseInt(cluster.getId()), VectorMath.parseVector(TextUtils.parseDelimited(cluster.getArray().getValue(), ' ')), cluster.getSize()) ).collect(Collectors.toList()); }
Map<String,Integer> valueEncodingMap = categoricalValueEncodings.getValueEncodingMap(featureNumber); String[] categories = TextUtils.parseDelimited(simpleSetPredicate.getArray().getValue(), ' '); BitSet activeCategories = new BitSet(valueEncodingMap.size()); if (operator == SimpleSetPredicate.BooleanOperator.IS_IN) {
@Test public void testToArrayDouble() { Array a = AppPMMLUtils.toArray(-1.0, 2.01, 3.5); assertEquals(3, a.getN().intValue()); assertEquals(Array.Type.REAL, a.getType()); assertEquals("-1.0 2.01 3.5", a.getValue()); }
Cluster cluster = clusters.get(id); String[] tokens = TextUtils.parseDelimited(cluster.getArray().getValue(), ' '); double[] modelCenter = VectorMath.parseVector(tokens);
/** * @param pmml PMML representation of Clusters * @return List of {@link ClusterInfo} */ public static List<ClusterInfo> read(PMML pmml) { Model model = pmml.getModels().get(0); Preconditions.checkArgument(model instanceof ClusteringModel); ClusteringModel clusteringModel = (ClusteringModel) model; return clusteringModel.getClusters().stream().map(cluster -> new ClusterInfo(Integer.parseInt(cluster.getId()), VectorMath.parseVector(TextUtils.parseDelimited(cluster.getArray().getValue(), ' ')), cluster.getSize()) ).collect(Collectors.toList()); }
private Predicate transform(SimpleSetPredicate simpleSetPredicate){ Array array = simpleSetPredicate.getArray(); String value = array.getValue(); List<String> tokens = ArrayUtil.parse(value, true); if(tokens.size() != 1){ return simpleSetPredicate; } value = tokens.get(0); SimpleSetPredicate.BooleanOperator booleanOperator = simpleSetPredicate.getBooleanOperator(); switch(booleanOperator){ case IS_IN: return createSimplePredicate(simpleSetPredicate.getField(), SimplePredicate.Operator.EQUAL, value); case IS_NOT_IN: return createSimplePredicate(simpleSetPredicate.getField(), SimplePredicate.Operator.NOT_EQUAL, value); default: break; } return simpleSetPredicate; }
String value = array.getValue();
Map<String,Integer> valueEncodingMap = categoricalValueEncodings.getValueEncodingMap(featureNumber); String[] categories = TextUtils.parseDelimited(simpleSetPredicate.getArray().getValue(), ' '); BitSet activeCategories = new BitSet(valueEncodingMap.size()); if (operator == SimpleSetPredicate.BooleanOperator.IS_IN) {