src/sagemaker_xgboost_container/encoder.py
def libsvm_to_dmatrix(string_like):  # type: (bytes) -> xgb.DMatrix
    """Convert a LIBSVM string representation to a DMatrix object.
    Args:
        string_like (bytes): LIBSVM string.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    """
    temp_file_location = None
    try:
        with tempfile.NamedTemporaryFile(delete=False) as libsvm_file:
            temp_file_location = libsvm_file.name
            libsvm_file.write(string_like)

        dmatrix = xgb.DMatrix(temp_file_location)
    finally:
        if temp_file_location and os.path.exists(temp_file_location):
            os.remove(temp_file_location)

    return dmatrix
Convert a LIBSVM string representation to a DMatrix object.
    Args:
        string_like (bytes): LIBSVM string.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    
Convert a LIBSVM string representation to a DMatrix object.
Convert a LIBSVM string representation to a DMatrix object .
def libsvm_to_dmatrix(string_like):  
    temp_file_location = None
    try:
        with tempfile.NamedTemporaryFile(delete=False) as libsvm_file:
            temp_file_location = libsvm_file.name
            libsvm_file.write(string_like)
        dmatrix = xgb.DMatrix(temp_file_location)
    finally:
        if temp_file_location and os.path.exists(temp_file_location):
            os.remove(temp_file_location)
    return dmatrix
def libsvm_to_dmatrix ( string_like ) : temp_file_location = None try : with tempfile . NamedTemporaryFile ( delete = False ) as libsvm_file : temp_file_location = libsvm_file . name libsvm_file . write ( string_like ) dmatrix = xgb . DMatrix ( temp_file_location ) finally : if temp_file_location and os . path . exists ( temp_file_location ) : os . remove ( temp_file_location ) return dmatrix
Convert a LIBSVM string representation to a DMatrix object.
Convert a LIBSVM string representation to a DMatrix object .
# type: (bytes) -> xgb.DMatrix """Convert a LIBSVM string representation to a DMatrix object.
    Args:
        string_like (bytes): LIBSVM string.
    Returns:
        (xgb.DMatrix): XGBoost DataMatrix
    """
None
(xgb.DMatrix)
string_like
None