Package com.jml.preprocessing
Class Encoder
java.lang.Object
com.jml.preprocessing.Encoder
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
encodeClasses(int[] labels)
Encodes a list of classes as values between 0 to (n-1) classes.static int[]
encodeClasses(String[] labels)
Encodes a list of classes as values between 0 to (n-1) classes.
Labels will be sorted lexicographically before encoding.static int[]
encodeClasses(String[][] labels)
Encodes a list of classes as values between 0 t0 (n-1) classes.
WARNING: This method only flattens the array and callsencodeClasses(String[])
.
Labels will be sorted alphabetically before encoding.
-
Method Details
-
encodeClasses
public static int[] encodeClasses(int[] labels)Encodes a list of classes as values between 0 to (n-1) classes.
Labels will be sorted lexicographically before encoding. This guarantees a consistent method of encoding so that the encoded labels can be decoded.- Parameters:
labels
- Labels of a dataset.- Returns:
- An integer array containing the encoding of each label.
-
encodeClasses
Encodes a list of classes as values between 0 to (n-1) classes.
Labels will be sorted lexicographically before encoding. This guarantees a consistent method of encoding so that the encoded labels can be decoded.- Parameters:
labels
- Labels of a dataset.- Returns:
- An integer array containing the encoding of each label.
-
encodeClasses
Encodes a list of classes as values between 0 t0 (n-1) classes.
WARNING: This method only flattens the array and callsencodeClasses(String[])
.
Labels will be sorted alphabetically before encoding. This guarantees a consistent method of encoding so that the encoded labels can be decoded.- Parameters:
labels
- Labels of a dataset.- Returns:
- An integer array containing the encoding of each label.
-