• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Interval类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.dmg.pmml.Interval的典型用法代码示例。如果您正苦于以下问题:Java Interval类的具体用法?Java Interval怎么用?Java Interval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Interval类属于org.dmg.pmml包,在下文中一共展示了Interval类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:23,代码来源:ExpressionTranslatorTest.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:24,代码来源:DiscretizationUtil.java


示例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));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:23,代码来源:DiscretizationUtilTest.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:35,代码来源:LightGBMUtil.java


示例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;
}
 
开发者ID:vruusmann,项目名称:jpmml-toolkit,代码行数:10,代码来源:Aggregator.java


示例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);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:11,代码来源:ValidValueDecorator.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-r,代码行数:15,代码来源:FormulaUtil.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:14,代码来源:FieldValueUtil.java


示例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));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:31,代码来源:DiscretizationUtilTest.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:9,代码来源:DiscretizationUtilTest.java


示例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();
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:9,代码来源:FieldValueUtilTest.java


示例12: addIntervals

import org.dmg.pmml.Interval; //导入依赖的package包/类
static
public void addIntervals(DataField dataField, List<Interval> intervals){
	(dataField.getIntervals()).addAll(intervals);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:5,代码来源:PMMLUtil.java


示例13: getIntervals

import org.dmg.pmml.Interval; //导入依赖的package包/类
public List<Interval> getIntervals(){
	return this.intervals;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:4,代码来源:ValidValueDecorator.java


示例14: addIntervals

import org.dmg.pmml.Interval; //导入依赖的package包/类
public ValidValueDecorator addIntervals(Interval... intervals){
	getIntervals().addAll(Arrays.asList(intervals));

	return this;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:6,代码来源:ValidValueDecorator.java


示例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);
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:53,代码来源:ContinuousDomain.java


示例16: toRange

import org.dmg.pmml.Interval; //导入依赖的package包/类
static
public Range<Double> toRange(Interval interval){
	Double leftMargin = interval.getLeftMargin();
	Double rightMargin = interval.getRightMargin();

	// "The leftMargin and rightMargin attributes are optional, but at least one value must be defined"
	if(leftMargin == null && rightMargin == null){
		throw new MissingAttributeException(interval, PMMLAttributes.INTERVAL_LEFTMARGIN);
	} // End if

	if(leftMargin != null && rightMargin != null && (leftMargin).compareTo(rightMargin) > 0){
		throw new InvalidElementException(interval);
	}

	Interval.Closure closure = interval.getClosure();
	if(closure == null){
		throw new MissingAttributeException(interval, PMMLAttributes.INTERVAL_CLOSURE);
	}

	switch(closure){
		case OPEN_OPEN:
			{
				if(leftMargin == null){
					return Range.lessThan(rightMargin);
				} else

				if(rightMargin == null){
					return Range.greaterThan(leftMargin);
				}

				return Range.open(leftMargin, rightMargin);
			}
		case OPEN_CLOSED:
			{
				if(leftMargin == null){
					return Range.atMost(rightMargin);
				} else

				if(rightMargin == null){
					return Range.greaterThan(leftMargin);
				}

				return Range.openClosed(leftMargin, rightMargin);
			}
		case CLOSED_OPEN:
			{
				if(leftMargin == null){
					return Range.lessThan(rightMargin);
				} else

				if(rightMargin == null){
					return Range.atLeast(leftMargin);
				}

				return Range.closedOpen(leftMargin, rightMargin);
			}
		case CLOSED_CLOSED:
			{
				if(leftMargin == null){
					return Range.atMost(rightMargin);
				} else

				if(rightMargin == null){
					return Range.atLeast(leftMargin);
				}

				return Range.closed(leftMargin, rightMargin);
			}
		default:
			throw new UnsupportedAttributeException(interval, closure);
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:73,代码来源:DiscretizationUtil.java


示例17: toRange

import org.dmg.pmml.Interval; //导入依赖的package包/类
static
private Range<Double> toRange(Interval.Closure closure, Double leftMargin, Double rightMargin){
	return DiscretizationUtil.toRange(createInterval(closure, leftMargin, rightMargin));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:5,代码来源:DiscretizationUtilTest.java


示例18: isOutlier

import org.dmg.pmml.Interval; //导入依赖的package包/类
static
public boolean isOutlier(DataField dataField, Object value){

	if(value == null){
		return false;
	}

	OpType opType = dataField.getOptype();
	switch(opType){
		case CONTINUOUS:
			{
				List<Double> range = null;

				List<Interval> fieldIntervals = dataField.getIntervals();
				for(Interval fieldInterval : fieldIntervals){

					if(range == null){
						range = Lists.newArrayList();
					}

					range.add(fieldInterval.getLeftMargin());
					range.add(fieldInterval.getRightMargin());
				}

				List<Value> fieldValues = dataField.getValues();
				for(Value fieldValue : fieldValues){
					Value.Property property = fieldValue.getProperty();

					switch(property){
						case VALID:
							{
								if(range == null){
									range = Lists.newArrayList();
								}

								range.add((Double)TypeUtil.parseOrCast(DataType.DOUBLE, fieldValue.getValue()));
							}
							break;
						default:
							break;
					}
				}

				if(range == null){
					return false;
				}

				Double doubleValue = (Double)TypeUtil.parseOrCast(DataType.DOUBLE, value);

				Double minValue = Collections.min(range);
				if(TypeUtil.compare(DataType.DOUBLE, doubleValue, minValue) < 0){
					return true;
				}

				Double maxValue = Collections.max(range);
				if(TypeUtil.compare(DataType.DOUBLE, doubleValue, maxValue) > 0){
					return true;
				}
			}
			break;
		case CATEGORICAL:
		case ORDINAL:
			break;
		default:
			throw new UnsupportedFeatureException(dataField, opType);
	}

	return false;
}
 
开发者ID:jpmml,项目名称:jpmml,代码行数:70,代码来源:ArgumentUtil.java


示例19: encodeFeatures

import org.dmg.pmml.Interval; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(SparkMLEncoder encoder){
	Bucketizer transformer = getTransformer();

	Feature feature = encoder.getOnlyFeature(transformer.getInputCol());

	ContinuousFeature continuousFeature = feature.toContinuousFeature();

	Discretize discretize = new Discretize(continuousFeature.getName());

	List<String> categories = new ArrayList<>();

	double[] splits = transformer.getSplits();
	for(int i = 0; i < (splits.length - 1); i++){
		String category = String.valueOf(i);

		categories.add(category);

		Interval interval = new Interval((i < (splits.length - 2)) ? Interval.Closure.CLOSED_OPEN : Interval.Closure.CLOSED_CLOSED)
			.setLeftMargin(formatMargin(splits[i]))
			.setRightMargin(formatMargin(splits[i + 1]));

		DiscretizeBin discretizeBin = new DiscretizeBin(category, interval);

		discretize.addDiscretizeBins(discretizeBin);
	}

	DerivedField derivedField = encoder.createDerivedField(formatName(transformer), OpType.CATEGORICAL, DataType.INTEGER, discretize);

	return Collections.<Feature>singletonList(new CategoricalFeature(encoder, derivedField, categories));
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:32,代码来源:BucketizerConverter.java



注:本文中的org.dmg.pmml.Interval类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WrongNumberArgsException类代码示例发布时间:2022-05-22
下一篇:
Java Comment类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap