R xgboost - 如何使用本地数据文件?
R xgboost - how to use local data files?
我有一个大数据集,我正在尝试使用 R 的包 xgboost
对其执行回归。
函数xgboost
说参数data
可以是本地数据文件,据我理解应该是文件名要使用的。但是没有关于它的进一步规范,所以我的问题是这个文件究竟应该如何。
我试过了
random=matrix(rnorm(15),5,3)
colnames(random)=c("first","second","label")
write.csv(random,"random.csv")
bst <- xgboost(data = "random.csv",
nthread = 7,
nround = 3,
objective="reg:linear",
verbose=FALSE)
但是 returns
6x0 matrix with 0 entries is loaded from random.csv
Error in xgb.iter.update(bst$handle, dtrain, i - 1, obj) :
NumCol:need column access
非常感谢!
遗憾的是,我还没有被允许发表评论,这对于正确的回答来说有点天真,但只是为了确定:
- 您确定 R
位于正确的文件夹中吗?尝试 getwd()
检查您所在的工作目录,然后 setwd()
更改它。
我稍后会删除我的答案,因为我认为它不完整,
问候,
丹尼尔
xgboost
本地数据文件输入不支持csv
。引自此link
Currently XGBoost supports local data files in the libsvm format. - See more at: http://blog.nycdatascience.com/uncategorized/xgboost-introduction/#sthash.bmlHst0T.dpuf
有关 libsvm 格式的更多信息,请参阅 this Cross Validated Question/Answer。
希望对您有所帮助。
我有一个大数据集,我正在尝试使用 R 的包 xgboost
对其执行回归。
函数xgboost
说参数data
可以是本地数据文件,据我理解应该是文件名要使用的。但是没有关于它的进一步规范,所以我的问题是这个文件究竟应该如何。
我试过了
random=matrix(rnorm(15),5,3)
colnames(random)=c("first","second","label")
write.csv(random,"random.csv")
bst <- xgboost(data = "random.csv",
nthread = 7,
nround = 3,
objective="reg:linear",
verbose=FALSE)
但是 returns
6x0 matrix with 0 entries is loaded from random.csv
Error in xgb.iter.update(bst$handle, dtrain, i - 1, obj) :
NumCol:need column access
非常感谢!
遗憾的是,我还没有被允许发表评论,这对于正确的回答来说有点天真,但只是为了确定:
- 您确定 R
位于正确的文件夹中吗?尝试 getwd()
检查您所在的工作目录,然后 setwd()
更改它。
我稍后会删除我的答案,因为我认为它不完整,
问候,
丹尼尔
xgboost
本地数据文件输入不支持csv
。引自此link
Currently XGBoost supports local data files in the libsvm format. - See more at: http://blog.nycdatascience.com/uncategorized/xgboost-introduction/#sthash.bmlHst0T.dpuf
有关 libsvm 格式的更多信息,请参阅 this Cross Validated Question/Answer。
希望对您有所帮助。