本文整理汇总了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();
}
}
示例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());
}
示例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;
}
示例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;
}
示例5: getMiningFunction
@Override
public MiningFunction getMiningFunction(){
GeneralizedLinearRegressionModel model = getTransformer();
String family = model.getFamily();
switch(family){
case "binomial":
return MiningFunction.CLASSIFICATION;
default:
return MiningFunction.REGRESSION;
}
}
示例6: getMiningFunction
@Override
public MiningFunction getMiningFunction(){
MiningFunction miningFunction = super.getMiningFunction();
if(miningFunction == null){
return MiningFunction.CLASSIFICATION;
}
return miningFunction;
}
示例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;
}
示例8: getMiningFunction
@Override
public MiningFunction getMiningFunction(){
return MiningFunction.CLASSIFICATION;
}
示例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);
}
示例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);
}
示例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));
}