• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MiningModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createNestedOutputFields

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

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


示例3: encodeModel

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


示例4: getLastModel

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


示例5: encodeMiningModel

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


示例6: createModelChain

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


示例7: encodeModel

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


示例8: encodeModel

import org.dmg.pmml.mining.MiningModel; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	List<? extends Regressor> estimators = getEstimators();
	List<? extends Number> estimatorWeights = getEstimatorWeights();

	Schema segmentSchema = schema.toAnonymousSchema();

	List<Model> models = new ArrayList<>();

	for(Regressor estimator : estimators){
		Model model = estimator.encodeModel(segmentSchema);

		models.add(model);
	}

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(MultipleModelMethod.WEIGHTED_MEDIAN, models, estimatorWeights));

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


示例9: encodeModel

import org.dmg.pmml.mining.MiningModel; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	RGenericVector ranger = getObject();

	RStringVector treetype = (RStringVector)ranger.getValue("treetype");

	switch(treetype.asScalar()){
		case "Regression":
			return encodeRegression(ranger, schema);
		case "Classification":
			return encodeClassification(ranger, schema);
		case "Probability estimation":
			return encodeProbabilityForest(ranger, schema);
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:18,代码来源:RangerConverter.java


示例10: encodeRegression

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


示例11: encodeModel

import org.dmg.pmml.mining.MiningModel; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	RGenericVector randomForest = getObject();

	RStringVector type = (RStringVector)randomForest.getValue("type");
	RGenericVector forest = (RGenericVector)randomForest.getValue("forest");

	switch(type.asScalar()){
		case "regression":
			return encodeRegression(forest, schema);
		case "classification":
			return encodeClassification(forest, schema);
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:17,代码来源:RandomForestConverter.java


示例12: encodeMiningModel

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

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

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


    int numClasses = regTrees.size();
    for (int l=0;l<numClasses;l++){
        MiningModel miningModel = createMiningModel(regTrees.get(l), base_score, segmentSchema)
                .setOutput(ModelUtil.createPredictedOutput(FieldName.create("class_(" + categoricalLabel.getValue(l) + ")"), OpType.CONTINUOUS, DataType.FLOAT));
        miningModels.add(miningModel);
    }

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


示例13: createMiningModel

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


示例14: createModelChain

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


示例15: popParent

import org.dmg.pmml.mining.MiningModel; //导入依赖的package包/类
@Override
public PMMLObject popParent(){
	PMMLObject parent = super.popParent();

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

		processMiningModel(miningModel);
	} else

	if(parent instanceof Model){
		Model model = (Model)parent;

		processModel(model);
	}

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


示例16: getDataField

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


示例17: encodeModel

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

	Booster booster = model.booster();

	return BoosterUtil.encodeBooster(booster, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:9,代码来源:XGBoostClassificationModelConverter.java


示例18: encodeModel

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

	Booster booster = model.booster();

	return BoosterUtil.encodeBooster(booster, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:9,代码来源:XGBoostRegressionModelConverter.java


示例19: encodeBooster

import org.dmg.pmml.mining.MiningModel; //导入依赖的package包/类
static
public MiningModel encodeBooster(Booster booster, Schema schema){
	byte[] bytes = booster.toByteArray();

	Learner learner;

	try(InputStream is = new ByteArrayInputStream(bytes)){
		learner = XGBoostUtil.loadLearner(is);
	} catch(IOException ioe){
		throw new RuntimeException(ioe);
	}

	Function<Feature, Feature> function = new Function<Feature, Feature>(){

		@Override
		public Feature apply(Feature feature){

			if(feature instanceof BinaryFeature){
				BinaryFeature binaryFeature = (BinaryFeature)feature;

				return binaryFeature;
			} else

			{
				ContinuousFeature continuousFeature = feature.toContinuousFeature(DataType.FLOAT);

				return continuousFeature;
			}
		}
	};

	Schema xgbSchema = schema.toTransformedSchema(function);

	return learner.encodeMiningModel(null, false, xgbSchema);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:36,代码来源:BoosterUtil.java


示例20: encodeMiningModel

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

	MiningModel miningModel = createMiningModel(trees, numIteration, segmentSchema)
		.setOutput(ModelUtil.createPredictedOutput(FieldName.create("lgbmValue"), OpType.CONTINUOUS, DataType.DOUBLE, new SigmoidTransformation(-1d * BinomialLogisticRegression.this.sigmoid_)));

	return MiningModelUtil.createBinaryLogisticClassification(miningModel, 1d, 0d, RegressionModel.NormalizationMethod.NONE, true, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:10,代码来源:BinomialLogisticRegression.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpringProcessEngineConfiguration类代码示例发布时间:2022-05-22
下一篇:
Java XPath类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap