本文整理汇总了Java中org.jpmml.converter.ContinuousLabel类的典型用法代码示例。如果您正苦于以下问题:Java ContinuousLabel类的具体用法?Java ContinuousLabel怎么用?Java ContinuousLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContinuousLabel类属于org.jpmml.converter包,在下文中一共展示了ContinuousLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}