def __init__(self, data, label=None, missing=None,
                 weight=None, silent=False,
                 feature_names=None, feature_types=None,
                 nthread=None):
        """
        Parameters
        ----------
        data : string/numpy.array/scipy.sparse/pd.DataFrame/dt.Frame
            Data source of DMatrix.
            When data is string type, it represents the path libsvm format txt file,
            or binary file that xgboost can read from.
        label : list or numpy 1-D array, optional
            Label of the training data.
        missing : float, optional
            Value in the data which needs to be present as a missing value. If
            None, defaults to np.nan.
        weight : list or numpy 1-D array , optional
            Weight for each instance.

            .. note:: For ranking task, weights are per-group.

                In ranking task, one weight is assigned to each group (not each data
                point). This is because we only care about the relative ordering of
                data points within each group, so it doesn't make sense to assign
                weights to individual data points.

        silent : boolean, optional
            Whether print messages during construction
        feature_names : list, optional
            Set names for features.
        feature_types : list, optional
            Set types for features.
        nthread : integer, optional
            Number of threads to use for loading data from numpy array. If -1,
            uses maximum threads available on the system.
        """
        # force into void_p, mac need to pass things in as void_p
        if data is None:
            self.handle = None

            if feature_names is not None:
                self._feature_names = feature_names
            if feature_types is not None:
                self._feature_types = feature_types
            return

        data, feature_names, feature_types = _maybe_pandas_data(data,
                                                                feature_names,
                                                                feature_types)

        data, feature_names, feature_types = _maybe_dt_data(data,
                                                            feature_names,
                                                            feature_types)
        label = _maybe_pandas_label(label)
        label = _maybe_dt_array(label)
        weight = _maybe_dt_array(weight)

        if isinstance(data, list):
            warnings.warn('Initializing DMatrix from List is deprecated.',
                          DeprecationWarning)

        if isinstance(data, STRING_TYPES):
            handle = ctypes.c_void_p()
            _check_call(_LIB.XGDMatrixCreateFromFile(c_str(data),
                                                     ctypes.c_int(silent),
                                                     ctypes.byref(handle)))
            self.handle = handle
        elif isinstance(data, scipy.sparse.csr_matrix):
            self._init_from_csr(data)
        elif isinstance(data, scipy.sparse.csc_matrix):
            self._init_from_csc(data)
        elif isinstance(data, np.ndarray):
            self._init_from_npy2d(data, missing, nthread)
        elif isinstance(data, DataTable):
            self._init_from_dt(data, nthread)
        else:
            try:
                csr = scipy.sparse.csr_matrix(data)
                self._init_from_csr(csr)
            except:
                raise TypeError('can not initialize DMatrix from'
                                ' {}'.format(type(data).__name__))

        if label is not None:
            if isinstance(label, np.ndarray):
                self.set_label_npy2d(label)
            else:
                self.set_label(label)
        if weight is not None:
            if isinstance(weight, np.ndarray):
                self.set_weight_npy2d(weight)
            else:
                self.set_weight(weight)

        self.feature_names = feature_names
        self.feature_types = feature_types
def __init__ ( self , data , label = None , missing = None , weight = None , silent = False , feature_names = None , feature_types = None , nthread = None ) : if data is None : self . handle = None if feature_names is not None : self . _feature_names = feature_names if feature_types is not None : self . _feature_types = feature_types return data , feature_names , feature_types = _maybe_pandas_data ( data , feature_names , feature_types ) data , feature_names , feature_types = _maybe_dt_data ( data , feature_names , feature_types ) label = _maybe_pandas_label ( label ) label = _maybe_dt_array ( label ) weight = _maybe_dt_array ( weight ) if isinstance ( data , list ) : warnings . warn ( 'Initializing DMatrix from List is deprecated.' , DeprecationWarning ) if isinstance ( data , STRING_TYPES ) : handle = ctypes . c_void_p ( ) _check_call ( _LIB . XGDMatrixCreateFromFile ( c_str ( data ) , ctypes . c_int ( silent ) , ctypes . byref ( handle ) ) ) self . handle = handle elif isinstance ( data , scipy . sparse . csr_matrix ) : self . _init_from_csr ( data ) elif isinstance ( data , scipy . sparse . csc_matrix ) : self . _init_from_csc ( data ) elif isinstance ( data , np . ndarray ) : self . _init_from_npy2d ( data , missing , nthread ) elif isinstance ( data , DataTable ) : self . _init_from_dt ( data , nthread ) else : try : csr = scipy . sparse . csr_matrix ( data ) self . _init_from_csr ( csr ) except : raise TypeError ( 'can not initialize DMatrix from' ' {}' . format ( type ( data ) . __name__ ) ) if label is not None : if isinstance ( label , np . ndarray ) : self . set_label_npy2d ( label ) else : self . set_label ( label ) if weight is not None : if isinstance ( weight , np . ndarray ) : self . set_weight_npy2d ( weight ) else : self . set_weight ( weight ) self . feature_names = feature_names self . feature_types = feature_types
Parameters
        ----------
        data : string/numpy.array/scipy.sparse/pd.DataFrame/dt.Frame
            Data source of DMatrix.
            When data is string type, it represents the path libsvm format txt file,
            or binary file that xgboost can read from.
        label : list or numpy 1-D array, optional
            Label of the training data.
        missing : float, optional
            Value in the data which needs to be present as a missing value. If
            None, defaults to np.nan.
        weight : list or numpy 1-D array , optional
            Weight for each instance.

            .. note:: For ranking task, weights are per-group.

                In ranking task, one weight is assigned to each group (not each data
                point). This is because we only care about the relative ordering of
                data points within each group, so it doesn't make sense to assign
                weights to individual data points.

        silent : boolean, optional
            Whether print messages during construction
        feature_names : list, optional
            Set names for features.
        feature_types : list, optional
            Set types for features.
        nthread : integer, optional
            Number of threads to use for loading data from numpy array. If -1,
            uses maximum threads available on the system.