Here you can find the source of createTarget(List
public static <T> List<Double> createTarget(List<T> labels)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main { public static <T> List<Double> createTarget(List<T> labels) { return createTarget(labels, new HashMap<T, Double>()); }// ww w .j a va2 s . com public static <T> List<Double> createTarget(List<T> labels, Map<T, Double> labelMap) { List<Double> target = new ArrayList<Double>(); double t = 0; for (T label : labels) { if (!labelMap.containsKey(label)) { t += 1; labelMap.put(label, t); } target.add((double) labelMap.get(label)); } return target; } }