(index_arr, label_size=None, check_arr=True)
return integrated_arr
Integrated the indexes of multi-label.

    Parameters
    ----------
    index_arr: list or np.ndarray
        multi-label index array.

    label_size: int, optional (default = None)
        the size of label set. If not provided, an inference is attempted.
        raise if the inference is failed.

    check_arr: bool, optional (default = True)
        whether to check the validity of index array.

    Returns
    -------
    array: list
        the integrated array.
Integrated the indexes of multi-label.
Integrated the indexes of multi - label .
def integrate_multilabel_index(index_arr, label_size=None, check_arr=True):
    """ Integrated the indexes of multi-label.

    Parameters
    ----------
    index_arr: list or np.ndarray
        multi-label index array.

    label_size: int, optional (default = None)
        the size of label set. If not provided, an inference is attempted.
        raise if the inference is failed.

    check_arr: bool, optional (default = True)
        whether to check the validity of index array.

    Returns
    -------
    array: list
        the integrated array.
    """
    if check_arr:
        index_arr = check_index_multilabel(index_arr)
    if label_size is None:
        label_size = infer_label_size_multilabel(index_arr)
    else:
        assert (label_size > 0)

    integrated_arr = []
    integrated_dict = {}
    for index in index_arr:
        example_ind = index[0]
        if len(index) == 1:
            integrated_dict[example_ind] = set(range(label_size))
        else:
            # length = 2
            if example_ind in integrated_dict.keys():
                integrated_dict[example_ind].update(
                    set(index[1] if isinstance(index[1], collections.Iterable) else [index[1]]))
            else:
                integrated_dict[example_ind] = set(
                    index[1] if isinstance(index[1], collections.Iterable) else [index[1]])

    for item in integrated_dict.items():
        if len(item[1]) == label_size:
            integrated_arr.append((item[0],))
        else:
            # -------------------------------------------------------------------------------------------
            # integrated_arr.append((item[0], tuple(item[0])))
            integrated_arr.append((item[0], tuple(item[1])))

    return integrated_arr
def integrate_multilabel_index ( index_arr , label_size = None , check_arr = True ) : if check_arr : index_arr = check_index_multilabel ( index_arr ) if label_size is None : label_size = infer_label_size_multilabel ( index_arr ) else : assert ( label_size > 0 ) integrated_arr = [ ] integrated_dict = { } for index in index_arr : example_ind = index [ 0 ] if len ( index ) == 1 : integrated_dict [ example_ind ] = set ( range ( label_size ) ) else : # length = 2 if example_ind in integrated_dict . keys ( ) : integrated_dict [ example_ind ] . update ( set ( index [ 1 ] if isinstance ( index [ 1 ] , collections . Iterable ) else [ index [ 1 ] ] ) ) else : integrated_dict [ example_ind ] = set ( index [ 1 ] if isinstance ( index [ 1 ] , collections . Iterable ) else [ index [ 1 ] ] ) for item in integrated_dict . items ( ) : if len ( item [ 1 ] ) == label_size : integrated_arr . append ( ( item [ 0 ] , ) ) else : # ------------------------------------------------------------------------------------------- # integrated_arr.append((item[0], tuple(item[0]))) integrated_arr . append ( ( item [ 0 ] , tuple ( item [ 1 ] ) ) ) return integrated_arr