src/sagemaker_xgboost_container/encoder.py
def csv_to_dmatrix(string_like, dtype=None):  # type: (str) -> xgb.DMatrix
    """Convert a CSV object to a DMatrix object.
    Args:
        string_like (str): CSV string. Assumes the string has been stripped of leading or trailing newline chars.
        dtype (dtype, optional):  Data type of the resulting array. If None, the dtypes will be determined by the
                                        contents of each column, individually. This argument can only be used to
                                        'upcast' the array.  For downcasting, use the .astype(t) method.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    """
    sniff_delimiter = csv.Sniffer().sniff(string_like.split('\n')[0][:512]).delimiter
    delimiter = ',' if sniff_delimiter.isalnum() else sniff_delimiter
    logging.info("Determined delimiter of CSV input is \'{}\'".format(delimiter))

    np_payload = np.array(list(map(lambda x: _clean_csv_string(x, delimiter), string_like.split('\n')))).astype(dtype)
    return xgb.DMatrix(np_payload)
Convert a CSV object to a DMatrix object.
    Args:
        string_like (str): CSV string. Assumes the string has been stripped of leading or trailing newline chars.
        dtype (dtype, optional):  Data type of the resulting array. If None, the dtypes will be determined by the
                                        contents of each column, individually. This argument can only be used to
                                        'upcast' the array.  For downcasting, use the .astype(t) method.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    
Convert a CSV object to a DMatrix object.
Convert a CSV object to a DMatrix object .
def csv_to_dmatrix(string_like, dtype=None):  
    sniff_delimiter = csv.Sniffer().sniff(string_like.split('\n')[0][:512]).delimiter
    delimiter = ',' if sniff_delimiter.isalnum() else sniff_delimiter
    logging.info("Determined delimiter of CSV input is \'{}\'".format(delimiter))
    np_payload = np.array(list(map(lambda x: _clean_csv_string(x, delimiter), string_like.split('\n')))).astype(dtype)
    return xgb.DMatrix(np_payload)
def csv_to_dmatrix ( string_like , dtype = None ) : sniff_delimiter = csv . Sniffer ( ) . sniff ( string_like . split ( '\n' ) [ 0 ] [ : 512 ] ) . delimiter delimiter = ',' if sniff_delimiter . isalnum ( ) else sniff_delimiter logging . info ( "Determined delimiter of CSV input is \'{}\'" . format ( delimiter ) ) np_payload = np . array ( list ( map ( lambda x : _clean_csv_string ( x , delimiter ) , string_like . split ( '\n' ) ) ) ) . astype ( dtype ) return xgb . DMatrix ( np_payload )
Convert a CSV object to a DMatrix object.
Convert a CSV object to a DMatrix object .
# type: (str) -> xgb.DMatrix """Convert a CSV object to a DMatrix object.
    Args:
        string_like (str): CSV string. Assumes the string has been stripped of leading or trailing newline chars.
        dtype (dtype, optional):  Data type of the resulting array. If None, the dtypes will be determined by the
                                        contents of each column, individually. This argument can only be used to
                                        'upcast' the array.  For downcasting, use the .astype(t) method.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    """
None
(xgb.DMatrix)
string_like
CSV string. Assumes the string has been stripped of leading or trailing newline chars.
CSV string . Assumes the string has been stripped of leading or trailing newline chars .
dtype
Data type of the resulting array. If None, the dtypes will be determined by the
contents of each column, individually. This argument can only be used to
'upcast' the array.  For downcasting, use the .astype(t) method.
Data type of the resulting array . If None the dtypes will be determined by the contents of each column individually . This argument can only be used to ' upcast ' the array . For downcasting use the . astype ( t ) method .