-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lgbm.cv example #4
Comments
I think the example is outdated, not sure, I have to check that. I am going to add the code below as the example in my next push. Try this (change the working directory on line 8 and LGBM on line 32): library(Laurae)
library(stringi)
library(Matrix)
library(sparsity)
library(data.table)
remove(list = ls()) # WARNING: CLEANS EVERYTHING IN THE ENVIRONMENT
setwd("D:/Data Science/HousePrices") # CHANGE THIS TO WHATEVER TEMPORARY DIRECTORY WHERE YOU WANT TEMPORARY FILES
DT <- data.table(Split1 = c(rep(0, 50), rep(1, 50)), Split2 = rep(c(rep(0, 25), rep(0.5, 25)), 2))
DT$Split3 <- rep(c(rep(0, 10), rep(0.25, 15)), 4)
DT$Split4 <- rep(c(rep(0, 5), rep(0.1, 5), rep(0, 5), rep(0.1, 10)), 4)
DT$Split5 <- rep(c(rep(0, 5), rep(0.05, 5), rep(0, 10), rep(0.05, 5)), 4)
label <- c(rep(0, 25), rep(1, 25), rep(0, 25), rep(1, 25))
label <- as.numeric((DT$Split2 == 0) & (DT$Split1 == 0) & (DT$Split3 == 0))
label <- as.numeric((DT$Split2 == 0) & (DT$Split1 == 0) & (DT$Split3 == 0) & (DT$Split4 == 0) | ((DT$Split2 == 0.5) & (DT$Split1 == 1) & (DT$Split3 == 0.25) & (DT$Split4 == 0.1) & (DT$Split5 == 0)) | ((DT$Split1 == 0) & (DT$Split2 == 0.5)))
trained <- lgbm.cv(y_train = label,
x_train = DT,
bias_train = NA,
folds = 5,
unicity = TRUE,
application = "binary",
num_iterations = 1,
early_stopping_rounds = 1,
learning_rate = 5,
num_leaves = 16,
min_data_in_leaf = 1,
min_sum_hessian_in_leaf = 1,
tree_learner = "serial",
num_threads = 1,
lgbm_path = "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe",
workingdir = file.path(getwd()),
validation = FALSE,
files_exist = FALSE,
verbose = TRUE,
is_training_metric = TRUE,
save_binary = TRUE,
metric = "binary_logloss")
str(trained) I am getting this output:
and List of 3
$ Models :List of 5
..$ 1:List of 8
.. ..$ Model : chr [1:14] "max_feature_idx=-1" "sigmoid=1" "" "Tree=0" ...
.. ..$ Path : chr "D:/Data Science/HousePrices/temp"
.. ..$ Name : chr "lgbm_model.txt"
.. ..$ lgbm : chr "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe"
.. ..$ Train : chr "lgbm_train.csv"
.. ..$ Valid : chr "lgbm_val.csv"
.. ..$ Test : logi NA
.. ..$ Validation: num [1:20] 1 1 1 1 1 ...
..$ 2:List of 8
.. ..$ Model : chr [1:14] "max_feature_idx=-1" "sigmoid=1" "" "Tree=0" ...
.. ..$ Path : chr "D:/Data Science/HousePrices/temp"
.. ..$ Name : chr "lgbm_model.txt"
.. ..$ lgbm : chr "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe"
.. ..$ Train : chr "lgbm_train.csv"
.. ..$ Valid : chr "lgbm_val.csv"
.. ..$ Test : logi NA
.. ..$ Validation: num [1:20] 1 1 1 1 1 ...
..$ 3:List of 8
.. ..$ Model : chr [1:14] "max_feature_idx=-1" "sigmoid=1" "" "Tree=0" ...
.. ..$ Path : chr "D:/Data Science/HousePrices/temp"
.. ..$ Name : chr "lgbm_model.txt"
.. ..$ lgbm : chr "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe"
.. ..$ Train : chr "lgbm_train.csv"
.. ..$ Valid : chr "lgbm_val.csv"
.. ..$ Test : logi NA
.. ..$ Validation: num [1:20] 1 1 1 1 1 ...
..$ 4:List of 8
.. ..$ Model : chr [1:14] "max_feature_idx=-1" "sigmoid=1" "" "Tree=0" ...
.. ..$ Path : chr "D:/Data Science/HousePrices/temp"
.. ..$ Name : chr "lgbm_model.txt"
.. ..$ lgbm : chr "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe"
.. ..$ Train : chr "lgbm_train.csv"
.. ..$ Valid : chr "lgbm_val.csv"
.. ..$ Test : logi NA
.. ..$ Validation: num [1:20] 1 1 1 1 1 ...
..$ 5:List of 8
.. ..$ Model : chr [1:14] "max_feature_idx=-1" "sigmoid=1" "" "Tree=0" ...
.. ..$ Path : chr "D:/Data Science/HousePrices/temp"
.. ..$ Name : chr "lgbm_model.txt"
.. ..$ lgbm : chr "C:/xgboost/LightGBM/windows/x64/Release/lightgbm.exe"
.. ..$ Train : chr "lgbm_train.csv"
.. ..$ Valid : chr "lgbm_val.csv"
.. ..$ Test : logi NA
.. ..$ Validation: num [1:20] 1 1 1 1 1 ...
$ Validation:List of 2
..$ : num [1:100] 1 1 1 1 1 ...
..$ :List of 5
.. ..$ : num [1:20] 1 1 1 1 1 ...
.. ..$ : num [1:20] 1 1 1 1 1 ...
.. ..$ : num [1:20] 1 1 1 1 1 ...
.. ..$ : num [1:20] 1 1 1 1 1 ...
.. ..$ : num [1:20] 1 1 1 1 1 ...
$ Weights : num [1:5] 0.2 0.2 0.2 0.2 0.2 |
Thanks! |
(You can close this if you want or leave it open) |
Another (potentially silly) question: If I followed the installation guide in the readme for linux, what might my lightgbm path be? |
I fixed the LightGBM functions' documentation in commit @4fe8e2b35acabbe8979cd3181dca8f004a03ee38.
Your LightGBM should be on the same directory as your LightGBM download. You can find out where it has been compiled using this on your LightGBM path: ls -d */ If you installed in a folder named "(...)/LightGBM" path, it should the |
I didn't even have lightgbm installed! lol. So for future reference, this error means lightgbm isn't installed, or you're pointing at the wrong path:
|
I also got this by omitting the path.
I installed on OS X as shown here...
Might it be possible to make the
It successfully wrote the .conf and train_1.csv and val_1.csv files. I'm not sure waht the other errors are about where it appears to look for a /bin/sh type executable or has the connection failure with no model_1.txt. |
The lgbm_path in mac was the location of unix executable that you build from source. |
I'm having trouble figuring out the example in
?lgbm.cv
. It looks like it's on the housing price dataset, but I'm not 100% sure. When I try to run it, I get the following error:Do you have a working example that runs on your machine I could try out, to make sure my installation is working?
The text was updated successfully, but these errors were encountered: