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


Java Segmentation类代码示例

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


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

示例1: createNestedOutputFields

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
private List<OutputField> createNestedOutputFields(){
	MiningModel miningModel = getModel();

	Segmentation segmentation = miningModel.getSegmentation();

	List<Segment> segments = segmentation.getSegments();

	Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
	switch(multipleModelMethod){
		case SELECT_ALL:
			// Ignored
			break;
		case SELECT_FIRST:
			return createNestedOutputFields(getActiveHead(segments));
		case MODEL_CHAIN:
			return createNestedOutputFields(getActiveTail(segments));
		default:
			break;
	}

	return Collections.emptyList();
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:23,代码来源:MiningModelEvaluator.java

示例2: encodeModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的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

示例3: getLastModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
protected org.dmg.pmml.Model getLastModel(org.dmg.pmml.Model model){

		if(model instanceof MiningModel){
			MiningModel miningModel = (MiningModel)model;

			Segmentation segmentation = miningModel.getSegmentation();

			MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
			switch(multipleModelMethod){
				case MODEL_CHAIN:
					List<Segment> segments = segmentation.getSegments();

					if(segments.size() > 0){
						Segment lastSegment = segments.get(segments.size() - 1);

						return lastSegment.getModel();
					}
					break;
				default:
					break;
			}
		}

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

示例4: createModelChain

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){

	if(models.size() < 1){
		throw new IllegalArgumentException();
	}

	Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);

	Model lastModel = Iterables.getLast(models);

	MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
		.setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
		.setSegmentation(segmentation);

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

示例5: encodeModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	List<? extends Classifier> estimators = getEstimators();
	List<List<Integer>> estimatorsFeatures = getEstimatorsFeatures();

	Segmentation.MultipleModelMethod multipleModelMethod = Segmentation.MultipleModelMethod.AVERAGE;

	for(Classifier estimator : estimators){

		if(!estimator.hasProbabilityDistribution()){
			multipleModelMethod = Segmentation.MultipleModelMethod.MAJORITY_VOTE;

			break;
		}
	}

	MiningModel miningModel = BaggingUtil.encodeBagging(estimators, estimatorsFeatures, multipleModelMethod, MiningFunction.CLASSIFICATION, schema)
		.setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, (CategoricalLabel)schema.getLabel()));

	return miningModel;
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:22,代码来源:BaggingClassifier.java

示例6: encodeRegression

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
private MiningModel encodeRegression(RGenericVector ranger, Schema schema){
	RGenericVector forest = (RGenericVector)ranger.getValue("forest");

	ScoreEncoder scoreEncoder = new ScoreEncoder(){

		@Override
		public void encode(Node node, Number splitValue, RNumberVector<?> terminalClassCount){
			node.setScore(ValueUtil.formatValue(splitValue));
		}
	};

	List<TreeModel> treeModels = encodeForest(forest, MiningFunction.REGRESSION, scoreEncoder, schema);

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));

	return miningModel;
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:19,代码来源:RangerConverter.java

示例7: createMiningModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
static
protected MiningModel createMiningModel(List<RegressionTree> regTrees, float base_score, Schema schema){
    ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

    Schema segmentSchema = schema.toAnonymousSchema();

    List<TreeModel> treeModels = new ArrayList<>();

    for(RegressionTree regTree : regTrees){
        TreeModel treeModel = regTree.encodeTreeModel(segmentSchema);

        treeModels.add(treeModel);
    }

    MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel))
            .setMathContext(MathContext.FLOAT)
            .setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.SUM, treeModels))
            .setTargets(ModelUtil.createRescaleTargets(null, ValueUtil.floatToDouble(base_score), continuousLabel));

    return miningModel;
}
 
开发者ID:cheng-li,项目名称:pyramid,代码行数:22,代码来源:PMMLConverter.java

示例8: createModelChain

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){

    if(models.size() < 1){
        throw new IllegalArgumentException();
    }

    Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);

    Model lastModel = Iterables.getLast(models);

    MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
            .setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
            .setSegmentation(segmentation);

    return miningModel;
}
 
开发者ID:cheng-li,项目名称:pyramid,代码行数:18,代码来源:MiningModelUtil.java

示例9: getDataField

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
@Override
protected DataField getDataField(){
	MiningModel miningModel = getModel();

	Segmentation segmentation = miningModel.getSegmentation();

	Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
	switch(multipleModelMethod){
		case SELECT_ALL:
		case SELECT_FIRST:
		case MODEL_CHAIN:
			return null;
		default:
			return super.getDataField();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:17,代码来源:MiningModelEvaluator.java

示例10: encodeModel

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

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

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.WEIGHTED_SUM, treeModels, Doubles.asList(model.treeWeights())));

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

示例11: encodeModel

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

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

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));

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

示例12: encodeModel

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

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

	MiningModel miningModel = new MiningModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));

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

示例13: createMiningModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
static
protected MiningModel createMiningModel(List<RegTree> regTrees, float base_score, Integer ntreeLimit, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	Schema segmentSchema = schema.toAnonymousSchema();

	List<TreeModel> treeModels = new ArrayList<>();

	if(ntreeLimit != null){

		if(ntreeLimit > regTrees.size()){
			throw new IllegalArgumentException("Tree limit " + ntreeLimit + " is greater than the number of trees");
		}

		regTrees = regTrees.subList(0, ntreeLimit);
	}

	for(RegTree regTree : regTrees){
		TreeModel treeModel = regTree.encodeTreeModel(segmentSchema);

		treeModels.add(treeModel);
	}

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel))
		.setMathContext(MathContext.FLOAT)
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.SUM, treeModels))
		.setTargets(ModelUtil.createRescaleTargets(null, ValueUtil.floatToDouble(base_score), continuousLabel));

	return miningModel;
}
 
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:31,代码来源:ObjFunction.java

示例14: createSegmentation

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
static
public Segmentation createSegmentation(Segmentation.MultipleModelMethod multipleModelMethod, List<? extends Model> models, List<? extends Number> weights){

	if((weights != null) && (models.size() != weights.size())){
		throw new IllegalArgumentException();
	}

	List<Segment> segments = new ArrayList<>();

	for(int i = 0; i < models.size(); i++){
		Model model = models.get(i);
		Number weight = (weights != null ? weights.get(i) : null);

		Segment segment = new Segment()
			.setId(String.valueOf(i + 1))
			.setPredicate(new True())
			.setModel(model);

		if(weight != null && !ValueUtil.isOne(weight)){
			segment.setWeight(ValueUtil.asDouble(weight));
		}

		segments.add(segment);
	}

	return new Segmentation(multipleModelMethod, segments);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:28,代码来源:MiningModelUtil.java

示例15: encodeModel

import org.dmg.pmml.mining.Segmentation; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	MiningModel miningModel = BaseForestUtil.encodeBaseForest(this, Segmentation.MultipleModelMethod.AVERAGE, MiningFunction.CLASSIFICATION, schema)
		.setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, (CategoricalLabel)schema.getLabel()));

	return miningModel;
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:8,代码来源:BaseForestClassifier.java


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