本文整理汇总了Java中org.dmg.pmml.mining.MiningModel.getSegmentation方法的典型用法代码示例。如果您正苦于以下问题:Java MiningModel.getSegmentation方法的具体用法?Java MiningModel.getSegmentation怎么用?Java MiningModel.getSegmentation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.mining.MiningModel
的用法示例。
在下文中一共展示了MiningModel.getSegmentation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNestedOutputFields
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
private List<OutputField> createNestedOutputFields(){
MiningModel miningModel = getModel();
Segmentation segmentation = miningModel.getSegmentation();
List<Segment> segments = segmentation.getSegments();
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case SELECT_ALL:
// Ignored
break;
case SELECT_FIRST:
return createNestedOutputFields(getActiveHead(segments));
case MODEL_CHAIN:
return createNestedOutputFields(getActiveTail(segments));
default:
break;
}
return Collections.emptyList();
}
示例2: getLastModel
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
protected org.dmg.pmml.Model getLastModel(org.dmg.pmml.Model model){
if(model instanceof MiningModel){
MiningModel miningModel = (MiningModel)model;
Segmentation segmentation = miningModel.getSegmentation();
MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case MODEL_CHAIN:
List<Segment> segments = segmentation.getSegments();
if(segments.size() > 0){
Segment lastSegment = segments.get(segments.size() - 1);
return lastSegment.getModel();
}
break;
default:
break;
}
}
return model;
}
示例3: getDataField
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
@Override
protected DataField getDataField(){
MiningModel miningModel = getModel();
Segmentation segmentation = miningModel.getSegmentation();
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case SELECT_ALL:
case SELECT_FIRST:
case MODEL_CHAIN:
return null;
default:
return super.getDataField();
}
}
示例4: MiningModelEvaluator
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
public MiningModelEvaluator(PMML pmml, MiningModel miningModel){
super(pmml, miningModel);
if(miningModel.hasEmbeddedModels()){
List<EmbeddedModel> embeddedModels = miningModel.getEmbeddedModels();
EmbeddedModel embeddedModel = Iterables.getFirst(embeddedModels, null);
throw new UnsupportedElementException(embeddedModel);
}
Segmentation segmentation = miningModel.getSegmentation();
if(segmentation == null){
throw new MissingElementException(miningModel, PMMLElements.MININGMODEL_SEGMENTATION);
}
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
if(multipleModelMethod == null){
throw new MissingAttributeException(segmentation, PMMLAttributes.SEGMENTATION_MULTIPLEMODELMETHOD);
} // End if
if(!segmentation.hasSegments()){
throw new MissingElementException(segmentation, PMMLElements.SEGMENTATION_SEGMENTS);
}
LocalTransformations localTransformations = segmentation.getLocalTransformations();
if(localTransformations != null){
throw new UnsupportedElementException(localTransformations);
}
}
示例5: evaluateRegression
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
private <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, MiningModelEvaluationContext context){
MiningModel miningModel = getModel();
List<SegmentResult> segmentResults = evaluateSegmentation(context);
Map<FieldName, ?> predictions = getSegmentationResult(REGRESSION_METHODS, segmentResults);
if(predictions != null){
return predictions;
}
Segmentation segmentation = miningModel.getSegmentation();
Value<V> result;
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case AVERAGE:
case WEIGHTED_AVERAGE:
case MEDIAN:
case WEIGHTED_MEDIAN:
case SUM:
case WEIGHTED_SUM:
result = MiningModelUtil.aggregateValues(valueFactory, segmentResults, multipleModelMethod);
break;
case MAJORITY_VOTE:
case WEIGHTED_MAJORITY_VOTE:
case MAX:
case SELECT_FIRST:
case SELECT_ALL:
case MODEL_CHAIN:
throw new InvalidAttributeException(segmentation, multipleModelMethod);
default:
throw new UnsupportedAttributeException(segmentation, multipleModelMethod);
}
return TargetUtil.evaluateRegression(getTargetField(), result);
}
示例6: getSegmentationResult
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
private Map<FieldName, ?> getSegmentationResult(Set<Segmentation.MultipleModelMethod> multipleModelMethods, List<SegmentResult> segmentResults){
MiningModel miningModel = getModel();
Segmentation segmentation = miningModel.getSegmentation();
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case SELECT_ALL:
return selectAll(segmentResults);
case SELECT_FIRST:
if(segmentResults.size() > 0){
return segmentResults.get(0);
}
break;
case MODEL_CHAIN:
if(segmentResults.size() > 0){
return segmentResults.get(segmentResults.size() - 1);
}
break;
default:
if(!(multipleModelMethods).contains(multipleModelMethod)){
throw new UnsupportedAttributeException(segmentation, multipleModelMethod);
}
break;
}
// "If no segments have predicates that evaluate to true, then the result is a missing value"
if(segmentResults.size() == 0){
return Collections.singletonMap(getTargetFieldName(), null);
}
return null;
}
示例7: processMiningModel
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
private Set<FieldName> processMiningModel(MiningModel miningModel){
Set<Field> activeFields = DeepFieldResolverUtil.getActiveFields(this, miningModel);
Set<FieldName> activeFieldNames = new HashSet<>();
Segmentation segmentation = miningModel.getSegmentation();
List<Segment> segments = segmentation.getSegments();
for(Segment segment : segments){
Model model = segment.getModel();
if(model == null){
continue;
}
MiningSchema miningSchema = model.getMiningSchema();
List<MiningField> miningFields = miningSchema.getMiningFields();
for(MiningField miningField : miningFields){
FieldName name = miningField.getName();
MiningField.UsageType usageType = miningField.getUsageType();
switch(usageType){
case ACTIVE:
activeFieldNames.add(name);
break;
default:
break;
}
}
}
Set<Field> modelFields = getFields(miningModel);
Set<Field> activeModelFields = FieldUtil.selectAll(modelFields, activeFieldNames, true);
activeFields.addAll(activeModelFields);
expandDerivedFields(miningModel, activeFields);
return FieldUtil.nameSet(activeFields);
}
示例8: evaluateClustering
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
private <V extends Number> Map<FieldName, ?> evaluateClustering(ValueFactory<V> valueFactory, MiningModelEvaluationContext context){
MiningModel miningModel = getModel();
List<SegmentResult> segmentResults = evaluateSegmentation(context);
Map<FieldName, ?> predictions = getSegmentationResult(CLUSTERING_METHODS, segmentResults);
if(predictions != null){
return predictions;
}
Segmentation segmentation = miningModel.getSegmentation();
VoteDistribution<V> result;
Segmentation.MultipleModelMethod multipleModelMethod = segmentation.getMultipleModelMethod();
switch(multipleModelMethod){
case MAJORITY_VOTE:
case WEIGHTED_MAJORITY_VOTE:
{
ValueMap<String, V> values = MiningModelUtil.aggregateVotes(valueFactory, segmentResults, multipleModelMethod);
result = new VoteDistribution<>(values);
}
break;
case AVERAGE:
case WEIGHTED_AVERAGE:
case MEDIAN:
case WEIGHTED_MEDIAN:
case MAX:
case SUM:
case WEIGHTED_SUM:
case SELECT_FIRST:
case SELECT_ALL:
case MODEL_CHAIN:
throw new InvalidAttributeException(segmentation, multipleModelMethod);
default:
throw new UnsupportedAttributeException(segmentation, multipleModelMethod);
}
result.computeResult(DataType.STRING);
return Collections.singletonMap(getTargetFieldName(), result);
}
示例9: load
import org.dmg.pmml.mining.MiningModel; //导入方法依赖的package包/类
@Override
public BiMap<String, Segment> load(MiningModel miningModel){
Segmentation segmentation = miningModel.getSegmentation();
return EntityUtil.buildBiMap(segmentation.getSegments());
}