nuanio / xgboost-node Goto Github PK
View Code? Open in Web Editor NEWRun XGBoost model and make predictions in Node.js
License: Other
Run XGBoost model and make predictions in Node.js
License: Other
I installed this package on Amazon Linux machine and copied the whole node_modules
folder directly to my Lambda zip file. This ensures that the package is built in the same environment that is supposed to run.
However, when trying to require
the package it fails with the following message:
{
"errorMessage": "/lib64/libm.so.6: version `GLIBC_2.23' not found (required by /var/task/node_modules/xgboost/build/Release/xgboost.node)",
"errorType": "Error",
"stackTrace": [
"Object.Module._extensions..node (module.js:597:18)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"bindings (/var/task/node_modules/bindings/bindings.js:81:44)",
"Object.<anonymous> (/var/task/node_modules/xgboost/index.js:6:11)",
"Module._compile (module.js:570:32)"
]
}
I'm guessing there might be some dependencies that don't exists in node_modules/xgboost
folder.
Any ideas or workaround to get this working on AWS Lambda?
I'm having issues installing xgboost-node
$ sudo hostnamectl | tail -n 3
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 5.10.142-19743-gd301e86c39f7
Architecture: x86-64
$ node --version
v18.12.1
$ g++ --version
g++ (Debian 8.3.0-6) 8.3.0
CXXFLAGS="--std=c++14" npm install --user xgboost
gives a bunch of errors that begin
npm ERR! done building library
npm ERR! make: Entering directory '/home/mchonofsky/traintracker/heroku/amtrak-lol/node_modules/xgboost/build'
npm ERR! CXX(target) Release/obj.target/xgboost/src/index.o
npm ERR! CXX(target) Release/obj.target/xgboost/src/xgmodel.o
npm ERR! make: Leaving directory '/home/mchonofsky/traintracker/heroku/amtrak-lol/node_modules/xgboost/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.7.3 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/mchonofsky/traintracker/heroku/amtrak-lol/node_modules/xgboost/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/mchonofsky/.cache/node-gyp/18.12.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/mchonofsky/.cache/node-gyp/18.12.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/mchonofsky/.cache/node-gyp/18.12.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/mchonofsky/traintracker/heroku/amtrak-lol/node_modules/xgboost',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/base.h:4,
npm ERR! from ../src/xgmatrix.h:4,
npm ERR! from ../src/index.cc:1:
npm ERR! /home/mchonofsky/.cache/node-gyp/18.12.1/include/node/node.h:976:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm ERR! (node::addon_register_func) (regfunc), \
npm ERR! ^
npm ERR! /home/mchonofsky/.cache/node-gyp/18.12.1/include/node/node.h:1010:3: note: in expansion of macro ‘NODE_MODULE_X’
npm ERR! NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
npm ERR! ^~~~~~~~~~~~~
npm ERR! ../src/index.cc:10:1: note: in expansion of macro ‘NODE_MODULE’
npm ERR! NODE_MODULE(xgboost, InitAll)
npm ERR! ^~~~~~~~~~~
npm ERR! ../src/xgmodel.cc: In static member function ‘static void XGModel::Init(v8::Local<v8::Object>)’:
npm ERR! ../src/xgmodel.cc:31:38: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
npm ERR! constructor.Reset(tpl->GetFunction());
Any ideas on how to fix the issue?
the image URL of Travis badge is not correct: https://travis-ci.org/nuanio/xgboost-node.svg?branch=update-readme , which is point to update-readme
branch
n/a
n/a
npm install xgboost
fails on Mac OS
Mac OS High Sierra 10.13.4
$ uname -a
Darwin 17.5.0 Darwin Kernel Version 17.5.0; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64
$ node --version
v9.7.1
$ CC --version
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ gcc-7 --version
gcc-7 (Homebrew GCC 7.3.0_1) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ npm install xgboost
> [email protected] install /workspace/ews-360-sim/node_modules/xgboost
> bash ./build.sh; node-gyp rebuild
c++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
clang: error: unsupported option '-fopenmp'
make: *** [build/learner.o] Error 1
-----------------------------
Building multi-thread xgboost failed
Start to build single-thread xgboost
rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
rm -f -rf build_tests *.gcov tests/cpp/xgboost_test
cd dmlc-core; /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; cd /workspace/ews-360-sim/node_modules/xgboost/xgboost
Makefile:9: make/config.mk: No such file or directory
make[1]: *** No rule to make target `make/config.mk'. Stop.
cd rabit; /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; cd /workspace/ews-360-sim/node_modules/xgboost/xgboost
...
...
clang: error: no such file or directory: 'dmlc-core/libdmlc.a'
make: *** [lib/libxgboost.dylib] Error 1
done building library
CXX(target) Release/obj.target/xgboost/src/index.o
CXX(target) Release/obj.target/xgboost/src/xgmodel.o
../src/xgmodel.cc:176:13: warning: 'Call' is deprecated [-Wdeprecated-declarations]
callback->Call(2, argv);
^
../../nan/nan.h:1617:3: note: 'Call' has been explicitly marked deprecated here
NAN_DEPRECATED inline v8::Local<v8::Value>
^
../../nan/nan.h:98:40: note: expanded from macro 'NAN_DEPRECATED'
# define NAN_DEPRECATED __attribute__((deprecated))
^
1 warning generated.
CXX(target) Release/obj.target/xgboost/src/xgmatrix.o
SOLINK_MODULE(target) Release/xgboost.node
clang: error: no such file or directory: '../xgboost/dmlc-core/libdmlc.a'
make: *** [Release/xgboost.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:127:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/8.1.4/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Google Drive/workspace/ews-360-sim/node_modules/xgboost
gyp ERR! node -v v9.7.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN @fortawesome/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `bash ./build.sh; node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /.npm/_logs/2018-04-26T21_15_07_146Z-debug.log
$ CC="gcc-7" CXX="g++-7" npm i xgboost
> [email protected] install /workspace/ews-360-sim/node_modules/xgboost
> bash ./build.sh; node-gyp rebuild
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/learner.cc -o build/learner.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/logging.cc -o build/logging.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api.o src/c_api/c_api.cc >build/c_api/c_api.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/c_api/c_api.cc -o build/c_api/c_api.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/c_api/c_api_error.cc -o build/c_api/c_api_error.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/common/common.o src/common/common.cc >build/common/common.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/common/common.cc -o build/common/common.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/common/hist_util.o src/common/hist_util.cc >build/common/hist_util.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/common/hist_util.cc -o build/common/hist_util.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/data/data.o src/data/data.cc >build/data/data.d
g++-7 -c -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp src/data/data.cc -o build/data/data.o
g++-7 -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -fopenmp -MM -MT build/data/simple_csr_source.o src/data/simple_csr_source.cc >build/data/simple_csr_source.d
...
...
...
g++-7: error: dmlc-core/libdmlc.a: No such file or directory
make: *** [lib/libxgboost.dylib] Error 1
-----------------------------
Building multi-thread xgboost failed
Start to build single-thread xgboost
rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
rm -f -rf build_tests *.gcov tests/cpp/xgboost_test
cd dmlc-core; /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; cd /workspace/ews-360-sim/node_modules/xgboost/xgboost
Makefile:9: make/config.mk: No such file or directory
make[1]: *** No rule to make target `make/config.mk'. Stop.
cd rabit; /Applications/Xcode.app/Contents/Developer/usr/bin/make clean; cd /workspace/ews-360-sim/node_modules/xgboost/xgboost
...
...
...
metric.o build/metric/metric.o build/metric/multiclass_metric.o build/metric/rank_metric.o build/objective/multiclass_obj.o build/objective/objective.o build/objective/rank_obj.o build/objective/regression_obj.o build/tree/tree_model.o build/tree/tree_updater.o build/tree/updater_colmaker.o build/tree/updater_fast_hist.o build/tree/updater_histmaker.o build/tree/updater_prune.o build/tree/updater_refresh.o build/tree/updater_skmaker.o build/tree/updater_sync.o dmlc-core/libdmlc.a rabit/lib/librabit_empty.a -pthread -lm
g++-7: error: dmlc-core/libdmlc.a: No such file or directory
make: *** [lib/libxgboost.dylib] Error 1
done building library
CXX(target) Release/obj.target/xgboost/src/index.o
g++-7: error: unrecognized command line option '-stdlib=libc++'
make: *** [Release/obj.target/xgboost/src/index.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at ChildProcess.emit (events.js:127:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/8.1.4/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Google Drive/workspace/ews-360-sim/node_modules/xgboost
gyp ERR! node -v v9.7.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `bash ./build.sh; node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /.npm/_logs/2018-04-26T21_22_18_780Z-debug.log
Is compilation on Mac OS supported as claimed in the README?
hi, is there any plan to update the xgboost training API in the near future, it would be very useful to train xgboost model with nodejs
Add async predict function to model class
Running npm install xgboost won't fully install.
Should it work with the following set-up?
root@vm:~# npm --version
6.2.0
root@vm:~# node --version
v10.8.0
root@vm:~# uname -a
Linux sketchy 3.16.0-4-amd64 #1 SMP Debian 3.16.51-2 (2017-12-03) x86_64 GNU/Linux
root@vm:~# c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10+deb8u1' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10+deb8u1)
Hi,
when I evaluate the model result in python it got different result from node.js in production. It turns out it is the problem with handling Null values. We used the API you mentioned: matrix(data, row, col, missing), and there is still about ~10% differences in terms of scores.
Could you please tell me what could the problem be, or give an example or how to deal with it? Right now we are doing something like this in production:
featureValues.push(item[col.name] || NaN)
})
})
featureValues = new Float32Array(featureValues)
let inputMatrix = new xgboost.matrix(featureValues,
row,
column, NaN)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.