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


Java MiningFunction.CLASSIFICATION属性代码示例

本文整理汇总了Java中org.dmg.pmml.MiningFunction.CLASSIFICATION属性的典型用法代码示例。如果您正苦于以下问题:Java MiningFunction.CLASSIFICATION属性的具体用法?Java MiningFunction.CLASSIFICATION怎么用?Java MiningFunction.CLASSIFICATION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.dmg.pmml.MiningFunction的用法示例。


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

示例1: getMiningFunction

static
private MiningFunction getMiningFunction(String family){
	GeneralRegressionModel.Distribution distribution = parseFamily(family);

	switch(distribution){
		case BINOMIAL:
			return MiningFunction.CLASSIFICATION;
		case NORMAL:
		case GAMMA:
		case IGAUSS:
		case POISSON:
			return MiningFunction.REGRESSION;
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:16,代码来源:GLMConverter.java

示例2: clean

@Test
public void clean(){
	Node node = new Node()
		.setPredicate(new True())
		.setScore("1")
		.addScoreDistributions(new ScoreDistribution("0", 0), new ScoreDistribution("1", 100));

	TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node);

	ScoreDistributionCleaner cleaner = new ScoreDistributionCleaner();
	cleaner.applyTo(treeModel);

	assertTrue(node.hasScoreDistributions());

	treeModel.setMiningFunction(MiningFunction.REGRESSION);

	cleaner.applyTo(treeModel);

	assertFalse(node.hasScoreDistributions());
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:20,代码来源:ScoreDistributionCleanerTest.java

示例3: buildDummyModel

private static PMML buildDummyModel() {
  Node node = new Node().setRecordCount(123.0);
  TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node);
  PMML pmml = PMMLUtils.buildSkeletonPMML();
  pmml.addModels(treeModel);
  return pmml;
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:7,代码来源:AppPMMLUtilsTest.java

示例4: buildDummyModel

public static PMML buildDummyModel() {
  Node node = new Node().setRecordCount(123.0);
  TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node);
  PMML pmml = PMMLUtils.buildSkeletonPMML();
  pmml.addModels(treeModel);
  return pmml;
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:7,代码来源:PMMLUtilsTest.java

示例5: getMiningFunction

@Override
public MiningFunction getMiningFunction(){
	GeneralizedLinearRegressionModel model = getTransformer();

	String family = model.getFamily();
	switch(family){
		case "binomial":
			return MiningFunction.CLASSIFICATION;
		default:
			return MiningFunction.REGRESSION;
	}
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:12,代码来源:GeneralizedLinearRegressionModelConverter.java

示例6: getMiningFunction

@Override
public MiningFunction getMiningFunction(){
	MiningFunction miningFunction = super.getMiningFunction();

	if(miningFunction == null){
		return MiningFunction.CLASSIFICATION;
	}

	return miningFunction;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:10,代码来源:JavaClassifierModel.java

示例7: buildDummyClassificationModel

private static PMML buildDummyClassificationModel(int numTrees) {
  PMML pmml = PMMLUtils.buildSkeletonPMML();

  List<DataField> dataFields = new ArrayList<>();
  DataField predictor =
      new DataField(FieldName.create("color"), OpType.CATEGORICAL, DataType.STRING);
  predictor.addValues(new Value("yellow"), new Value("red"));
  dataFields.add(predictor);
  DataField target =
      new DataField(FieldName.create("fruit"), OpType.CATEGORICAL, DataType.STRING);
  target.addValues(new Value("banana"), new Value("apple"));
  dataFields.add(target);
  DataDictionary dataDictionary =
      new DataDictionary(dataFields).setNumberOfFields(dataFields.size());
  pmml.setDataDictionary(dataDictionary);

  List<MiningField> miningFields = new ArrayList<>();
  MiningField predictorMF = new MiningField(FieldName.create("color"))
      .setOpType(OpType.CATEGORICAL)
      .setUsageType(MiningField.UsageType.ACTIVE)
      .setImportance(0.5);
  miningFields.add(predictorMF);
  MiningField targetMF = new MiningField(FieldName.create("fruit"))
      .setOpType(OpType.CATEGORICAL)
      .setUsageType(MiningField.UsageType.PREDICTED);
  miningFields.add(targetMF);
  MiningSchema miningSchema = new MiningSchema(miningFields);

  double dummyCount = 2.0;
  Node rootNode = new Node().setId("r").setRecordCount(dummyCount).setPredicate(new True());

  double halfCount = dummyCount / 2;

  Node left = new Node().setId("r-").setRecordCount(halfCount).setPredicate(new True());
  left.addScoreDistributions(new ScoreDistribution("apple", halfCount));
  Node right = new Node().setId("r+").setRecordCount(halfCount)
      .setPredicate(new SimpleSetPredicate(FieldName.create("color"),
                                           SimpleSetPredicate.BooleanOperator.IS_NOT_IN,
                                           new Array(Array.Type.STRING, "red")));
  right.addScoreDistributions(new ScoreDistribution("banana", halfCount));

  rootNode.addNodes(right, left);

  TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, miningSchema, rootNode)
      .setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT)
      .setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD);

  if (numTrees > 1) {
    MiningModel miningModel = new MiningModel(MiningFunction.CLASSIFICATION, miningSchema);
    List<Segment> segments = new ArrayList<>();
    for (int i = 0; i < numTrees; i++) {
      segments.add(new Segment()
          .setId(Integer.toString(i))
          .setPredicate(new True())
          .setModel(treeModel)
          .setWeight(1.0));
    }
    miningModel.setSegmentation(
        new Segmentation(Segmentation.MultipleModelMethod.WEIGHTED_MAJORITY_VOTE, segments));
    pmml.addModels(miningModel);
  } else {
    pmml.addModels(treeModel);
  }

  return pmml;
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:66,代码来源:RDFPMMLUtilsTest.java

示例8: getMiningFunction

@Override
public MiningFunction getMiningFunction(){
	return MiningFunction.CLASSIFICATION;
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:4,代码来源:ClassificationModelConverter.java

示例9: transform

@Test
public void transform(){
	Node node1a = new Node();

	Node node2a = new Node();
	Node node2b = new Node();

	node1a.addNodes(node2a, node2b);

	Node node3a = new Node();

	node2a.addNodes(node3a);

	assertTrue(node1a.getNodes() instanceof ArrayList);
	assertTrue(node2a.getNodes() instanceof ArrayList);

	TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node1a);

	ArrayListTransformer transformer = new ArrayListTransformer();
	transformer.applyTo(treeModel);

	assertTrue(node1a.getNodes() instanceof DoubletonList);
	assertTrue(node2a.getNodes() instanceof SingletonList);
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:24,代码来源:ArrayListTransformerTest.java

示例10: encodeResponse

private void encodeResponse(S4Object responses, RExpEncoder encoder){
	RGenericVector variables = (RGenericVector)responses.getAttributeValue("variables");
	RBooleanVector is_nominal = (RBooleanVector)responses.getAttributeValue("is_nominal");
	RGenericVector levels = (RGenericVector)responses.getAttributeValue("levels");

	RStringVector variableNames = variables.names();

	String variableName = variableNames.asScalar();

	DataField dataField;

	Boolean categorical = is_nominal.getValue(variableName);
	if((Boolean.TRUE).equals(categorical)){
		this.miningFunction = MiningFunction.CLASSIFICATION;

		RExp targetVariable = variables.getValue(variableName);

		RStringVector targetVariableClass = (RStringVector)targetVariable.getAttributeValue("class");

		RStringVector targetCategories = (RStringVector)levels.getValue(variableName);

		dataField = encoder.createDataField(FieldName.create(variableName), OpType.CATEGORICAL, RExpUtil.getDataType(targetVariableClass.asScalar()), targetCategories.getValues());
	} else

	if((Boolean.FALSE).equals(categorical)){
		this.miningFunction = MiningFunction.REGRESSION;

		dataField = encoder.createDataField(FieldName.create(variableName), OpType.CONTINUOUS, DataType.DOUBLE);
	} else

	{
		throw new IllegalArgumentException();
	}

	encoder.setLabel(dataField);
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:36,代码来源:BinaryTreeConverter.java

示例11: find

@Test
public void find(){
	Node node1a = new Node();

	Node node2a = new Node();
	Node node2b = new Node();
	Node node2c = new Node();

	node1a.addNodes(node2a, node2b, node2c);

	Node node3a = new Node();
	Node node3b = new Node();

	node2b.addNodes(node3a);
	node2c.addNodes(node3b);

	Node node4a = new Node();

	node3a.addNodes(node4a);

	TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node1a);

	TreePathFinder finder = new TreePathFinder();
	finder.applyTo(treeModel);

	Map<Node, List<Node>> paths = finder.getPaths();

	assertEquals(3, paths.size());

	assertEquals(Arrays.asList(node1a, node2a), paths.get(node2a));
	assertEquals(Arrays.asList(node1a, node2b, node3a, node4a), paths.get(node4a));
	assertEquals(Arrays.asList(node1a, node2c, node3b), paths.get(node3b));
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:33,代码来源:TreePathFinderTest.java


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