def __pred_for_csc(self, csc, num_iteration, predict_type):
        """Predict for a CSC data."""
        nrow = csc.shape[0]
        if nrow > MAX_INT32:
            return self.__pred_for_csr(csc.tocsr(), num_iteration, predict_type)
        n_preds = self.__get_num_preds(num_iteration, nrow, predict_type)
        preds = np.zeros(n_preds, dtype=np.float64)
        out_num_preds = ctypes.c_int64(0)

        ptr_indptr, type_ptr_indptr, __ = c_int_array(csc.indptr)
        ptr_data, type_ptr_data, _ = c_float_array(csc.data)

        assert csc.shape[0] <= MAX_INT32
        csc.indices = csc.indices.astype(np.int32, copy=False)

        _safe_call(_LIB.LGBM_BoosterPredictForCSC(
            self.handle,
            ptr_indptr,
            ctypes.c_int32(type_ptr_indptr),
            csc.indices.ctypes.data_as(ctypes.POINTER(ctypes.c_int32)),
            ptr_data,
            ctypes.c_int(type_ptr_data),
            ctypes.c_int64(len(csc.indptr)),
            ctypes.c_int64(len(csc.data)),
            ctypes.c_int64(csc.shape[0]),
            ctypes.c_int(predict_type),
            ctypes.c_int(num_iteration),
            c_str(self.pred_parameter),
            ctypes.byref(out_num_preds),
            preds.ctypes.data_as(ctypes.POINTER(ctypes.c_double))))
        if n_preds != out_num_preds.value:
            raise ValueError("Wrong length for predict results")
        return preds, nrow
def __pred_for_csc ( self , csc , num_iteration , predict_type ) : nrow = csc . shape [ 0 ] if nrow > MAX_INT32 : return self . __pred_for_csr ( csc . tocsr ( ) , num_iteration , predict_type ) n_preds = self . __get_num_preds ( num_iteration , nrow , predict_type ) preds = np . zeros ( n_preds , dtype = np . float64 ) out_num_preds = ctypes . c_int64 ( 0 ) ptr_indptr , type_ptr_indptr , __ = c_int_array ( csc . indptr ) ptr_data , type_ptr_data , _ = c_float_array ( csc . data ) assert csc . shape [ 0 ] <= MAX_INT32 csc . indices = csc . indices . astype ( np . int32 , copy = False ) _safe_call ( _LIB . LGBM_BoosterPredictForCSC ( self . handle , ptr_indptr , ctypes . c_int32 ( type_ptr_indptr ) , csc . indices . ctypes . data_as ( ctypes . POINTER ( ctypes . c_int32 ) ) , ptr_data , ctypes . c_int ( type_ptr_data ) , ctypes . c_int64 ( len ( csc . indptr ) ) , ctypes . c_int64 ( len ( csc . data ) ) , ctypes . c_int64 ( csc . shape [ 0 ] ) , ctypes . c_int ( predict_type ) , ctypes . c_int ( num_iteration ) , c_str ( self . pred_parameter ) , ctypes . byref ( out_num_preds ) , preds . ctypes . data_as ( ctypes . POINTER ( ctypes . c_double ) ) ) ) if n_preds != out_num_preds . value : raise ValueError ( "Wrong length for predict results" ) return preds , nrow
Predict for a CSC data.