### Question:
LabelEncoder extends AbstractDatasetFeatureVectorTransformer { public LabelEncoder(Dataset dataset) { LOGGER.info("Start initializing LabelEncoder"); StopWatch stopWatch = new StopWatch(); Set<String> nominalValueNames = dataset.getFeatureInformation().getFeatureNamesOfType(NominalValue.class); DatasetStatistics statistics = new DatasetStatistics(dataset.filterFeatures(equal(nominalValueNames))); Map<String, Map<String, Integer>> mappings = new HashMap<>(); for (String nominalValueName : nominalValueNames) { NominalValueStatistics valueStatistics = (NominalValueStatistics) statistics.getValueStatistics(nominalValueName); List<String> list = new ArrayList<>(valueStatistics.getValues()); Collections.sort(list); Map<String, Integer> indexMap = CollectionHelper.createIndexMap(list); LOGGER.debug("# unique values for {}: {}", nominalValueName, list.size()); mappings.put(nominalValueName, indexMap); } LOGGER.info("Initialized LabelEncoder in {}", stopWatch); this.mappings = mappings; } LabelEncoder(Dataset dataset); @Override FeatureInformation getFeatureInformation(FeatureInformation featureInformation); @Override FeatureVector apply(FeatureVector featureVector);  }### Answer:
@Test public void testLabelEncoder() { List<Instance> instances = new ArrayList<>(); instances.add(new InstanceBuilder().set("value", "a").create("dummy")); instances.add(new InstanceBuilder().set("value", "z").create("dummy")); instances.add(new InstanceBuilder().set("value", "b").create("dummy")); Dataset dataset = new DefaultDataset(instances); LabelEncoder labelEncoder = new LabelEncoder(dataset); Instance transformedInstance = labelEncoder.apply(new InstanceBuilder().set("value", "a").create("dummy")); assertEquals(0, transformedInstance.getVector().getNumeric("value_labelEncoded").getInt()); Instance transformedInstance2 = labelEncoder.apply(new InstanceBuilder().set("value", "b").create("dummy")); assertEquals(1, transformedInstance2.getVector().getNumeric("value_labelEncoded").getInt()); Instance transformedInstance3 = labelEncoder.apply(new InstanceBuilder().set("value", "z").create("dummy")); assertEquals(2, transformedInstance3.getVector().getNumeric("value_labelEncoded").getInt()); Instance transformedInstance4 = labelEncoder.apply(new InstanceBuilder().set("value", "x").create("dummy")); assertTrue(transformedInstance4.getVector().get("value_labelEncoded").isNull()); }