def _preprocess_data(self, X, Y=None, idxs=None, train=False):
        """
        Preprocess the data:
        1. Convert sparse matrix to dense matrix.
        2. Select subset of the input if idxs exists.

        :param X: The input data of the model.
        :type X: pair with candidates and corresponding features
        :param Y: The labels of input data.
        :type Y: list or numpy.array
        :param idxs: The selected indices of input data.
        :type idxs: list or numpy.array
        :param train: Indicator of training set.
        :type train: bool
        :return: Preprocessed data.
        :rtype: list of features
        """

        C, F = X
        if issparse(F):
            F = np.array(F.todense(), dtype=np.float32)

        if Y is not None:
            Y = np.array(Y).astype(np.float32)

        if idxs is None:
            if Y is not None:
                return F, Y
            else:
                return F
        if Y is not None:
            return F[idxs], Y[idxs]
        else:
            return F[idxs]
def _preprocess_data ( self , X , Y = None , idxs = None , train = False ) : C , F = X if issparse ( F ) : F = np . array ( F . todense ( ) , dtype = np . float32 ) if Y is not None : Y = np . array ( Y ) . astype ( np . float32 ) if idxs is None : if Y is not None : return F , Y else : return F if Y is not None : return F [ idxs ] , Y [ idxs ] else : return F [ idxs ]
Preprocess the data:
        1. Convert sparse matrix to dense matrix.
        2. Select subset of the input if idxs exists.

        :param X: The input data of the model.
        :type X: pair with candidates and corresponding features
        :param Y: The labels of input data.
        :type Y: list or numpy.array
        :param idxs: The selected indices of input data.
        :type idxs: list or numpy.array
        :param train: Indicator of training set.
        :type train: bool
        :return: Preprocessed data.
        :rtype: list of features