Java Code Examples for org.dmg.pmml.DataType#DATE
The following examples show how to use
org.dmg.pmml.DataType#DATE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
/** * @see DataType#DATE */ static private LocalDate toDate(Object value){ if(value instanceof LocalDate){ return (LocalDate)value; } else if(value instanceof LocalDateTime){ LocalDateTime instant = (LocalDateTime)value; return instant.toLocalDate(); } throw new TypeCheckException(DataType.DATE, value); }
Example 2
Source File: TransformerUtil.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 5 votes |
static public DataType parseDataType(String dtype){ switch(dtype){ case "datetime64[D]": return DataType.DATE; case "datetime64[s]": return DataType.DATE_TIME; default: throw new IllegalArgumentException(dtype); } }
Example 3
Source File: DateDomain.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 4 votes |
@Override public DataType getDataType(){ return DataType.DATE; }
Example 4
Source File: ExpressionUtilTest.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 3 votes |
@Test public void evaluateAggregate(){ FieldName name = FieldName.create("x"); TypeInfo typeInfo = new SimpleTypeInfo(DataType.DATE, OpType.ORDINAL); List<?> values = Arrays.asList(TypeUtil.parse(DataType.DATE, "2013-01-01"), TypeUtil.parse(DataType.DATE, "2013-02-01"), TypeUtil.parse(DataType.DATE, "2013-03-01")); Map<FieldName, FieldValue> arguments = Collections.singletonMap(name, FieldValue.create(typeInfo, values)); Aggregate aggregate = new Aggregate(name, Aggregate.Function.COUNT); assertEquals(3, evaluate(aggregate, arguments)); aggregate.setFunction(Aggregate.Function.MIN); assertEquals(values.get(0), evaluate(aggregate, arguments)); aggregate.setFunction(Aggregate.Function.MAX); assertEquals(values.get(2), evaluate(aggregate, arguments)); typeInfo = new SimpleTypeInfo(DataType.DATE, OpType.ORDINAL, Lists.reverse(values)); arguments = Collections.singletonMap(name, FieldValue.create(typeInfo, values)); aggregate.setFunction(Aggregate.Function.MIN); assertEquals(values.get(2), evaluate(aggregate, arguments)); aggregate.setFunction(Aggregate.Function.MAX); assertEquals(values.get(0), evaluate(aggregate, arguments)); }