当前位置: 首页>>代码示例>>Java>>正文


Java FieldName类代码示例

本文整理汇总了Java中org.dmg.pmml.FieldName的典型用法代码示例。如果您正苦于以下问题:Java FieldName类的具体用法?Java FieldName怎么用?Java FieldName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FieldName类属于org.dmg.pmml包,在下文中一共展示了FieldName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encodeMiningModel

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Override
public MiningModel encodeMiningModel(List<Tree> trees, Integer numIteration, Schema schema){
	Schema segmentSchema = new Schema(new ContinuousLabel(null, DataType.DOUBLE), schema.getFeatures());

	List<MiningModel> miningModels = new ArrayList<>();

	CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();

	for(int i = 0, rows = categoricalLabel.size(), columns = (trees.size() / rows); i < rows; i++){
		MiningModel miningModel = createMiningModel(FortranMatrixUtil.getRow(trees, rows, columns, i), numIteration, segmentSchema)
			.setOutput(ModelUtil.createPredictedOutput(FieldName.create("lgbmValue(" + categoricalLabel.getValue(i) + ")"), OpType.CONTINUOUS, DataType.DOUBLE));

		miningModels.add(miningModel);
	}

	return MiningModelUtil.createClassification(miningModels, RegressionModel.NormalizationMethod.SOFTMAX, true, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:18,代码来源:MultinomialLogisticRegression.java

示例2: testBuildCategoricalEncoding

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Test
public void testBuildCategoricalEncoding() {
  List<DataField> dataFields = new ArrayList<>();
  dataFields.add(new DataField(FieldName.create("foo"), OpType.CONTINUOUS, DataType.DOUBLE));
  DataField barField =
      new DataField(FieldName.create("bar"), OpType.CATEGORICAL, DataType.STRING);
  barField.addValues(new Value("b"), new Value("a"));
  dataFields.add(barField);
  DataDictionary dictionary = new DataDictionary(dataFields).setNumberOfFields(dataFields.size());
  CategoricalValueEncodings encodings = AppPMMLUtils.buildCategoricalValueEncodings(dictionary);
  assertEquals(2, encodings.getValueCount(1));
  assertEquals(0, encodings.getValueEncodingMap(1).get("b").intValue());
  assertEquals(1, encodings.getValueEncodingMap(1).get("a").intValue());
  assertEquals("b", encodings.getEncodingValueMap(1).get(0));
  assertEquals("a", encodings.getEncodingValueMap(1).get(1));
  assertEquals(Collections.singletonMap(1, 2), encodings.getCategoryCounts());
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:18,代码来源:AppPMMLUtilsTest.java

示例3: registerOutputFields

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Override
public List<OutputField> registerOutputFields(Label label, SparkMLEncoder encoder){
	T model = getTransformer();

	String predictionCol = model.getPredictionCol();

	OutputField predictedField = ModelUtil.createPredictedField(FieldName.create(predictionCol), DataType.STRING, OpType.CATEGORICAL);

	Feature feature = new Feature(encoder, predictedField.getName(), predictedField.getDataType()){

		@Override
		public ContinuousFeature toContinuousFeature(){
			throw new UnsupportedOperationException();
		}
	};

	encoder.putOnlyFeature(predictionCol, feature);

	return Collections.singletonList(predictedField);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:21,代码来源:ClusteringModelConverter.java

示例4: encodeModel

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	GBTClassificationModel model = getTransformer();

	String lossType = model.getLossType();
	switch(lossType){
		case "logistic":
			break;
		default:
			throw new IllegalArgumentException("Loss function " + lossType + " is not supported");
	}

	Schema segmentSchema = new Schema(new ContinuousLabel(null, DataType.DOUBLE), schema.getFeatures());

	List<TreeModel> treeModels = TreeModelUtil.encodeDecisionTreeEnsemble(model, segmentSchema);

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(segmentSchema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.WEIGHTED_SUM, treeModels, Doubles.asList(model.treeWeights())))
		.setOutput(ModelUtil.createPredictedOutput(FieldName.create("gbtValue"), OpType.CONTINUOUS, DataType.DOUBLE));

	return MiningModelUtil.createBinaryLogisticClassification(miningModel, 2d, 0d, RegressionModel.NormalizationMethod.LOGIT, false, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:23,代码来源:GBTClassificationModelConverter.java

示例5: encodeTreeModel

import org.dmg.pmml.FieldName; //导入依赖的package包/类
static
public TreeModel encodeTreeModel(org.apache.spark.ml.tree.Node node, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema){
	Node root = encodeNode(node, predicateManager, Collections.<FieldName, Set<String>>emptyMap(), miningFunction, schema)
		.setPredicate(new True());

	TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
		.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);

	String compact = TreeModelOptions.COMPACT;
	if(compact != null && Boolean.valueOf(compact)){
		Visitor visitor = new TreeModelCompactor();

		visitor.applyTo(treeModel);
	}

	return treeModel;
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:18,代码来源:TreeModelUtil.java

示例6: createDataField

import org.dmg.pmml.FieldName; //导入依赖的package包/类
public DataField createDataField(FieldName name){
	StructField field = this.schema.apply(name.getValue());

	org.apache.spark.sql.types.DataType sparkDataType = field.dataType();

	if(sparkDataType instanceof StringType){
		return createDataField(name, OpType.CATEGORICAL, DataType.STRING);
	} else

	if(sparkDataType instanceof IntegralType){
		return createDataField(name, OpType.CONTINUOUS, DataType.INTEGER);
	} else

	if(sparkDataType instanceof DoubleType){
		return createDataField(name, OpType.CONTINUOUS, DataType.DOUBLE);
	} else

	if(sparkDataType instanceof BooleanType){
		return createDataField(name, OpType.CATEGORICAL, DataType.BOOLEAN);
	} else

	{
		throw new IllegalArgumentException("Expected string, integral, double or boolean type, got " + sparkDataType.typeName() + " type");
	}
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:26,代码来源:SparkMLEncoder.java

示例7: showEvaluatorDialog

import org.dmg.pmml.FieldName; //导入依赖的package包/类
private void showEvaluatorDialog(Evaluator evaluator){
	List<FieldName> activeFields = getNames(evaluator.getActiveFields());
	List<FieldName> targetFields = getNames(evaluator.getTargetFields());
	List<FieldName> outputFields = getNames(evaluator.getOutputFields());

	StringBuilder sb = new StringBuilder();

	sb.append("Active fields: ").append(activeFields);
	sb.append("\n");
	sb.append("Target fields: ").append(targetFields);
	sb.append("\n");
	sb.append("Output fields: ").append(outputFields);

	TextView textView = new TextView(this);
	textView.setText(sb.toString());

	Dialog dialog = new Dialog(this);
	dialog.setContentView(textView);
	dialog.show();
}
 
开发者ID:jpmml,项目名称:jpmml-android,代码行数:21,代码来源:MainActivity.java

示例8: encodeMiningModel

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Override
public MiningModel encodeMiningModel(List<RegTree> regTrees, float base_score, Integer ntreeLimit, Schema schema){
	Schema segmentSchema = new Schema(new ContinuousLabel(null, DataType.FLOAT), schema.getFeatures());

	List<MiningModel> miningModels = new ArrayList<>();

	CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();

	for(int i = 0, columns = categoricalLabel.size(), rows = (regTrees.size() / columns); i < columns; i++){
		MiningModel miningModel = createMiningModel(CMatrixUtil.getColumn(regTrees, rows, columns, i), base_score, ntreeLimit, segmentSchema)
			.setOutput(ModelUtil.createPredictedOutput(FieldName.create("xgbValue(" + categoricalLabel.getValue(i) + ")"), OpType.CONTINUOUS, DataType.FLOAT));

		miningModels.add(miningModel);
	}

	return MiningModelUtil.createClassification(miningModels, RegressionModel.NormalizationMethod.SOFTMAX, true, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:18,代码来源:MultinomialLogisticRegression.java

示例9: run

import org.dmg.pmml.FieldName; //导入依赖的package包/类
private void run() throws Exception {
	Learner learner;

	try(InputStream is = new FileInputStream(this.modelInput)){
		learner = XGBoostUtil.loadLearner(is);
	}

	FeatureMap featureMap;

	try(InputStream is = new FileInputStream(this.fmapInput)){
		featureMap = XGBoostUtil.loadFeatureMap(is);
	}

	if(this.missingValue != null){
		featureMap.addMissingValue(this.missingValue);
	}

	PMML pmml = learner.encodePMML(this.targetName != null ? FieldName.create(this.targetName) : null, this.targetCategories, featureMap, this.ntreeLimit, this.transform);

	try(OutputStream os = new FileOutputStream(this.pmmlOutput)){
		MetroJAXBUtil.marshalPMML(pmml, os);
	}
}
 
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:24,代码来源:Main.java

示例10: createMiningSchema

import org.dmg.pmml.FieldName; //导入依赖的package包/类
static
public MiningSchema createMiningSchema(Label label){
	MiningSchema miningSchema = new MiningSchema();

	if(label != null){
		FieldName name = label.getName();

		if(name != null){
			MiningField miningField = createMiningField(name, MiningField.UsageType.TARGET);

			miningSchema.addMiningFields(miningField);
		}
	}

	return miningSchema;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:17,代码来源:ModelUtil.java

示例11: toContinuousFeature

import org.dmg.pmml.FieldName; //导入依赖的package包/类
public ContinuousFeature toContinuousFeature(DataType dataType){
	ContinuousFeature continuousFeature = toContinuousFeature();

	if((dataType).equals(continuousFeature.getDataType())){
		return continuousFeature;
	}

	PMMLEncoder encoder = ensureEncoder();

	FieldName name = FieldName.create((dataType.name()).toLowerCase() + "(" + (continuousFeature.getName()).getValue() + ")");

	DerivedField derivedField = encoder.getDerivedField(name);
	if(derivedField == null){
		derivedField = encoder.createDerivedField(name, OpType.CONTINUOUS, dataType, continuousFeature.ref());
	}

	return new ContinuousFeature(encoder, derivedField);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:19,代码来源:Feature.java

示例12: translateArithmeticExpressionChain

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Test
public void translateArithmeticExpressionChain(){
	Apply apply = (Apply)ExpressionTranslator.translateExpression("A + B - X + C");

	List<Expression> expressions = checkApply(apply, "+", Apply.class, FieldRef.class);

	Expression left = expressions.get(0);
	Expression right = expressions.get(1);

	expressions = checkApply((Apply)left, "-", Apply.class, FieldRef.class);
	checkFieldRef((FieldRef)right, FieldName.create("C"));

	left = expressions.get(0);
	right = expressions.get(1);

	expressions = checkApply((Apply)left, "+", FieldRef.class, FieldRef.class);
	checkFieldRef((FieldRef)right, FieldName.create("X"));

	left = expressions.get(0);
	right = expressions.get(1);

	checkFieldRef((FieldRef)left, FieldName.create("A"));
	checkFieldRef((FieldRef)right, FieldName.create("B"));
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:25,代码来源:ExpressionTranslatorTest.java

示例13: toContinuous

import org.dmg.pmml.FieldName; //导入依赖的package包/类
public TypeDefinitionField toContinuous(FieldName name){
	TypeDefinitionField field = getField(name);

	DataType dataType = field.getDataType();
	switch(dataType){
		case INTEGER:
		case FLOAT:
		case DOUBLE:
			break;
		default:
			throw new IllegalArgumentException("Field " + name.getValue() + " has data type " + dataType);
	}

	field.setOpType(OpType.CONTINUOUS);

	return field;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:18,代码来源:PMMLEncoder.java

示例14: resolveFeature

import org.dmg.pmml.FieldName; //导入依赖的package包/类
public Feature resolveFeature(String name){
	RExpEncoder encoder = getEncoder();

	List<String> variables = split(name);
	if(variables.size() == 1){
		return resolveFeature(FieldName.create(name));
	} else

	{
		List<Feature> variableFeatures = new ArrayList<>();

		for(String variable : variables){
			Feature variableFeature = resolveFeature(FieldName.create(variable));

			variableFeatures.add(variableFeature);
		}

		return new InteractionFeature(encoder, FieldName.create(name), DataType.DOUBLE, variableFeatures);
	}
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:21,代码来源:Formula.java

示例15: wildcardFeature

import org.dmg.pmml.FieldName; //导入依赖的package包/类
@Test
public void wildcardFeature(){
	PMMLEncoder encoder = new PMMLEncoder();

	DataField dataField = encoder.createDataField(FieldName.create("x"), OpType.CONTINUOUS, DataType.DOUBLE);

	WildcardFeature wildcard = new WildcardFeature(encoder, dataField);

	CategoricalFeature categoricalDouble = wildcard.toCategoricalFeature(Arrays.asList("1", "2", "3"));

	assertEquals(DataType.DOUBLE, categoricalDouble.getDataType());
	assertEquals(Arrays.asList("1", "2", "3"), categoricalDouble.getValues());

	assertEquals(OpType.CATEGORICAL, dataField.getOpType());
	assertEquals(DataType.DOUBLE, dataField.getDataType());
	assertEquals(Arrays.asList("1", "2", "3"), PMMLUtil.getValues(dataField));
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:18,代码来源:FeatureTest.java


注:本文中的org.dmg.pmml.FieldName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。