Open anuragreddygv323 opened 5 years ago
Original "lightgbm" provides a good python API, which you can refer for using it in jupyter. https://lightgbm.readthedocs.io/en/latest/Python-Intro.html Thus, compile the files we provide, then you can use our code in Jupiter. I will consider adding a test python code sooner for illustration, but you can first have a quick try.
root@ml-dev-66d476d4dd-c5vvk:~/Unbiased_LambdaMart/Unbias_LightGBM/build# make -j4 Scanning dependencies of target lightgbm Scanning dependencies of target _lightgbm [ 3%] Building CXX object CMakeFiles/_lightgbm.dir/src/lightgbm_R.cpp.o [ 3%] Building CXX object CMakeFiles/_lightgbm.dir/src/c_api.cpp.o [ 4%] Building CXX object CMakeFiles/_lightgbm.dir/src/application/application.cpp.o [ 6%] Building CXX object CMakeFiles/lightgbm.dir/src/main.cpp.o [ 8%] Building CXX object CMakeFiles/lightgbm.dir/src/application/application.cpp.o [ 9%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/boosting.cpp.o [ 11%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt.cpp.o [ 13%] Building CXX object CMakeFiles/lightgbm.dir/src/boosting/boosting.cpp.o [ 14%] Building CXX object CMakeFiles/lightgbm.dir/src/boosting/gbdt.cpp.o [ 16%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt_model_text.cpp.o [ 18%] Building CXX object CMakeFiles/lightgbm.dir/src/boosting/gbdt_model_text.cpp.o [ 19%] Building CXX object CMakeFiles/lightgbm.dir/src/boosting/gbdt_prediction.cpp.o [ 21%] Building CXX object CMakeFiles/lightgbm.dir/src/boosting/prediction_early_stop.cpp.o [ 22%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/gbdt_prediction.cpp.o [ 24%] Building CXX object CMakeFiles/lightgbm.dir/src/io/bin.cpp.o [ 26%] Building CXX object CMakeFiles/lightgbm.dir/src/io/config.cpp.o [ 27%] Building CXX object CMakeFiles/_lightgbm.dir/src/boosting/prediction_early_stop.cpp.o [ 29%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/bin.cpp.o [ 31%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/config.cpp.o [ 32%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset.cpp.o [ 34%] Building CXX object CMakeFiles/lightgbm.dir/src/io/dataset.cpp.o [ 36%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/dataset_loader.cpp.o [ 37%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/file_io.cpp.o [ 39%] Building CXX object CMakeFiles/lightgbm.dir/src/io/dataset_loader.cpp.o [ 40%] Building CXX object CMakeFiles/lightgbm.dir/src/io/file_io.cpp.o [ 42%] Building CXX object CMakeFiles/lightgbm.dir/src/io/json11.cpp.o [ 44%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/json11.cpp.o [ 45%] Building CXX object CMakeFiles/lightgbm.dir/src/io/metadata.cpp.o [ 47%] Building CXX object CMakeFiles/lightgbm.dir/src/io/parser.cpp.o [ 49%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/metadata.cpp.o [ 50%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/parser.cpp.o [ 52%] Building CXX object CMakeFiles/lightgbm.dir/src/io/tree.cpp.o [ 54%] Building CXX object CMakeFiles/_lightgbm.dir/src/io/tree.cpp.o [ 55%] Building CXX object CMakeFiles/lightgbm.dir/src/metric/dcg_calculator.cpp.o [ 57%] Building CXX object CMakeFiles/lightgbm.dir/src/metric/metric.cpp.o [ 59%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/dcg_calculator.cpp.o [ 60%] Building CXX object CMakeFiles/_lightgbm.dir/src/metric/metric.cpp.o [ 62%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linker_topo.cpp.o [ 63%] Building CXX object CMakeFiles/lightgbm.dir/src/network/linker_topo.cpp.o [ 65%] Building CXX object CMakeFiles/lightgbm.dir/src/network/linkers_mpi.cpp.o [ 67%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_mpi.cpp.o [ 68%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/linkers_socket.cpp.o [ 70%] Building CXX object CMakeFiles/_lightgbm.dir/src/network/network.cpp.o [ 72%] Building CXX object CMakeFiles/lightgbm.dir/src/network/linkers_socket.cpp.o [ 73%] Building CXX object CMakeFiles/lightgbm.dir/src/network/network.cpp.o [ 75%] Building CXX object CMakeFiles/lightgbm.dir/src/objective/objective_function.cpp.o [ 77%] Building CXX object CMakeFiles/_lightgbm.dir/src/objective/objective_function.cpp.o [ 78%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/data_parallel_tree_learner.cpp.o [ 80%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/feature_parallel_tree_learner.cpp.o [ 81%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/data_parallel_tree_learner.cpp.o [ 83%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/feature_parallel_tree_learner.cpp.o [ 85%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/gpu_tree_learner.cpp.o [ 86%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/gpu_tree_learner.cpp.o [ 88%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/serial_tree_learner.cpp.o [ 90%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/serial_tree_learner.cpp.o [ 91%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/tree_learner.cpp.o [ 93%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/tree_learner.cpp.o [ 95%] Building CXX object CMakeFiles/_lightgbm.dir/src/treelearner/voting_parallel_tree_learner.cpp.o [ 96%] Building CXX object CMakeFiles/lightgbm.dir/src/treelearner/voting_parallel_tree_learner.cpp.o [ 98%] Linking CXX shared library ../lib_lightgbm.so [ 98%] Built target _lightgbm [100%] Linking CXX executable ../lightgbm [100%] Built target lightgbm
**Compiled it. Now how to call this in a notebook. I tried doing
import lightgbm as lgb
error: ModuleNotFoundError: No module named 'lightgbm'
could you help. After compiling, what to do to make sure that I can call it like a typical package on Jupyter notebook.**
Sorry about previous mistake. I checked the python interface, and find that there are some parts need to be modified to adapt our changes. I will fix this issue as soon as possible.
Meanwhile, I also provide a really simple script for you to run. After you compile the model, you can find a compiled "lightgbm" file. Move this file into "examples/lambdarank", then execute it by:
./lightgbm config="train.conf"
And you can see the log and the trained model.
Using the jupyter is exactly the same as modifying "train.conf", so you can have a try before I modify the python interface.
Hey @acbull, thanks for contributing the great Unbiased LambdaMart. May I know if there's any update on the python API? Thanks!
Could you let me know how to use it in Jupyter notebook.
Should I add something to lightgbm package ?
Can u add an example