[Breaking] Require format to be specified in input URI. (#9077)
Previously, we use `libsvm` as default when format is not specified. However, the dmlc data parser is not particularly robust against errors, and the most common type of error is undefined format. Along with which, we will recommend users to use other data loader instead. We will continue the maintenance of the parsers as it's currently used for many internal tests including federated learning.
This commit is contained in:
@@ -882,5 +882,12 @@ def data_dir(path: str) -> str:
|
||||
return os.path.join(demo_dir(path), "data")
|
||||
|
||||
|
||||
def load_agaricus(path: str) -> Tuple[xgb.DMatrix, xgb.DMatrix]:
|
||||
dpath = data_dir(path)
|
||||
dtrain = xgb.DMatrix(os.path.join(dpath, "agaricus.txt.train?format=libsvm"))
|
||||
dtest = xgb.DMatrix(os.path.join(dpath, "agaricus.txt.test?format=libsvm"))
|
||||
return dtrain, dtest
|
||||
|
||||
|
||||
def project_root(path: str) -> str:
|
||||
return normpath(os.path.join(demo_dir(path), os.path.pardir))
|
||||
|
||||
Reference in New Issue
Block a user