本文整理汇总了Java中org.jpmml.converter.Schema类的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Schema类属于org.jpmml.converter包,在下文中一共展示了Schema类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: encodeTreeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public TreeModel encodeTreeModel(org.apache.spark.ml.tree.Node node, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema){
Node root = encodeNode(node, predicateManager, Collections.<FieldName, Set<String>>emptyMap(), miningFunction, schema)
.setPredicate(new True());
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
String compact = TreeModelOptions.COMPACT;
if(compact != null && Boolean.valueOf(compact)){
Visitor visitor = new TreeModelCompactor();
visitor.applyTo(treeModel);
}
return treeModel;
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:18,代码来源:TreeModelUtil.java
示例4: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public ClusteringModel encodeModel(Schema schema){
KMeansModel model = getTransformer();
List<Cluster> clusters = new ArrayList<>();
Vector[] clusterCenters = model.clusterCenters();
for(int i = 0; i < clusterCenters.length; i++){
Cluster cluster = new Cluster()
.setId(String.valueOf(i))
.setArray(PMMLUtil.createRealArray(VectorUtil.toList(clusterCenters[i])));
clusters.add(cluster);
}
ComparisonMeasure comparisonMeasure = new ComparisonMeasure(ComparisonMeasure.Kind.DISTANCE)
.setCompareFunction(CompareFunction.ABS_DIFF)
.setMeasure(new SquaredEuclidean());
return new ClusteringModel(MiningFunction.CLUSTERING, ClusteringModel.ModelClass.CENTER_BASED, clusters.size(), ModelUtil.createMiningSchema(schema.getLabel()), comparisonMeasure, ClusteringModelUtil.createClusteringFields(schema.getFeatures()), clusters);
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:22,代码来源:KMeansModelConverter.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());
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
示例6: createModelChain
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){
if(models.size() < 1){
throw new IllegalArgumentException();
}
Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);
Model lastModel = Iterables.getLast(models);
MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
.setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
.setSegmentation(segmentation);
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:18,代码来源:MiningModelUtil.java
示例7: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
List<? extends Classifier> estimators = getEstimators();
List<List<Integer>> estimatorsFeatures = getEstimatorsFeatures();
Segmentation.MultipleModelMethod multipleModelMethod = Segmentation.MultipleModelMethod.AVERAGE;
for(Classifier estimator : estimators){
if(!estimator.hasProbabilityDistribution()){
multipleModelMethod = Segmentation.MultipleModelMethod.MAJORITY_VOTE;
break;
}
}
MiningModel miningModel = BaggingUtil.encodeBagging(estimators, estimatorsFeatures, multipleModelMethod, MiningFunction.CLASSIFICATION, schema)
.setOutput(ModelUtil.createProbabilityOutput(DataType.DOUBLE, (CategoricalLabel)schema.getLabel()));
return miningModel;
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:22,代码来源:BaggingClassifier.java
示例8: encodeModel
import org.jpmml.converter.Schema; //导入依赖的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
示例9: encodeTreeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public <E extends Estimator & HasTree> TreeModel encodeTreeModel(E estimator, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema){
Tree tree = estimator.getTree();
int[] leftChildren = tree.getChildrenLeft();
int[] rightChildren = tree.getChildrenRight();
int[] features = tree.getFeature();
double[] thresholds = tree.getThreshold();
double[] values = tree.getValues();
Node root = new Node()
.setId("1")
.setPredicate(new True());
encodeNode(root, predicateManager, 0, leftChildren, rightChildren, features, thresholds, values, miningFunction, schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:22,代码来源:TreeModelUtil.java
示例10: toTreeModelSchema
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public Schema toTreeModelSchema(final DataType dataType, Schema schema){
Function<Feature, Feature> function = new Function<Feature, Feature>(){
@Override
public Feature apply(Feature feature){
if(feature instanceof BinaryFeature){
BinaryFeature binaryFeature = (BinaryFeature)feature;
return binaryFeature;
} else
{
ContinuousFeature continuousFeature = feature.toContinuousFeature(dataType);
return continuousFeature;
}
}
};
return schema.toTransformedSchema(function);
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:24,代码来源:TreeModelUtil.java
示例11: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public SupportVectorMachineModel encodeModel(Schema schema){
int[] shape = getSupportVectorsShape();
int numberOfVectors = shape[0];
int numberOfFeatures = shape[1];
List<Integer> support = getSupport();
List<? extends Number> supportVectors = getSupportVectors();
List<? extends Number> dualCoef = getDualCoef();
List<? extends Number> intercept = getIntercept();
SupportVectorMachineModel supportVectorMachineModel = LibSVMUtil.createRegression(new CMatrix<>(ValueUtil.asDoubles(supportVectors), numberOfVectors, numberOfFeatures), SupportVectorMachineUtil.formatIds(support), ValueUtil.asDouble(Iterables.getOnlyElement(intercept)), ValueUtil.asDoubles(dualCoef), schema)
.setKernel(SupportVectorMachineUtil.createKernel(getKernel(), getDegree(), getGamma(), getCoef0()));
return supportVectorMachineModel;
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:18,代码来源:BaseLibSVMRegressor.java
示例12: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
RGenericVector ranger = getObject();
RStringVector treetype = (RStringVector)ranger.getValue("treetype");
switch(treetype.asScalar()){
case "Regression":
return encodeRegression(ranger, schema);
case "Classification":
return encodeClassification(ranger, schema);
case "Probability estimation":
return encodeProbabilityForest(ranger, schema);
default:
throw new IllegalArgumentException();
}
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:18,代码来源:RangerConverter.java
示例13: encodeRegression
import org.jpmml.converter.Schema; //导入依赖的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
示例14: encodeForest
import org.jpmml.converter.Schema; //导入依赖的package包/类
private List<TreeModel> encodeForest(RGenericVector forest, MiningFunction miningFunction, ScoreEncoder scoreEncoder, Schema schema){
RNumberVector<?> numTrees = (RNumberVector<?>)forest.getValue("num.trees");
RGenericVector childNodeIDs = (RGenericVector)forest.getValue("child.nodeIDs");
RGenericVector splitVarIDs = (RGenericVector)forest.getValue("split.varIDs");
RGenericVector splitValues = (RGenericVector)forest.getValue("split.values");
RGenericVector terminalClassCounts = (RGenericVector)forest.getValue("terminal.class.counts", true);
Schema segmentSchema = schema.toAnonymousSchema();
List<TreeModel> treeModels = new ArrayList<>();
for(int i = 0; i < ValueUtil.asInt(numTrees.asScalar()); i++){
TreeModel treeModel = encodeTreeModel(miningFunction, scoreEncoder, (RGenericVector)childNodeIDs.getValue(i), (RNumberVector<?>)splitVarIDs.getValue(i), (RNumberVector<?>)splitValues.getValue(i), (terminalClassCounts != null ? (RGenericVector)terminalClassCounts.getValue(i) : null), segmentSchema);
treeModels.add(treeModel);
}
return treeModels;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:20,代码来源:RangerConverter.java
示例15: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
RGenericVector randomForest = getObject();
RStringVector type = (RStringVector)randomForest.getValue("type");
RGenericVector forest = (RGenericVector)randomForest.getValue("forest");
switch(type.asScalar()){
case "regression":
return encodeRegression(forest, schema);
case "classification":
return encodeClassification(forest, schema);
default:
throw new IllegalArgumentException();
}
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:17,代码来源:RandomForestConverter.java
示例16: filter
import org.jpmml.converter.Schema; //导入依赖的package包/类
private Schema filter(Schema schema){
Function<Feature, Feature> function = new Function<Feature, Feature>(){
@Override
public Feature apply(Feature feature){
Expression expression = encodeExpression(feature);
if(expression == null){
return feature;
}
DerivedField derivedField = createDerivedField(FeatureUtil.createName("preProcess", feature), OpType.CONTINUOUS, DataType.DOUBLE, expression);
return new ContinuousFeature(PreProcessEncoder.this, derivedField);
}
};
return schema.toTransformedSchema(function);
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:20,代码来源:PreProcessEncoder.java
示例17: createModelChain
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){
if(models.size() < 1){
throw new IllegalArgumentException();
}
Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);
Model lastModel = Iterables.getLast(models);
MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
.setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
.setSegmentation(segmentation);
return miningModel;
}
开发者ID:cheng-li,项目名称:pyramid,代码行数:18,代码来源:MiningModelUtil.java
示例18: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
XGBoostClassificationModel model = (XGBoostClassificationModel)getTransformer();
Booster booster = model.booster();
return BoosterUtil.encodeBooster(booster, schema);
}
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:9,代码来源:XGBoostClassificationModelConverter.java
示例19: encodeModel
import org.jpmml.converter.Schema; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
XGBoostRegressionModel model = (XGBoostRegressionModel)getTransformer();
Booster booster = model.booster();
return BoosterUtil.encodeBooster(booster, schema);
}
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:9,代码来源:XGBoostRegressionModelConverter.java
示例20: encodeBooster
import org.jpmml.converter.Schema; //导入依赖的package包/类
static
public MiningModel encodeBooster(Booster booster, Schema schema){
byte[] bytes = booster.toByteArray();
Learner learner;
try(InputStream is = new ByteArrayInputStream(bytes)){
learner = XGBoostUtil.loadLearner(is);
} catch(IOException ioe){
throw new RuntimeException(ioe);
}
Function<Feature, Feature> function = new Function<Feature, Feature>(){
@Override
public Feature apply(Feature feature){
if(feature instanceof BinaryFeature){
BinaryFeature binaryFeature = (BinaryFeature)feature;
return binaryFeature;
} else
{
ContinuousFeature continuousFeature = feature.toContinuousFeature(DataType.FLOAT);
return continuousFeature;
}
}
};
Schema xgbSchema = schema.toTransformedSchema(function);
return learner.encodeMiningModel(null, false, xgbSchema);
}
开发者ID:jpmml,项目名称:jpmml-sparkml-xgboost,代码行数:36,代码来源:BoosterUtil.java
注:本文中的org.jpmml.converter.Schema类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论