(index, data_matrix, unknown_element=0)
return label_indexed, index_arr
get data matrix by giving index in multi-label setting.

    Note:
    Each index should be a tuple, with the first element representing instance index.
    e.g.
    queried_index = (1, [3,4])  # 1st instance, 3rd,4t _labels
    queried_index = (1, [3])    # 1st instance, 3rd _labels
    queried_index = (1, 3)
    queried_index = (1, (3))
    queried_index = (1, (3,4))
    queried_index = (1, )   # query all _labels

    Parameters
    ----------
    index: {list, np.ndarray, tuple, MultiLabelIndexCollection}
        if only one index, a tuple is expected.
        Otherwise, it should be a list type with n tuples.

    data_matrix:  array-like
        matrix with [n_samples, n_features] or [n_samples, n_classes].

    unknown_element: object
        value to fill up the unknown part of the matrix_clip.

    Returns
    -------
    Matrix_clip: np.ndarray
        data matrix given index

    index_arr: list
        index of examples correspond to the each row of Matrix_clip
get data matrix by giving index in multi-label setting.
get data matrix by giving index in multi - label setting .
def get_labelmatrix_in_multilabel(index, data_matrix, unknown_element=0):
    """get data matrix by giving index in multi-label setting.

    Note:
    Each index should be a tuple, with the first element representing instance index.
    e.g.
    queried_index = (1, [3,4])  # 1st instance, 3rd,4t _labels
    queried_index = (1, [3])    # 1st instance, 3rd _labels
    queried_index = (1, 3)
    queried_index = (1, (3))
    queried_index = (1, (3,4))
    queried_index = (1, )   # query all _labels

    Parameters
    ----------
    index: {list, np.ndarray, tuple, MultiLabelIndexCollection}
        if only one index, a tuple is expected.
        Otherwise, it should be a list type with n tuples.

    data_matrix:  array-like
        matrix with [n_samples, n_features] or [n_samples, n_classes].

    unknown_element: object
        value to fill up the unknown part of the matrix_clip.

    Returns
    -------
    Matrix_clip: np.ndarray
        data matrix given index

    index_arr: list
        index of examples correspond to the each row of Matrix_clip
    """
    # check validity
    index = check_index_multilabel(index)
    data_matrix = check_matrix(data_matrix)

    ins_bound = data_matrix.shape[0]
    ele_bound = data_matrix.shape[1]

    index_arr = []  # record if a row is already constructed
    current_rows = 0  # record how many rows have been constructed
    label_indexed = None
    for k in index:
        # k is a tuple with 2 elements
        k_len = len(k)
        if k_len != 1 and k_len != 2:
            raise ValueError(
                "A single index should only have 1 element (example_index, ) to query all _labels or"
                "2 elements (example_index, [label_indexes]) to query specific _labels. But found %d in %s" %
                (len(k), str(k)))
        example_ind = k[0]
        assert (example_ind < ins_bound)
        if example_ind in index_arr:
            ind_row = index_arr.index(example_ind)
        else:
            index_arr.append(example_ind)
            ind_row = -1  # new row
            current_rows += 1
        if k_len == 1:  # all _labels
            label_ind = [i for i in range(ele_bound)]
        else:
            if isinstance(k[1], collections.Iterable):
                label_ind = [i for i in k[1] if 0 <= i < ele_bound]
            else:
                assert (0 <= k[1] < ele_bound)
                label_ind = [k[1]]

        # construct mat
        if ind_row == -1:
            tmp = np.zeros((1, ele_bound)) + unknown_element
            tmp[0, label_ind] = data_matrix[example_ind, label_ind]
            if label_indexed is None:
                label_indexed = tmp.copy()
            else:
                label_indexed = np.append(label_indexed, tmp, axis=0)
        else:
            label_indexed[ind_row, label_ind] = data_matrix[example_ind, label_ind]
    return label_indexed, index_arr
def get_labelmatrix_in_multilabel ( index , data_matrix , unknown_element = 0 ) : # check validity index = check_index_multilabel ( index ) data_matrix = check_matrix ( data_matrix ) ins_bound = data_matrix . shape [ 0 ] ele_bound = data_matrix . shape [ 1 ] index_arr = [ ] # record if a row is already constructed current_rows = 0 # record how many rows have been constructed label_indexed = None for k in index : # k is a tuple with 2 elements k_len = len ( k ) if k_len != 1 and k_len != 2 : raise ValueError ( "A single index should only have 1 element (example_index, ) to query all _labels or" "2 elements (example_index, [label_indexes]) to query specific _labels. But found %d in %s" % ( len ( k ) , str ( k ) ) ) example_ind = k [ 0 ] assert ( example_ind < ins_bound ) if example_ind in index_arr : ind_row = index_arr . index ( example_ind ) else : index_arr . append ( example_ind ) ind_row = - 1 # new row current_rows += 1 if k_len == 1 : # all _labels label_ind = [ i for i in range ( ele_bound ) ] else : if isinstance ( k [ 1 ] , collections . Iterable ) : label_ind = [ i for i in k [ 1 ] if 0 <= i < ele_bound ] else : assert ( 0 <= k [ 1 ] < ele_bound ) label_ind = [ k [ 1 ] ] # construct mat if ind_row == - 1 : tmp = np . zeros ( ( 1 , ele_bound ) ) + unknown_element tmp [ 0 , label_ind ] = data_matrix [ example_ind , label_ind ] if label_indexed is None : label_indexed = tmp . copy ( ) else : label_indexed = np . append ( label_indexed , tmp , axis = 0 ) else : label_indexed [ ind_row , label_ind ] = data_matrix [ example_ind , label_ind ] return label_indexed , index_arr