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


Java RegressionModel类代码示例

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


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

示例1: encodeMiningModel

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

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

示例5: marshal

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
@Test
public void marshal() throws Exception {
	RegressionModel regressionModel = new RegressionModel()
		.addRegressionTables(new RegressionTable());

	PMML pmml = new PMML(Version.PMML_4_3.getVersion(), new Header(), new DataDictionary())
		.addModels(regressionModel);

	JAXBContext context = JAXBContextFactory.createContext(new Class[]{org.dmg.pmml.ObjectFactory.class, org.dmg.pmml.regression.ObjectFactory.class}, null);

	Marshaller marshaller = context.createMarshaller();

	ByteArrayOutputStream os = new ByteArrayOutputStream();

	marshaller.marshal(pmml, os);

	String string = os.toString("UTF-8");

	assertTrue(string.contains("<PMML xmlns=\"http://www.dmg.org/PMML-4_3\" version=\"4.3\">"));
	assertTrue(string.contains("<RegressionModel>"));
	assertTrue(string.contains("</RegressionModel>"));
	assertTrue(string.contains("</PMML>"));
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:24,代码来源:MarshallerTest.java

示例6: normalizeRegressionResult

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
static
public <V extends Number> Value<V> normalizeRegressionResult(Value<V> value, RegressionModel.NormalizationMethod normalizationMethod){

	switch(normalizationMethod){
		case NONE:
			return value;
		case SOFTMAX:
		case LOGIT:
			return value.inverseLogit();
		case EXP:
			return value.exp();
		case PROBIT:
			return value.inverseProbit();
		case CLOGLOG:
			return value.inverseCloglog();
		case LOGLOG:
			return value.inverseLoglog();
		case CAUCHIT:
			return value.inverseCauchit();
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:24,代码来源:RegressionModelUtil.java

示例7: normalizeBinaryLogisticClassificationResult

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
static
public <V extends Number> Value<V> normalizeBinaryLogisticClassificationResult(Value<V> value, RegressionModel.NormalizationMethod normalizationMethod){

	switch(normalizationMethod){
		case NONE:
			return value.restrict(0d, 1d);
		case LOGIT:
			return value.inverseLogit();
		case PROBIT:
			return value.inverseProbit();
		case CLOGLOG:
			return value.inverseCloglog();
		case LOGLOG:
			return value.inverseLoglog();
		case CAUCHIT:
			return value.inverseCauchit();
		default:
			throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:21,代码来源:RegressionModelUtil.java

示例8: encodeMiningModel

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

示例9: encodeMiningModel

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
@Override
public MiningModel encodeMiningModel(List<Tree> trees, Integer numIteration, Schema schema){
	Schema segmentSchema = schema.toAnonymousSchema();

	MiningModel miningModel = super.encodeMiningModel(trees, numIteration, segmentSchema)
		.setOutput(ModelUtil.createPredictedOutput(FieldName.create("lgbmValue"), OpType.CONTINUOUS, DataType.DOUBLE));

	return MiningModelUtil.createRegression(miningModel, RegressionModel.NormalizationMethod.EXP, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:10,代码来源:PoissonRegression.java

示例10: encodeModel

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

示例11: encodeMiningModel

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

示例12: createRegression

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
static
public MiningModel createRegression(Model model, RegressionModel.NormalizationMethod normalizationMethod, Schema schema){
	Feature feature = MiningModelUtil.MODEL_PREDICTION.apply(model);

	RegressionModel regressionModel = RegressionModelUtil.createRegression(model.getMathContext(), Collections.singletonList(feature), Collections.singletonList(1d), null, normalizationMethod, schema);

	return createModelChain(Arrays.asList(model, regressionModel), schema);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:9,代码来源:MiningModelUtil.java

示例13: createBinaryLogisticClassification

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
static
public MiningModel createBinaryLogisticClassification(Model model, double coefficient, double intercept, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
	Feature feature = MiningModelUtil.MODEL_PREDICTION.apply(model);

	RegressionModel regressionModel = RegressionModelUtil.createBinaryLogisticClassification(model.getMathContext(), Collections.singletonList(feature), Collections.singletonList(coefficient), intercept, normalizationMethod, hasProbabilityDistribution, schema);

	return createModelChain(Arrays.asList(model, regressionModel), schema);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:9,代码来源:MiningModelUtil.java

示例14: createRegression

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

示例15: createBinaryLogisticClassification

import org.dmg.pmml.regression.RegressionModel; //导入依赖的package包/类
static
public RegressionModel createBinaryLogisticClassification(MathContext mathContext, List<? extends Feature> features, List<Double> coefficients, Double intercept, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
	CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();

	if(categoricalLabel.size() != 2){
		throw new IllegalArgumentException();
	} // End if

	if(normalizationMethod != null){

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

	RegressionTable activeRegressionTable = RegressionModelUtil.createRegressionTable(features, coefficients, intercept)
		.setTargetCategory(categoricalLabel.getValue(1));

	RegressionTable passiveRegressionTable = RegressionModelUtil.createRegressionTable(Collections.<Feature>emptyList(), Collections.<Double>emptyList(), null)
		.setTargetCategory(categoricalLabel.getValue(0));

	RegressionModel regressionModel = new RegressionModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), null)
		.setNormalizationMethod(normalizationMethod)
		.setMathContext(ModelUtil.simplifyMathContext(mathContext))
		.addRegressionTables(activeRegressionTable, passiveRegressionTable)
		.setOutput(hasProbabilityDistribution ? ModelUtil.createProbabilityOutput(mathContext, categoricalLabel) : null);

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


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