本文整理汇总了Java中org.dmg.pmml.regression.RegressionModel.NormalizationMethod方法的典型用法代码示例。如果您正苦于以下问题:Java RegressionModel.NormalizationMethod方法的具体用法?Java RegressionModel.NormalizationMethod怎么用?Java RegressionModel.NormalizationMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.regression.RegressionModel
的用法示例。
在下文中一共展示了RegressionModel.NormalizationMethod方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: normalizeRegressionResult
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public <V extends Number> Value<V> normalizeRegressionResult(Value<V> value, RegressionModel.NormalizationMethod normalizationMethod){
switch(normalizationMethod){
case NONE:
return value;
case SOFTMAX:
case LOGIT:
return value.inverseLogit();
case EXP:
return value.exp();
case PROBIT:
return value.inverseProbit();
case CLOGLOG:
return value.inverseCloglog();
case LOGLOG:
return value.inverseLoglog();
case CAUCHIT:
return value.inverseCauchit();
default:
throw new IllegalArgumentException();
}
}
示例2: normalizeBinaryLogisticClassificationResult
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public <V extends Number> Value<V> normalizeBinaryLogisticClassificationResult(Value<V> value, RegressionModel.NormalizationMethod normalizationMethod){
switch(normalizationMethod){
case NONE:
return value.restrict(0d, 1d);
case LOGIT:
return value.inverseLogit();
case PROBIT:
return value.inverseProbit();
case CLOGLOG:
return value.inverseCloglog();
case LOGLOG:
return value.inverseLoglog();
case CAUCHIT:
return value.inverseCauchit();
default:
throw new IllegalArgumentException();
}
}
示例3: createRegression
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public MiningModel createRegression(Model model, RegressionModel.NormalizationMethod normalizationMethod, Schema schema){
Feature feature = MiningModelUtil.MODEL_PREDICTION.apply(model);
RegressionModel regressionModel = RegressionModelUtil.createRegression(model.getMathContext(), Collections.singletonList(feature), Collections.singletonList(1d), null, normalizationMethod, schema);
return createModelChain(Arrays.asList(model, regressionModel), schema);
}
示例4: createBinaryLogisticClassification
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public MiningModel createBinaryLogisticClassification(Model model, double coefficient, double intercept, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
Feature feature = MiningModelUtil.MODEL_PREDICTION.apply(model);
RegressionModel regressionModel = RegressionModelUtil.createBinaryLogisticClassification(model.getMathContext(), Collections.singletonList(feature), Collections.singletonList(coefficient), intercept, normalizationMethod, hasProbabilityDistribution, schema);
return createModelChain(Arrays.asList(model, regressionModel), schema);
}
示例5: createRegression
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的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;
}
示例6: createBinaryLogisticClassification
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public RegressionModel createBinaryLogisticClassification(MathContext mathContext, List<? extends Feature> features, List<Double> coefficients, Double intercept, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();
if(categoricalLabel.size() != 2){
throw new IllegalArgumentException();
} // End if
if(normalizationMethod != null){
switch(normalizationMethod){
case NONE:
case LOGIT:
case PROBIT:
case CLOGLOG:
case LOGLOG:
case CAUCHIT:
break;
default:
throw new IllegalArgumentException();
}
}
RegressionTable activeRegressionTable = RegressionModelUtil.createRegressionTable(features, coefficients, intercept)
.setTargetCategory(categoricalLabel.getValue(1));
RegressionTable passiveRegressionTable = RegressionModelUtil.createRegressionTable(Collections.<Feature>emptyList(), Collections.<Double>emptyList(), null)
.setTargetCategory(categoricalLabel.getValue(0));
RegressionModel regressionModel = new RegressionModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), null)
.setNormalizationMethod(normalizationMethod)
.setMathContext(ModelUtil.simplifyMathContext(mathContext))
.addRegressionTables(activeRegressionTable, passiveRegressionTable)
.setOutput(hasProbabilityDistribution ? ModelUtil.createProbabilityOutput(mathContext, categoricalLabel) : null);
return regressionModel;
}
示例7: getNormalizationMethod
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
@Override
public RegressionModel.NormalizationMethod getNormalizationMethod(){
return RegressionModel.NormalizationMethod.LOGIT;
}
示例8: getNormalizationMethod
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
abstract
public RegressionModel.NormalizationMethod getNormalizationMethod();
示例9: getNormalizationMethod
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
@Override
public RegressionModel.NormalizationMethod getNormalizationMethod(){
return RegressionModel.NormalizationMethod.EXP;
}
示例10: createClassification
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public MiningModel createClassification(List<? extends Model> models, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();
if(categoricalLabel.size() < 3 || categoricalLabel.size() != models.size()){
throw new IllegalArgumentException();
} // End if
if(normalizationMethod != null){
switch(normalizationMethod){
case NONE:
case SIMPLEMAX:
case SOFTMAX:
break;
default:
throw new IllegalArgumentException();
}
}
MathContext mathContext = null;
List<RegressionTable> regressionTables = new ArrayList<>();
for(int i = 0; i < categoricalLabel.size(); i++){
Model model = models.get(i);
MathContext modelMathContext = model.getMathContext();
if(modelMathContext == null){
modelMathContext = MathContext.DOUBLE;
} // End if
if(mathContext == null){
mathContext = modelMathContext;
} else
{
if(!Objects.equals(mathContext, modelMathContext)){
throw new IllegalArgumentException();
}
}
Feature feature = MiningModelUtil.MODEL_PREDICTION.apply(model);
RegressionTable regressionTable = RegressionModelUtil.createRegressionTable(Collections.singletonList(feature), Collections.singletonList(1d), null)
.setTargetCategory(categoricalLabel.getValue(i));
regressionTables.add(regressionTable);
}
RegressionModel regressionModel = new RegressionModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), regressionTables)
.setNormalizationMethod(normalizationMethod)
.setMathContext(ModelUtil.simplifyMathContext(mathContext))
.setOutput(hasProbabilityDistribution ? ModelUtil.createProbabilityOutput(mathContext, categoricalLabel) : null);
List<Model> segmentationModels = new ArrayList<>(models);
segmentationModels.add(regressionModel);
return createModelChain(segmentationModels, schema);
}
示例11: createClassification
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public MiningModel createClassification(List<? extends Model> models, RegressionModel.NormalizationMethod normalizationMethod, boolean hasProbabilityDistribution, Schema schema){
CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel();
// modified here
if(categoricalLabel.size() != models.size()){
throw new IllegalArgumentException();
} // End if
if(normalizationMethod != null){
switch(normalizationMethod){
case NONE:
case SIMPLEMAX:
case SOFTMAX:
break;
default:
throw new IllegalArgumentException();
}
}
MathContext mathContext = null;
List<RegressionTable> regressionTables = new ArrayList<>();
for(int i = 0; i < categoricalLabel.size(); i++){
Model model = models.get(i);
MathContext modelMathContext = model.getMathContext();
if(modelMathContext == null){
modelMathContext = MathContext.DOUBLE;
} // End if
if(mathContext == null){
mathContext = modelMathContext;
} else
{
if(!Objects.equals(mathContext, modelMathContext)){
throw new IllegalArgumentException();
}
}
Feature feature = MODEL_PREDICTION.apply(model);
RegressionTable regressionTable = RegressionModelUtil.createRegressionTable(Collections.singletonList(feature), Collections.singletonList(1d), null)
.setTargetCategory(categoricalLabel.getValue(i));
regressionTables.add(regressionTable);
}
RegressionModel regressionModel = new RegressionModel(MiningFunction.CLASSIFICATION, ModelUtil.createMiningSchema(categoricalLabel), regressionTables)
.setNormalizationMethod(normalizationMethod)
.setMathContext(ModelUtil.simplifyMathContext(mathContext))
.setOutput(hasProbabilityDistribution ? ModelUtil.createProbabilityOutput(mathContext, categoricalLabel) : null);
List<Model> segmentationModels = new ArrayList<>(models);
segmentationModels.add(regressionModel);
return createModelChain(segmentationModels, schema);
}
示例12: evaluateRegression
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
private <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
RegressionModel regressionModel = getModel();
TargetField targetField = getTargetField();
FieldName targetFieldName = regressionModel.getTargetFieldName();
if(targetFieldName != null && !Objects.equals(targetField.getName(), targetFieldName)){
throw new InvalidAttributeException(regressionModel, PMMLAttributes.REGRESSIONMODEL_TARGETFIELDNAME, targetFieldName);
}
List<RegressionTable> regressionTables = regressionModel.getRegressionTables();
if(regressionTables.size() != 1){
throw new InvalidElementListException(regressionTables);
}
RegressionTable regressionTable = regressionTables.get(0);
Value<V> result = evaluateRegressionTable(valueFactory, regressionTable, context);
if(result == null){
return TargetUtil.evaluateRegressionDefault(valueFactory, targetField);
}
RegressionModel.NormalizationMethod normalizationMethod = regressionModel.getNormalizationMethod();
switch(normalizationMethod){
case NONE:
case SOFTMAX:
case LOGIT:
case EXP:
case PROBIT:
case CLOGLOG:
case LOGLOG:
case CAUCHIT:
RegressionModelUtil.normalizeRegressionResult(result, normalizationMethod);
break;
case SIMPLEMAX:
throw new InvalidAttributeException(regressionModel, normalizationMethod);
default:
throw new UnsupportedAttributeException(regressionModel, normalizationMethod);
}
return TargetUtil.evaluateRegression(targetField, result);
}
示例13: computeBinomialProbabilities
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public <K, V extends Number> ValueMap<K, V> computeBinomialProbabilities(ValueMap<K, V> values, RegressionModel.NormalizationMethod normalizationMethod){
if(values.size() != 2){
throw new IllegalArgumentException();
}
Iterator<Value<V>> valueIt = values.iterator();
Value<V> firstValue = valueIt.next();
// The probability of the first category is calculated
normalizeBinaryLogisticClassificationResult(firstValue, normalizationMethod);
Value<V> secondValue = valueIt.next();
// The probability of the second category is obtained by subtracting the probability of the first category from 1.0
secondValue.residual(firstValue);
return values;
}
示例14: computeOrdinalProbabilities
import org.dmg.pmml.regression.RegressionModel; //导入方法依赖的package包/类
static
public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(ValueMap<K, V> values, RegressionModel.NormalizationMethod normalizationMethod){
if(values.size() < 2){
throw new IllegalArgumentException();
}
switch(normalizationMethod){
case NONE:
case LOGIT:
case PROBIT:
case CLOGLOG:
case LOGLOG:
case CAUCHIT:
{
Value<V> sum = null;
Iterator<Value<V>> valueIt = values.iterator();
for(int i = 0, max = values.size() - 1; i < max; i++){
Value<V> value = valueIt.next();
normalizeBinaryLogisticClassificationResult(value, normalizationMethod);
if(sum == null){
sum = value.copy();
} else
{
value.subtract(sum);
sum.add(value);
}
}
Value<V> lastValue = valueIt.next();
lastValue.residual(sum);
}
break;
default:
throw new IllegalArgumentException();
}
return values;
}