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


Java Schema.getFeatures方法代码示例

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


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

示例1: encodeMiningModel

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

示例5: encodeMiningModel

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

示例6: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public GeneralRegressionModel encodeModel(Schema schema){
	RGenericVector mvr = getObject();

	RDoubleVector coefficients = (RDoubleVector)mvr.getValue("coefficients");
	RDoubleVector xMeans = (RDoubleVector)mvr.getValue("Xmeans");
	RDoubleVector yMeans = (RDoubleVector)mvr.getValue("Ymeans");
	RNumberVector<?> ncomp = (RNumberVector<?>)mvr.getValue("ncomp");

	RStringVector rowNames = coefficients.dimnames(0);
	RStringVector columnNames = coefficients.dimnames(1);
	RStringVector compNames = coefficients.dimnames(2);

	int rows = rowNames.size();
	int columns = columnNames.size();
	int components = compNames.size();

	List<Feature> features = schema.getFeatures();

	List<Double> featureCoefficients = FortranMatrixUtil.getColumn(coefficients.getValues(), rows, (columns * components), 0 + (ValueUtil.asInt(ncomp.asScalar()) - 1));

	Double intercept = yMeans.getValue(0);

	for(int j = 0; j < rowNames.size(); j++){
		intercept -= (featureCoefficients.get(j) * xMeans.getValue(j));
	}

	GeneralRegressionModel generalRegressionModel = new GeneralRegressionModel(GeneralRegressionModel.ModelType.GENERALIZED_LINEAR, MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), null, null, null)
		.setLinkFunction(GeneralRegressionModel.LinkFunction.IDENTITY);

	GeneralRegressionModelUtil.encodeRegressionTable(generalRegressionModel, features, intercept, featureCoefficients, null);

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

示例7: encodeBinaryClassification

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

示例8: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public RegressionModel encodeModel(Schema schema){
	int[] shape = getCoefShape();

	int numberOfClasses = shape[0];
	int numberOfFeatures = shape[1];

	boolean hasProbabilityDistribution = hasProbabilityDistribution();

	List<? extends Number> coef = getCoef();
	List<? extends Number> intercepts = getIntercept();

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

	List<Feature> features = schema.getFeatures();

	if(numberOfClasses == 1){
		ClassifierUtil.checkSize(2, categoricalLabel);

		return RegressionModelUtil.createBinaryLogisticClassification(features, ValueUtil.asDoubles(CMatrixUtil.getRow(coef, numberOfClasses, numberOfFeatures, 0)), ValueUtil.asDouble(intercepts.get(0)), RegressionModel.NormalizationMethod.LOGIT, hasProbabilityDistribution, schema);
	} else

	if(numberOfClasses >= 3){
		ClassifierUtil.checkSize(numberOfClasses, categoricalLabel);

		List<RegressionTable> regressionTables = new ArrayList<>();

		for(int i = 0, rows = categoricalLabel.size(); i < rows; i++){
			RegressionTable regressionTable = RegressionModelUtil.createRegressionTable(features, ValueUtil.asDoubles(CMatrixUtil.getRow(coef, numberOfClasses, numberOfFeatures, i)), ValueUtil.asDouble(intercepts.get(i)))
				.setTargetCategory(categoricalLabel.getValue(i));

			regressionTables.add(regressionTable);
		}

		RegressionModel regressionModel = new RegressionModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), regressionTables)
			.setNormalizationMethod(RegressionModel.NormalizationMethod.LOGIT)
			.setOutput(hasProbabilityDistribution ? ModelUtil.createProbabilityOutput(DataType.DOUBLE, categoricalLabel) : null);

		return regressionModel;
	} else

	{
		throw new IllegalArgumentException();
	}
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:46,代码来源:BaseLinearClassifier.java

示例9: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public Model encodeModel(Schema schema){
	RGenericVector glm = getObject();

	RDoubleVector coefficients = (RDoubleVector)glm.getValue("coefficients");
	RGenericVector family = (RGenericVector)glm.getValue("family");

	Double intercept = coefficients.getValue(getInterceptName(), true);

	RStringVector familyFamily = (RStringVector)family.getValue("family");
	RStringVector familyLink = (RStringVector)family.getValue("link");

	Label label = schema.getLabel();
	List<Feature> features = schema.getFeatures();

	if(coefficients.size() != (features.size() + (intercept != null ? 1 : 0))){
		throw new IllegalArgumentException();
	}

	List<Double> featureCoefficients = getFeatureCoefficients(features, coefficients);

	MiningFunction miningFunction = getMiningFunction(familyFamily.asScalar());

	String targetCategory = null;

	switch(miningFunction){
		case CLASSIFICATION:
			{
				CategoricalLabel categoricalLabel = (CategoricalLabel)label;

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

				targetCategory = categoricalLabel.getValue(1);
			}
			break;
		default:
			break;
	}

	GeneralRegressionModel generalRegressionModel = new GeneralRegressionModel(GeneralRegressionModel.ModelType.GENERALIZED_LINEAR, miningFunction, ModelUtil.createMiningSchema(label), null, null, null)
		.setDistribution(parseFamily(familyFamily.asScalar()))
		.setLinkFunction(parseLinkFunction(familyLink.asScalar()))
		.setLinkParameter(parseLinkParameter(familyLink.asScalar()));

	GeneralRegressionModelUtil.encodeRegressionTable(generalRegressionModel, features, intercept, featureCoefficients, targetCategory);

	switch(miningFunction){
		case CLASSIFICATION:
			generalRegressionModel.setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, (CategoricalLabel)label));
			break;
		default:
			break;
	}

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

示例10: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public Model encodeModel(Schema schema){
	RGenericVector lm = getObject();

	RDoubleVector coefficients = (RDoubleVector)lm.getValue("coefficients");

	Double intercept = coefficients.getValue(getInterceptName(), true);

	List<Feature> features = schema.getFeatures();

	if(coefficients.size() != (features.size() + (intercept != null ? 1 : 0))){
		throw new IllegalArgumentException();
	}

	List<Double> featureCoefficients = getFeatureCoefficients(features, coefficients);

	return RegressionModelUtil.createRegression(features, featureCoefficients, intercept, null, schema);
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:19,代码来源:LMConverter.java

示例11: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public GeneralRegressionModel encodeModel(Schema schema){
	RGenericVector earth = getObject();

	RDoubleVector coefficients = (RDoubleVector)earth.getValue("coefficients");

	Double intercept = coefficients.getValue(0);

	List<Feature> features = schema.getFeatures();

	if(coefficients.size() != (features.size() + 1)){
		throw new IllegalArgumentException();
	}

	List<Double> featureCoefficients = (coefficients.getValues()).subList(1, features.size() + 1);

	GeneralRegressionModel generalRegressionModel = new GeneralRegressionModel(GeneralRegressionModel.ModelType.GENERALIZED_LINEAR, MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), null, null, null)
		.setLinkFunction(GeneralRegressionModel.LinkFunction.IDENTITY);

	GeneralRegressionModelUtil.encodeRegressionTable(generalRegressionModel, features, intercept, featureCoefficients, null);

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

示例12: encodeMultinomialClassification

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

示例13: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的package包/类
@Override
public Model encodeModel(Schema schema){
	RGenericVector lrm = getObject();

	RDoubleVector coefficients = (RDoubleVector)lrm.getValue("coefficients");

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

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

	String targetCategory = categoricalLabel.getValue(1);

	Double intercept = coefficients.getValue(getInterceptName(), true);

	List<Feature> features = schema.getFeatures();

	if(coefficients.size() != (features.size() + (intercept != null ? 1 : 0))){
		throw new IllegalArgumentException();
	}

	List<Double> featureCoefficients = getFeatureCoefficients(features, coefficients);

	GeneralRegressionModel generalRegressionModel = new GeneralRegressionModel(GeneralRegressionModel.ModelType.GENERALIZED_LINEAR, MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), null, null, null)
		.setLinkFunction(GeneralRegressionModel.LinkFunction.LOGIT)
		.setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, categoricalLabel));

	GeneralRegressionModelUtil.encodeRegressionTable(generalRegressionModel, features, intercept, featureCoefficients, targetCategory);

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

示例14: encodeModel

import org.jpmml.converter.Schema; //导入方法依赖的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.Schema.getFeatures方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。