def _preprocess_data(self, X, Y=None, idxs=None, train=False):
C, F = X<EOL>if issparse(F):<EOL><INDENT>F = np.array(F.todense(), dtype=np.float32)<EOL><DEDENT>if Y is not None:<EOL><INDENT>Y = np.array(Y).astype(np.float32)<EOL><DEDENT>if idxs is None:<EOL><INDENT>if Y is not None:<EOL><INDENT>return F, Y<EOL><DEDENT>else:<EOL><INDENT>return F<EOL><DEDENT><DEDENT>if Y is not None:<EOL><INDENT>return F[idxs], Y[idxs]<EOL><DEDENT>else:<EOL><INDENT>return F[idxs]<EOL><DEDENT>
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