@Test public void testClassToIndex() { final CategoricalValueSchema schema = new CategoricalValueSchema( true, ImmutableSet.of( "fraud", "genuine" ) ); final Function<Serializable, Integer> converter = EncodingHelper.classToIndexConverter(schema); assertThat(converter.apply("fraud")) .as("Converting a valid value") .isEqualTo(0); assertThat(converter.apply("ERROR")) .as("Converting an unexpected value") .isNull(); }
public static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema) { final Map<String, Integer> conversionMap = conversionMap(targetVariableSchema, Function.identity()); return value -> conversionMap.get(value.toString()); }
EncodingHelper implements Serializable { public static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema) { final Map<String, Integer> conversionMap = conversionMap(targetVariableSchema, Function.identity()); return value -> conversionMap.get(value.toString()); } }
EncodingHelper implements Serializable { public static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema) { final Map<String, Integer> conversionMap = conversionMap(targetVariableSchema, Function.identity()); return value -> conversionMap.get(value.toString()); } EncodingHelper(final DatasetSchema schema); }
EncodingHelper implements Serializable { public static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema) { final Map<String, Integer> conversionMap = conversionMap(targetVariableSchema, Function.identity()); return value -> conversionMap.get(value.toString()); } EncodingHelper(final DatasetSchema schema); static SerializableEncoder encoderForField(final AbstractValueSchema abstractValueSchema); static String decodeDoubleToCategory(final double doubleValue,
                                                final CategoricalValueSchema categoricalValueSchema); static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema); Serializable encode(final Serializable value, final int index); int numberFields(); }
EncodingHelper implements Serializable { public static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema) { final Map<String, Integer> conversionMap = conversionMap(targetVariableSchema, Function.identity()); return value -> conversionMap.get(value.toString()); } EncodingHelper(final DatasetSchema schema); static SerializableEncoder encoderForField(final AbstractValueSchema abstractValueSchema); static String decodeDoubleToCategory(final double doubleValue,
                                                final CategoricalValueSchema categoricalValueSchema); static Function<Serializable, Integer> classToIndexConverter(final CategoricalValueSchema targetVariableSchema); Serializable encode(final Serializable value, final int index); int numberFields();  }