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

Java ContinuousLabel类代码示例

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

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



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

示例1: encodeMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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: encodeModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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: encodeMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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


示例4: createRegressionNeuralOutputs

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
public NeuralOutputs createRegressionNeuralOutputs(List<? extends Entity> entities, ContinuousLabel continuousLabel){

	if(entities.size() != 1){
		throw new IllegalArgumentException();
	}

	Entity entity = Iterables.getOnlyElement(entities);

	DerivedField derivedField = new DerivedField(OpType.CONTINUOUS, continuousLabel.getDataType())
		.setExpression(new FieldRef(continuousLabel.getName()));

	NeuralOutput neuralOutput = new NeuralOutput()
		.setOutputNeuron(entity.getId())
		.setDerivedField(derivedField);

	NeuralOutputs neuralOutputs = new NeuralOutputs()
		.addNeuralOutputs(neuralOutput);

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


示例5: encodeMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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


示例6: encodeLabel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public Label encodeLabel(FieldName targetField, List<String> targetCategories, PMMLEncoder encoder){

	if(targetCategories != null){
		throw new IllegalArgumentException();
	}

	DataField dataField = encoder.createDataField(targetField, OpType.CONTINUOUS, DataType.DOUBLE);

	return new ContinuousLabel(dataField);
}
 
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:12,代码来源:Regression.java


示例7: encodeModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public RegressionModel encodeModel(TensorFlowEncoder encoder){
	DataField dataField = encoder.createDataField(FieldName.create("_target"), OpType.CONTINUOUS, DataType.FLOAT);

	Label label = new ContinuousLabel(dataField);

	RegressionModel regressionModel = encodeRegressionModel(encoder)
		.setMiningFunction(MiningFunction.REGRESSION)
		.setMiningSchema(ModelUtil.createMiningSchema(label));

	return regressionModel;
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:13,代码来源:LinearRegressor.java


示例8: encodeMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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());

	MiningModel miningModel = createMiningModel(regTrees, base_score, ntreeLimit, segmentSchema)
		.setOutput(ModelUtil.createPredictedOutput(FieldName.create("xgbValue"), OpType.CONTINUOUS, DataType.FLOAT));

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


示例9: encodeLabel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public Label encodeLabel(FieldName targetField, List<String> targetCategories, PMMLEncoder encoder){

	if(targetCategories != null){
		throw new IllegalArgumentException();
	}

	DataField dataField = encoder.createDataField(targetField, OpType.CONTINUOUS, DataType.FLOAT);

	return new ContinuousLabel(dataField);
}
 
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:12,代码来源:Regression.java


示例10: createMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的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


示例11: createRegression

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
public RegressionModel createRegression(MathContext mathContext, List<? extends Feature> features, List<Double> coefficients, Double intercept, RegressionModel.NormalizationMethod normalizationMethod, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	if(normalizationMethod != null){

		switch(normalizationMethod){
			case NONE:
			case SOFTMAX:
			case LOGIT:
			case PROBIT:
			case CLOGLOG:
			case EXP:
			case LOGLOG:
			case CAUCHIT:
				break;
			default:
				throw new IllegalArgumentException();
		}
	}

	RegressionModel regressionModel = new RegressionModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel), null)
		.setNormalizationMethod(normalizationMethod)
		.setMathContext(ModelUtil.simplifyMathContext(mathContext))
		.addRegressionTables(createRegressionTable(features, coefficients, intercept));

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


示例12: encodeGradientBoosting

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
public <E extends Estimator & HasEstimatorEnsemble<DecisionTreeRegressor> & HasTreeOptions> MiningModel encodeGradientBoosting(E estimator, Number initialPrediction, Number learningRate, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	List<TreeModel> treeModels = TreeModelUtil.encodeTreeModelSegmentation(estimator, MiningFunction.REGRESSION, schema);

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.SUM, treeModels))
		.setTargets(ModelUtil.createRescaleTargets(learningRate, initialPrediction, continuousLabel));

	return TreeModelUtil.transform(estimator, miningModel);
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:13,代码来源:GradientBoostingUtil.java


示例13: encodeBinaryClassification

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
private MiningModel encodeBinaryClassification(List<TreeModel> treeModels, Double initF, double coefficient, Schema schema){
	Schema segmentSchema = new Schema(new ContinuousLabel(null, DataType.DOUBLE), schema.getFeatures());

	MiningModel miningModel = createMiningModel(treeModels, initF, segmentSchema)
		.setOutput(ModelUtil.createPredictedOutput(FieldName.create("gbmValue"), OpType.CONTINUOUS, DataType.DOUBLE));

	return MiningModelUtil.createBinaryLogisticClassification(miningModel, -coefficient, 0d, RegressionModel.NormalizationMethod.LOGIT, true, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:9,代码来源:GBMConverter.java


示例14: createMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
private MiningModel createMiningModel(List<TreeModel> treeModels, Double initF, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.SUM, treeModels))
		.setTargets(ModelUtil.createRescaleTargets(null, initF, continuousLabel));

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


示例15: encodeModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public NeuralNetwork encodeModel(TensorFlowEncoder encoder){
	DataField dataField = encoder.createDataField(FieldName.create("_target"), OpType.CONTINUOUS, DataType.FLOAT);

	NeuralNetwork neuralNetwork = encodeNeuralNetwork(encoder);

	List<NeuralLayer> neuralLayers = neuralNetwork.getNeuralLayers();

	NeuralLayer neuralLayer = Iterables.getLast(neuralLayers);

	neuralLayer.setActivationFunction(NeuralNetwork.ActivationFunction.IDENTITY);

	List<Neuron> neurons = neuralLayer.getNeurons();

	ContinuousLabel continuousLabel = new ContinuousLabel(dataField);

	neuralNetwork
		.setMiningFunction(MiningFunction.REGRESSION)
		.setMiningSchema(ModelUtil.createMiningSchema(continuousLabel))
		.setNeuralOutputs(NeuralNetworkUtil.createRegressionNeuralOutputs(neurons, continuousLabel));

	return neuralNetwork;
}
 
开发者ID:jpmml,项目名称:jpmml-tensorflow,代码行数:24,代码来源:DNNRegressor.java


示例16: encodeModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public SupportVectorMachineModel encodeModel(Schema schema){
	RGenericVector svm = getObject();

	RDoubleVector type = (RDoubleVector)svm.getValue("type");
	RDoubleVector kernel = (RDoubleVector)svm.getValue("kernel");
	RDoubleVector degree = (RDoubleVector)svm.getValue("degree");
	RDoubleVector gamma = (RDoubleVector)svm.getValue("gamma");
	RDoubleVector coef0 = (RDoubleVector)svm.getValue("coef0");
	RGenericVector yScale = (RGenericVector)svm.getValue("y.scale");
	RIntegerVector nSv = (RIntegerVector)svm.getValue("nSV");
	RDoubleVector sv = (RDoubleVector)svm.getValue("SV");
	RDoubleVector rho = (RDoubleVector)svm.getValue("rho");
	RDoubleVector coefs = (RDoubleVector)svm.getValue("coefs");

	Type svmType = Type.values()[ValueUtil.asInt(type.asScalar())];
	Kernel svmKernel = Kernel.values()[ValueUtil.asInt(kernel.asScalar())];

	SupportVectorMachineModel supportVectorMachineModel;

	switch(svmType){
		case C_CLASSIFICATION:
		case NU_CLASSIFICATION:
			{
				supportVectorMachineModel = encodeClassification(sv, nSv, rho, coefs, schema);
			}
			break;
		case ONE_CLASSIFICATION:
			{
				Transformation outlier = new OutlierTransformation(){

					@Override
					public Expression createExpression(FieldRef fieldRef){
						return PMMLUtil.createApply("lessOrEqual", fieldRef, PMMLUtil.createConstant(0d));
					}
				};

				supportVectorMachineModel = encodeRegression(sv, rho, coefs, schema)
					.setOutput(ModelUtil.createPredictedOutput(FieldName.create("decisionFunction"), OpType.CONTINUOUS, DataType.DOUBLE, outlier));

				if(yScale != null && yScale.size() > 0){
					throw new IllegalArgumentException();
				}
			}
			break;
		case EPS_REGRESSION:
		case NU_REGRESSION:
			{
				supportVectorMachineModel = encodeRegression(sv, rho, coefs, schema);

				if(yScale != null && yScale.size() > 0){
					RDoubleVector yScaledCenter = (RDoubleVector)yScale.getValue("scaled:center");
					RDoubleVector yScaledScale = (RDoubleVector)yScale.getValue("scaled:scale");

					supportVectorMachineModel.setTargets(ModelUtil.createRescaleTargets(-1d * yScaledScale.asScalar(), yScaledCenter.asScalar(), (ContinuousLabel)schema.getLabel()));
				}
			}
			break;
		default:
			throw new IllegalArgumentException();
	}

	supportVectorMachineModel.setKernel(svmKernel.createKernel(degree.asScalar(), gamma.asScalar(), coef0.asScalar()));

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


示例17: encodeMultinomialClassification

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
private MiningModel encodeMultinomialClassification(List<TreeModel> treeModels, Double initF, Schema schema){
	CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();

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

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

	for(int i = 0, columns = categoricalLabel.size(), rows = (treeModels.size() / columns); i < columns; i++){
		MiningModel miningModel = createMiningModel(CMatrixUtil.getColumn(treeModels, rows, columns, i), initF, segmentSchema)
			.setOutput(ModelUtil.createPredictedOutput(FieldName.create("gbmValue(" + categoricalLabel.getValue(i) + ")"), OpType.CONTINUOUS, DataType.DOUBLE));

		miningModels.add(miningModel);
	}

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


示例18: createMiningModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
protected MiningModel createMiningModel(List<Tree> trees, Integer numIteration, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	Schema segmentSchema = schema.toAnonymousSchema();

	PredicateManager predicateManager = new PredicateManager();

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

	if(numIteration != null){

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

		trees = trees.subList(0, numIteration);
	}

	for(Tree tree : trees){
		TreeModel treeModel = tree.encodeTreeModel(predicateManager, segmentSchema);

		treeModels.add(treeModel);
	}

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel))
		.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.SUM, treeModels));

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


示例19: createRegression

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
static
public SupportVectorMachineModel createRegression(Matrix<Double> sv, List<String> ids, Double rho, List<Double> coefs, Schema schema){
	ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel();

	VectorDictionary vectorDictionary = LibSVMUtil.createVectorDictionary(sv, ids, schema);

	List<VectorInstance> vectorInstances = vectorDictionary.getVectorInstances();

	List<SupportVectorMachine> supportVectorMachines = new ArrayList<>();
	supportVectorMachines.add(LibSVMUtil.createSupportVectorMachine(vectorInstances, rho, coefs));

	SupportVectorMachineModel supportVectorMachineModel = new SupportVectorMachineModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel), vectorDictionary, supportVectorMachines);

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


示例20: encodeModel

import org.jpmml.converter.ContinuousLabel; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	RGenericVector gbm = getObject();

	RDoubleVector initF = (RDoubleVector)gbm.getValue("initF");
	RGenericVector trees = (RGenericVector)gbm.getValue("trees");
	RGenericVector c_splits = (RGenericVector)gbm.getValue("c.splits");
	RGenericVector distribution = (RGenericVector)gbm.getValue("distribution");

	RStringVector distributionName = (RStringVector)distribution.getValue("name");

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

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

	for(int i = 0; i < trees.size(); i++){
		RGenericVector tree = (RGenericVector)trees.getValue(i);

		TreeModel treeModel = encodeTreeModel(MiningFunction.REGRESSION, tree, c_splits, segmentSchema);

		treeModels.add(treeModel);
	}

	MiningModel miningModel = encodeMiningModel(distributionName, treeModels, initF.asScalar(), schema);

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ElasticSearchIndexRequestBuilderFactory类代码示例发布时间:2022-05-22
下一篇:
Java MUCInitialPresence类代码示例发布时间: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