本文整理汇总了Java中org.dmg.pmml.Interval类的典型用法代码示例。如果您正苦于以下问题:Java Interval类的具体用法?Java Interval怎么用?Java Interval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interval类属于org.dmg.pmml包,在下文中一共展示了Interval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateInterval
import org.dmg.pmml.Interval; //导入依赖的package包/类
@Test
public void translateInterval(){
Interval interval = ExpressionTranslator.translateInterval("(-10.0E+0, +10.0E-0]");
assertEquals(Interval.Closure.OPEN_CLOSED, interval.getClosure());
assertEquals(new Double("-10.0E0"), interval.getLeftMargin());
assertEquals(new Double("+10.0E0"), interval.getRightMargin());
try {
interval = ExpressionTranslator.translateInterval("(0, NaN)");
fail();
} catch(IllegalArgumentException iae){
// Ignored
}
interval = ExpressionTranslator.translateInterval("[-Inf, +Inf]");
assertEquals(Interval.Closure.CLOSED_CLOSED, interval.getClosure());
assertEquals(null, interval.getLeftMargin());
assertEquals(null, interval.getRightMargin());
}
示例2: parseDiscretize
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private RangeMap<Double, String> parseDiscretize(Discretize discretize){
RangeMap<Double, String> result = TreeRangeMap.create();
List<DiscretizeBin> discretizeBins = discretize.getDiscretizeBins();
for(DiscretizeBin discretizeBin : discretizeBins){
Interval interval = discretizeBin.getInterval();
if(interval == null){
throw new MissingAttributeException(discretizeBin, PMMLAttributes.DISCRETIZEBIN_INTERVAL);
}
Range<Double> range = toRange(interval);
String binValue = discretizeBin.getBinValue();
if(binValue == null){
throw new MissingAttributeException(discretizeBin, PMMLAttributes.DISCRETIZEBIN_BINVALUE);
}
result.put(range, binValue);
}
return result;
}
示例3: unboundedRange
import org.dmg.pmml.Interval; //导入依赖的package包/类
@Test
public void unboundedRange(){
Range<Double> lessThan = toRange(Interval.Closure.OPEN_OPEN, null, 0d);
assertTrue(lessThan.contains(-Double.MAX_VALUE));
assertFalse(lessThan.contains(0d));
assertFalse(lessThan.contains(Double.MAX_VALUE));
Range<Double> atMost = toRange(Interval.Closure.OPEN_CLOSED, null, 0d);
assertTrue(atMost.contains(-Double.MAX_VALUE));
assertTrue(atMost.contains(0d));
assertFalse(atMost.contains(Double.MAX_VALUE));
Range<Double> greaterThan = toRange(Interval.Closure.OPEN_OPEN, 0d, null);
assertFalse(greaterThan.contains(-Double.MAX_VALUE));
assertFalse(greaterThan.contains(0d));
assertTrue(greaterThan.contains(Double.MAX_VALUE));
Range<Double> atLeast = toRange(Interval.Closure.CLOSED_OPEN, 0d, null);
assertFalse(atLeast.contains(-Double.MAX_VALUE));
assertTrue(atLeast.contains(0d));
assertTrue(atLeast.contains(Double.MAX_VALUE));
}
示例4: parseInterval
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
public Interval parseInterval(String string){
if(string.length() < 3){
throw new IllegalArgumentException();
}
String bounds = string.substring(0, 1) + string.substring(string.length() - 1, string.length());
String margins = string.substring(1, string.length() - 1);
Interval.Closure closure;
switch(bounds){
case "[]":
closure = Interval.Closure.CLOSED_CLOSED;
break;
default:
throw new IllegalArgumentException(string);
}
String[] values = margins.split(":");
if(values.length != 2){
throw new IllegalArgumentException(margins);
}
Double leftMargin = Double.valueOf(values[0]);
Double rightMargin = Double.valueOf(values[1]);
Interval interval = new Interval(closure)
.setLeftMargin(leftMargin)
.setRightMargin(rightMargin);
return interval;
}
示例5: mergeIntervals
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private List<Interval> mergeIntervals(List<Interval> left, List<Interval> right){
if(left.isEmpty() && right.size() > 0){
return right;
}
return left;
}
示例6: decorate
import org.dmg.pmml.Interval; //导入依赖的package包/类
@Override
public void decorate(DataField dataField, MiningField miningField){
List<Interval> intervals = getIntervals();
if(intervals.size() > 0){
PMMLUtil.addIntervals(dataField, intervals);
}
super.decorate(dataField, miningField);
}
示例7: createDiscretize
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private Discretize createDiscretize(FieldName name, List<String> categories){
Discretize discretize = new Discretize(name);
for(String category : categories){
Interval interval = ExpressionTranslator.translateInterval(category);
DiscretizeBin discretizeBin = new DiscretizeBin(category, interval);
discretize.addDiscretizeBins(discretizeBin);
}
return discretize;
}
示例8: parseValidRanges
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private RangeSet<Double> parseValidRanges(DataField dataField){
RangeSet<Double> result = TreeRangeSet.create();
List<Interval> intervals = dataField.getIntervals();
for(Interval interval : intervals){
Range<Double> range = DiscretizationUtil.toRange(interval);
result.add(range);
}
return result;
}
示例9: boundedRange
import org.dmg.pmml.Interval; //导入依赖的package包/类
@Test
public void boundedRange(){
Range<Double> open = toRange(Interval.Closure.OPEN_OPEN, -1d, 1d);
assertFalse(open.contains(-Double.MAX_VALUE));
assertFalse(open.contains(-1d));
assertTrue(open.contains(0d));
assertFalse(open.contains(1d));
assertFalse(open.contains(Double.MAX_VALUE));
Range<Double> openClosed = toRange(Interval.Closure.OPEN_CLOSED, -1d, 1d);
assertFalse(openClosed.contains(-Double.MAX_VALUE));
assertFalse(openClosed.contains(-1d));
assertTrue(openClosed.contains(0d));
assertTrue(openClosed.contains(1d));
assertFalse(openClosed.contains(Double.MAX_VALUE));
Range<Double> closedOpen = toRange(Interval.Closure.CLOSED_OPEN, -1d, 1d);
assertFalse(closedOpen.contains(-Double.MAX_VALUE));
assertTrue(closedOpen.contains(-1d));
assertTrue(closedOpen.contains(0d));
assertFalse(closedOpen.contains(1d));
assertFalse(closedOpen.contains(Double.MAX_VALUE));
Range<Double> closed = toRange(Interval.Closure.CLOSED_CLOSED, -1d, 1d);
assertFalse(closed.contains(-Double.MAX_VALUE));
assertTrue(closed.contains(-1d));
assertTrue(closed.contains(0d));
assertTrue(closed.contains(1d));
assertFalse(closed.contains(Double.MAX_VALUE));
}
示例10: createInterval
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private Interval createInterval(Interval.Closure closure, Double leftMargin, Double rightMargin){
Interval result = new Interval(closure)
.setLeftMargin(leftMargin)
.setRightMargin(rightMargin);
return result;
}
示例11: clearIntervalsAndValues
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private void clearIntervalsAndValues(DataField dataField){
List<Interval> intervals = dataField.getIntervals();
intervals.clear();
List<Value> values = dataField.getValues();
values.clear();
}
示例12: addIntervals
import org.dmg.pmml.Interval; //导入依赖的package包/类
static
public void addIntervals(DataField dataField, List<Interval> intervals){
(dataField.getIntervals()).addAll(intervals);
}
示例13: getIntervals
import org.dmg.pmml.Interval; //导入依赖的package包/类
public List<Interval> getIntervals(){
return this.intervals;
}
示例14: addIntervals
import org.dmg.pmml.Interval; //导入依赖的package包/类
public ValidValueDecorator addIntervals(Interval... intervals){
getIntervals().addAll(Arrays.asList(intervals));
return this;
}
示例15: encodeFeatures
import org.dmg.pmml.Interval; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){
Boolean withData = getWithData();
Boolean withStatistics = getWithStatistics();
List<? extends Number> dataMin = null;
List<? extends Number> dataMax = null;
if(withData){
dataMin = getDataMin();
dataMax = getDataMax();
ClassDictUtil.checkSize(features, dataMin, dataMax);
}
List<Feature> result = new ArrayList<>();
for(int i = 0; i < features.size(); i++){
Feature feature = features.get(i);
WildcardFeature wildcardFeature = (WildcardFeature)feature;
if(withData){
Interval interval = new Interval(Interval.Closure.CLOSED_CLOSED)
.setLeftMargin(ValueUtil.asDouble(dataMin.get(i)))
.setRightMargin(ValueUtil.asDouble(dataMax.get(i)));
ValidValueDecorator validValueDecorator = new ValidValueDecorator()
.addIntervals(interval);
feature = wildcardFeature.toContinuousFeature();
encoder.addDecorator(wildcardFeature.getName(), validValueDecorator);
} // End if
if(withStatistics){
Map<String, ?> counts = extractMap(getCounts(), i);
Map<String, ?> numericInfo = extractMap(getNumericInfo(), i);
UnivariateStats univariateStats = new UnivariateStats()
.setField(wildcardFeature.getName())
.setCounts(createCounts(counts))
.setNumericInfo(createNumericInfo(numericInfo));
encoder.putUnivariateStats(univariateStats);
}
result.add(feature);
}
return super.encodeFeatures(result, encoder);
}