def _class_indices(vector):
    """Return dict mapping class -> index.

    Classes get index in order of first appearance.
    """
    # Find all classes
    # Each unique row is considered a class, whether matrix is 1d, 2d, etc.
    # This alllows it to work with col vectors, or 1d vectors
    class_indices = {}
    index = 0
    for val in vector:
        key = str(val)
        if key not in class_indices:
            class_indices[key] = index
            index += 1
    return class_indices