本文整理汇总了Java中org.jpmml.converter.mining.MiningModelUtil类的典型用法代码示例。如果您正苦于以下问题:Java MiningModelUtil类的具体用法?Java MiningModelUtil怎么用?Java MiningModelUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MiningModelUtil类属于org.jpmml.converter.mining包,在下文中一共展示了MiningModelUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: encodeMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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.mining.MiningModelUtil; //导入依赖的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.mining.MiningModelUtil; //导入依赖的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: encodeModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例5: encodeRegression
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例6: createMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例7: encodeMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例8: encodeMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例9: encodeModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
GBTRegressionModel model = getTransformer();
List<TreeModel> treeModels = TreeModelUtil.encodeDecisionTreeEnsemble(model, schema);
MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.WEIGHTED_SUM, treeModels, Doubles.asList(model.treeWeights())));
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:12,代码来源:GBTRegressionModelConverter.java
示例10: encodeModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
RandomForestRegressionModel model = getTransformer();
List<TreeModel> treeModels = TreeModelUtil.encodeDecisionTreeEnsemble(model, schema);
MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:12,代码来源:RandomForestRegressionModelConverter.java
示例11: encodeModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
RandomForestClassificationModel model = getTransformer();
List<TreeModel> treeModels = TreeModelUtil.encodeDecisionTreeEnsemble(model, schema);
MiningModel miningModel = new MiningModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(schema.getLabel()))
.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, treeModels));
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:12,代码来源:RandomForestClassificationModelConverter.java
示例12: encodeMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例13: encodeMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
@Override
public MiningModel encodeMiningModel(List<RegTree> regTrees, float base_score, Integer ntreeLimit, Schema schema){
Schema segmentSchema = schema.toAnonymousSchema();
MiningModel miningModel = createMiningModel(regTrees, base_score, ntreeLimit, segmentSchema)
.setOutput(ModelUtil.createPredictedOutput(FieldName.create("xgbValue"), OpType.CONTINUOUS, DataType.FLOAT));
return MiningModelUtil.createRegression(miningModel, getNormalizationMethod(), schema);
}
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:10,代码来源:GeneralizedLinearRegression.java
示例14: createMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例15: encodeBaseForest
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
static
public <E extends Estimator & HasEstimatorEnsemble<T> & HasTreeOptions, T extends Estimator & HasTree> MiningModel encodeBaseForest(E estimator, Segmentation.MultipleModelMethod multipleModelMethod, MiningFunction miningFunction, Schema schema){
List<TreeModel> treeModels = TreeModelUtil.encodeTreeModelSegmentation(estimator, miningFunction, schema);
MiningModel miningModel = new MiningModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()))
.setSegmentation(MiningModelUtil.createSegmentation(multipleModelMethod, treeModels));
return TreeModelUtil.transform(estimator, miningModel);
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:10,代码来源:BaseForestUtil.java
示例16: encodeGradientBoosting
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例17: encodePMML
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
@Override
public PMML encodePMML(Model model){
if(this.transformers.size() > 0){
List<Model> models = new ArrayList<>(this.transformers);
models.add(model);
Schema schema = new Schema(null, Collections.<Feature>emptyList());
model = MiningModelUtil.createModelChain(models, schema);
}
PMML pmml = super.encodePMML(model);
DataDictionary dataDictionary = pmml.getDataDictionary();
List<DataField> dataFields = dataDictionary.getDataFields();
for(DataField dataField : dataFields){
UnivariateStats univariateStats = getUnivariateStats(dataField.getName());
if(univariateStats == null){
continue;
}
ModelStats modelStats = model.getModelStats();
if(modelStats == null){
modelStats = new ModelStats();
model.setModelStats(modelStats);
}
modelStats.addUnivariateStats(univariateStats);
}
return pmml;
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:37,代码来源:SkLearnEncoder.java
示例18: encodeClassification
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的package包/类
private MiningModel encodeClassification(RGenericVector ranger, Schema schema){
RGenericVector forest = (RGenericVector)ranger.getValue("forest");
final
RStringVector levels = (RStringVector)forest.getValue("levels");
ScoreEncoder scoreEncoder = new ScoreEncoder(){
@Override
public void encode(Node node, Number splitValue, RNumberVector<?> terminalClassCount){
int index = ValueUtil.asInt(splitValue);
if(terminalClassCount != null){
throw new IllegalArgumentException();
}
node.setScore(levels.getValue(index - 1));
}
};
List<TreeModel> treeModels = encodeForest(forest, MiningFunction.CLASSIFICATION, scoreEncoder, schema);
MiningModel miningModel = new MiningModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(schema.getLabel()))
.setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.MAJORITY_VOTE, treeModels));
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:28,代码来源:RangerConverter.java
示例19: encodeBinaryClassification
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
示例20: createMiningModel
import org.jpmml.converter.mining.MiningModelUtil; //导入依赖的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
注:本文中的org.jpmml.converter.mining.MiningModelUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论