[PATCH 0/3] Add xgboost.

  • Done
  • quality assurance status badge
Details
2 participants
  • Leo Famulari
  • Vinicius Monego
Owner
unassigned
Submitted by
Vinicius Monego
Severity
normal
V
V
Vinicius Monego wrote on 13 May 2021 01:56
(address . guix-patches@gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210512235649.516594-1-monego@posteo.net
This patchset adds the binaries, C++ library and Python frontend for the XGBoost gradient boosting framework.

I noticed r-xgboost in the packages, which compiles a bundled copy of xgboost. Ideally it would inherit from xgboost and build from there, but I do not work with R so I can't help with this.

I also had to do some dirty hack in the python patch for reading version and using libxgboost from the xgboost package. Lmk is there is a better way to handle this.

Vinicius Monego (3):
gnu: Add dmlc-core.
gnu: Add xgboost.
gnu: Add python-xgboost.

gnu/local.mk | 2 +
gnu/packages/machine-learning.scm | 125 ++++++++++++++++++
...xgboost-python-use-system-libxgboost.patch | 69 ++++++++++
.../xgboost-use-system-dmlc-core.patch | 35 +++++
4 files changed, 231 insertions(+)
create mode 100644 gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
create mode 100644 gnu/packages/patches/xgboost-use-system-dmlc-core.patch

--
2.31.1
V
V
Vinicius Monego wrote on 13 May 2021 01:58
[PATCH 1/3] gnu: Add dmlc-core.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210512235844.516970-1-monego@posteo.net
* gnu/packages/machine-learning.scm (dmlc-core): New variable.
---
gnu/packages/machine-learning.scm | 32 +++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 837ebbba67..9d6c5505f7 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1927,6 +1927,38 @@ together building blocks and a subclassing API with an imperative style for
advanced research.")
(license license:asl2.0)))
+(define-public dmlc-core
+ ;; Version 0.4 is too old for xgboost.
+ (let ((version "0.5")
+ (commit "f00e3ec7abc9f293a1b7061157b0a4e22a735cf5")
+ (revision "0"))
+ (package
+ (name "dmlc-core")
+ (version (git-version version revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/dmlc-core")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1x4ad1jhn84fywlk031fmv1kxyiscclmrqn9hhj8gz0mh7z9vcrh"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags
+ (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (home-page "https://github.com/dmlc/dmlc-core")
+ (synopsis "Common bricks library for machine learning")
+ (description
+ "DMLC-Core is the backbone library to support all DMLC projects,
+offers the bricks to build efficient and scalable distributed machine
+learning libraries.")
+ (license license:asl2.0))))
+
(define-public python-iml
(package
(name "python-iml")
--
2.31.1
V
V
Vinicius Monego wrote on 13 May 2021 01:58
[PATCH 2/3] gnu: Add xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210512235844.516970-2-monego@posteo.net
* gnu/packages/machine-learning.scm (xgboost): New variable.
---
gnu/local.mk | 2 +
gnu/packages/machine-learning.scm | 33 +++++++++
...xgboost-python-use-system-libxgboost.patch | 69 +++++++++++++++++++
.../xgboost-use-system-dmlc-core.patch | 35 ++++++++++
4 files changed, 139 insertions(+)
create mode 100644 gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
create mode 100644 gnu/packages/patches/xgboost-use-system-dmlc-core.patch

Toggle diff (175 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 37166bb2fc..e1d382c543 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1823,6 +1823,8 @@ dist_patch_DATA = \
%D%/packages/patches/xf86-video-voodoo-pcitag.patch \
%D%/packages/patches/xfce4-panel-plugins.patch \
%D%/packages/patches/xfce4-settings-defaults.patch \
+ %D%/packages/patches/xgboost-python-use-system-libxgboost.patch \
+ %D%/packages/patches/xgboost-use-system-dmlc-core.patch \
%D%/packages/patches/xmonad-dynamic-linking.patch \
%D%/packages/patches/xplanet-1.3.1-cxx11-eof.patch \
%D%/packages/patches/xplanet-1.3.1-libdisplay_DisplayOutput.cpp.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 9d6c5505f7..fd10de427f 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1959,6 +1959,39 @@ offers the bricks to build efficient and scalable distributed machine
learning libraries.")
(license license:asl2.0))))
+(define-public xgboost
+ (package
+ (name "xgboost")
+ (version "1.4.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/xgboost")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "xgboost-python-use-system-libxgboost.patch"
+ "xgboost-use-system-dmlc-core.patch"))
+ (sha256
+ (base32 "0ixacmpcj844c09xigi1vd4rrckld84k32iarvhnvvm6yjih756y"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (inputs
+ `(("dmlc-core" ,dmlc-core)))
+ (home-page "https://xgboost.ai/")
+ (synopsis "Gradient boosting (GBDT, GBRT or GBM) library in C++")
+ (description
+ "XGBoost is an optimized distributed gradient boosting library designed
+to be highly efficient, flexible and portable. It implements machine learning
+algorithms under the Gradient Boosting framework. XGBoost provides a parallel
+tree boosting (also known as GBDT, GBM) that solve many data science problems
+in a fast and accurate way.")
+ (license license:asl2.0)))
+
(define-public python-iml
(package
(name "python-iml")
diff --git a/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch b/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
new file mode 100644
index 0000000000..992e6bb3fd
--- /dev/null
+++ b/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
@@ -0,0 +1,69 @@
+From 768192b9c6700f0ae6b750c56b114d7022692a0b Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:30:55 -0300
+Subject: [PATCH] Python wrapper: use system libxgboost.
+
+---
+This patch was extended from the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/setup.py.patch/
+
+ python-package/setup.py | 4 ++--
+ python-package/xgboost/__init__.py | 5 ++---
+ python-package/xgboost/libpath.py | 5 +++++
+ 3 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/python-package/setup.py b/python-package/setup.py
+index a2feb766..b8b78429 100644
+--- a/python-package/setup.py
++++ b/python-package/setup.py
+@@ -312,11 +312,11 @@ if __name__ == '__main__':
+ 'numpy',
+ 'scipy',
+ ],
+- ext_modules=[CMakeExtension('libxgboost')],
++ # ext_modules=[CMakeExtension('libxgboost')],
+ cmdclass={
+ 'build_ext': BuildExt,
+ 'sdist': Sdist,
+- 'install_lib': InstallLib,
++ # 'install_lib': InstallLib,
+ 'install': Install
+ },
+ extras_require={
+diff --git a/python-package/xgboost/__init__.py b/python-package/xgboost/__init__.py
+index e0ff434d..658e84e6 100644
+--- a/python-package/xgboost/__init__.py
++++ b/python-package/xgboost/__init__.py
+@@ -21,9 +21,8 @@ try:
+ except ImportError:
+ pass
+
+-VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
+-with open(VERSION_FILE) as f:
+- __version__ = f.read().strip()
++# This variable will be set during substitution.
++__version__ = ''
+
+ __all__ = ['DMatrix', 'DeviceQuantileDMatrix', 'Booster',
+ 'train', 'cv',
+diff --git a/python-package/xgboost/libpath.py b/python-package/xgboost/libpath.py
+index f7a7d9cd..88d9d986 100644
+--- a/python-package/xgboost/libpath.py
++++ b/python-package/xgboost/libpath.py
+@@ -19,9 +19,14 @@ def find_lib_path() -> List[str]:
+ lib_path
+ List of all found library path to xgboost
+ """
++
++ # This variable will be set during substitution.
++ XGBOOST_PATH = ''
++
+ curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
+ dll_path = [
+ # normal, after installation `lib` is copied into Python package tree.
++ os.path.join(XGBOOST_PATH, 'lib'),
+ os.path.join(curr_path, 'lib'),
+ # editable installation, no copying is performed.
+ os.path.join(curr_path, os.path.pardir, os.path.pardir, 'lib'),
+--
+2.31.1
+
diff --git a/gnu/packages/patches/xgboost-use-system-dmlc-core.patch b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
new file mode 100644
index 0000000000..6209ae1f10
--- /dev/null
+++ b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
@@ -0,0 +1,35 @@
+From 34167cc105e47589b86b6f62da76e0ab744002dd Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:35:30 -0300
+Subject: [PATCH] Use dmlc-core from Guix.
+
+---
+This patch is a subset from the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/cmake.patch/
+
+Rabit is now developed as part of xgboost, so we don't build it separately.
+
+ CMakeLists.txt | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6cc19fbd..3b42bc17 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -150,11 +150,9 @@ endif (USE_OPENMP)
+
+ # dmlc-core
+ msvc_use_static_runtime()
+-add_subdirectory(${xgboost_SOURCE_DIR}/dmlc-core)
+-set_target_properties(dmlc PROPERTIES
+- CXX_STANDARD 14
+- CXX_STANDARD_REQUIRED ON
+- POSITION_INDEPENDENT_CODE ON)
++add_library(dmlc SHARED IMPORTED)
++find_library(DMLC_LIBRARY dmlc)
++set_property(TARGET dmlc PROPERTY IMPORTED_LOCATION "${DMLC_LIBRARY}")
+ if (MSVC)
+ target_compile_options(dmlc PRIVATE
+ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
+--
+2.31.1
+
--
2.31.1
V
V
Vinicius Monego wrote on 13 May 2021 01:58
[PATCH 3/3] gnu: Add python-xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210512235844.516970-3-monego@posteo.net
* gnu/packages/machine-learning.scm (python-xgboost): New variable.
---
gnu/packages/machine-learning.scm | 60 +++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

Toggle diff (73 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index fd10de427f..f7bb01f274 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1992,6 +1992,66 @@ tree boosting (also known as GBDT, GBM) that solve many data science problems
in a fast and accurate way.")
(license license:asl2.0)))
+(define-public python-xgboost
+ (package
+ (inherit xgboost)
+ (name "python-xgboost")
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Move python-package content to parent directory to silence
+ ;; some warnings about files not being found if we chdir.
+ (rename-file "python-package/xgboost" "xgboost")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/setup.cfg" "setup.cfg")
+ (rename-file "python-package/setup.py" "setup.py")
+
+ (with-directory-excursion "xgboost"
+ ;; Version is read from a VERSION file, but that file is not
+ ;; part of the installation.
+ (substitute* "__init__.py"
+ (("__version__ = ''")
+ (string-append "__version__ = " "'"
+ ,(package-version xgboost) "'")))
+ ;; The Python wrapper expects libxgboost to be found in the
+ ;; same source from where the wrapper builds. This workaround
+ ;; allows libxgboost to be used from the xgboost package.
+ (substitute* "libpath.py"
+ (("XGBOOST_PATH = ''")
+ (string-append "XGBOOST_PATH = "
+ "'" (assoc-ref inputs "xgboost") "'"))))
+ #t))
+ (replace 'check
+ ;; Python-specific tests are located in tests/python.
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "tests/python"
+ ;; FIXME: CLI tests fail with PermissionError.
+ "--ignore" "tests/python/test_cli.py" "-k"
+ (string-append
+ "not test_cli_regression_demo"
+ ;; The tests below open a network connection.
+ " and not test_model_compatibility"
+ " and not test_get_group"
+ " and not test_cv_no_shuffle"
+ " and not test_cv"
+ " and not test_training"
+ ;; "'['./runexp.sh']' returned non-zero exit status 1."
+ " and not test_cli_binary_classification")))))))
+ (native-inputs
+ `(("python-pandas" ,python-pandas)
+ ("python-pytest" ,python-pytest)
+ ("python-scikit-learn" ,python-scikit-learn)))
+ (inputs
+ `(("xgboost" ,xgboost)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python interface for the XGBoost library")))
+
(define-public python-iml
(package
(name "python-iml")
--
2.31.1
V
V
Vinicius Monego wrote on 13 May 2021 17:29
[PATCH v2 2/3] gnu: Add xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210513152914.573837-1-monego@posteo.net
* gnu/packages/machine-learning.scm (xgboost): New variable.
* gnu/packages/patches/xgboost-python-use-system-libxgboost.patch,
gnu/packages/patches/xgboost-use-system-dmlc-core.patch: New files.
* gnu/local.mk (dist_PATCH_DATA): Add them.
---
Changed commit message to add patch files.

gnu/local.mk | 2 +
gnu/packages/machine-learning.scm | 33 +++++++++
...xgboost-python-use-system-libxgboost.patch | 69 +++++++++++++++++++
.../xgboost-use-system-dmlc-core.patch | 35 ++++++++++
4 files changed, 139 insertions(+)
create mode 100644 gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
create mode 100644 gnu/packages/patches/xgboost-use-system-dmlc-core.patch

Toggle diff (175 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 37166bb2fc..e1d382c543 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1823,6 +1823,8 @@ dist_patch_DATA = \
%D%/packages/patches/xf86-video-voodoo-pcitag.patch \
%D%/packages/patches/xfce4-panel-plugins.patch \
%D%/packages/patches/xfce4-settings-defaults.patch \
+ %D%/packages/patches/xgboost-python-use-system-libxgboost.patch \
+ %D%/packages/patches/xgboost-use-system-dmlc-core.patch \
%D%/packages/patches/xmonad-dynamic-linking.patch \
%D%/packages/patches/xplanet-1.3.1-cxx11-eof.patch \
%D%/packages/patches/xplanet-1.3.1-libdisplay_DisplayOutput.cpp.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 9d6c5505f7..d81370797f 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1959,6 +1959,39 @@ offers the bricks to build efficient and scalable distributed machine
learning libraries.")
(license license:asl2.0))))
+(define-public xgboost
+ (package
+ (name "xgboost")
+ (version "1.4.1")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/xgboost")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "xgboost-python-use-system-libxgboost.patch"
+ "xgboost-use-system-dmlc-core.patch"))
+ (sha256
+ (base32 "0ixacmpcj844c09xigi1vd4rrckld84k32iarvhnvvm6yjih756y"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (inputs
+ `(("dmlc-core" ,dmlc-core)))
+ (home-page "https://xgboost.ai/")
+ (synopsis "Gradient boosting (GBDT, GBRT or GBM) library in C++")
+ (description
+ "XGBoost is an optimized distributed gradient boosting library designed
+to be highly efficient, flexible and portable. It implements machine learning
+algorithms under the Gradient Boosting framework. XGBoost provides a parallel
+tree boosting (also known as GBDT, GBM) that solve many data science problems
+in a fast and accurate way.")
+ (license license:asl2.0)))
+
(define-public python-iml
(package
(name "python-iml")
diff --git a/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch b/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
new file mode 100644
index 0000000000..992e6bb3fd
--- /dev/null
+++ b/gnu/packages/patches/xgboost-python-use-system-libxgboost.patch
@@ -0,0 +1,69 @@
+From 768192b9c6700f0ae6b750c56b114d7022692a0b Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:30:55 -0300
+Subject: [PATCH] Python wrapper: use system libxgboost.
+
+---
+This patch was extended from the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/setup.py.patch/
+
+ python-package/setup.py | 4 ++--
+ python-package/xgboost/__init__.py | 5 ++---
+ python-package/xgboost/libpath.py | 5 +++++
+ 3 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/python-package/setup.py b/python-package/setup.py
+index a2feb766..b8b78429 100644
+--- a/python-package/setup.py
++++ b/python-package/setup.py
+@@ -312,11 +312,11 @@ if __name__ == '__main__':
+ 'numpy',
+ 'scipy',
+ ],
+- ext_modules=[CMakeExtension('libxgboost')],
++ # ext_modules=[CMakeExtension('libxgboost')],
+ cmdclass={
+ 'build_ext': BuildExt,
+ 'sdist': Sdist,
+- 'install_lib': InstallLib,
++ # 'install_lib': InstallLib,
+ 'install': Install
+ },
+ extras_require={
+diff --git a/python-package/xgboost/__init__.py b/python-package/xgboost/__init__.py
+index e0ff434d..658e84e6 100644
+--- a/python-package/xgboost/__init__.py
++++ b/python-package/xgboost/__init__.py
+@@ -21,9 +21,8 @@ try:
+ except ImportError:
+ pass
+
+-VERSION_FILE = os.path.join(os.path.dirname(__file__), 'VERSION')
+-with open(VERSION_FILE) as f:
+- __version__ = f.read().strip()
++# This variable will be set during substitution.
++__version__ = ''
+
+ __all__ = ['DMatrix', 'DeviceQuantileDMatrix', 'Booster',
+ 'train', 'cv',
+diff --git a/python-package/xgboost/libpath.py b/python-package/xgboost/libpath.py
+index f7a7d9cd..88d9d986 100644
+--- a/python-package/xgboost/libpath.py
++++ b/python-package/xgboost/libpath.py
+@@ -19,9 +19,14 @@ def find_lib_path() -> List[str]:
+ lib_path
+ List of all found library path to xgboost
+ """
++
++ # This variable will be set during substitution.
++ XGBOOST_PATH = ''
++
+ curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
+ dll_path = [
+ # normal, after installation `lib` is copied into Python package tree.
++ os.path.join(XGBOOST_PATH, 'lib'),
+ os.path.join(curr_path, 'lib'),
+ # editable installation, no copying is performed.
+ os.path.join(curr_path, os.path.pardir, os.path.pardir, 'lib'),
+--
+2.31.1
+
diff --git a/gnu/packages/patches/xgboost-use-system-dmlc-core.patch b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
new file mode 100644
index 0000000000..6209ae1f10
--- /dev/null
+++ b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
@@ -0,0 +1,35 @@
+From 34167cc105e47589b86b6f62da76e0ab744002dd Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:35:30 -0300
+Subject: [PATCH] Use dmlc-core from Guix.
+
+---
+This patch is a subset from the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/cmake.patch/
+
+Rabit is now developed as part of xgboost, so we don't build it separately.
+
+ CMakeLists.txt | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6cc19fbd..3b42bc17 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -150,11 +150,9 @@ endif (USE_OPENMP)
+
+ # dmlc-core
+ msvc_use_static_runtime()
+-add_subdirectory(${xgboost_SOURCE_DIR}/dmlc-core)
+-set_target_properties(dmlc PROPERTIES
+- CXX_STANDARD 14
+- CXX_STANDARD_REQUIRED ON
+- POSITION_INDEPENDENT_CODE ON)
++add_library(dmlc SHARED IMPORTED)
++find_library(DMLC_LIBRARY dmlc)
++set_property(TARGET dmlc PROPERTY IMPORTED_LOCATION "${DMLC_LIBRARY}")
+ if (MSVC)
+ target_compile_options(dmlc PRIVATE
+ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
+--
+2.31.1
+
--
2.31.1
V
V
Vinicius Monego wrote on 13 May 2021 17:29
[PATCH v2 3/3] gnu: Add python-xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210513152914.573837-2-monego@posteo.net
* gnu/packages/machine-learning.scm (python-xgboost): New variable.
---
Added (when tests?) in check phase to allow --without-tests.

gnu/packages/machine-learning.scm | 62 +++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)

Toggle diff (75 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index d81370797f..ead47a534a 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1992,6 +1992,68 @@ tree boosting (also known as GBDT, GBM) that solve many data science problems
in a fast and accurate way.")
(license license:asl2.0)))
+(define-public python-xgboost
+ (package
+ (inherit xgboost)
+ (name "python-xgboost")
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Move python-package content to parent directory to silence
+ ;; some warnings about files not being found if we chdir.
+ (rename-file "python-package/xgboost" "xgboost")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/setup.cfg" "setup.cfg")
+ (rename-file "python-package/setup.py" "setup.py")
+
+ (with-directory-excursion "xgboost"
+ ;; Version is read from a VERSION file, but that file is not
+ ;; part of the installation.
+ (substitute* "__init__.py"
+ (("__version__ = ''")
+ (string-append "__version__ = " "'"
+ ,(package-version xgboost) "'")))
+ ;; The Python wrapper expects libxgboost to be found in the
+ ;; same source from where the wrapper builds. This workaround
+ ;; allows libxgboost to be used from the xgboost package.
+ (substitute* "libpath.py"
+ (("XGBOOST_PATH = ''")
+ (string-append "XGBOOST_PATH = "
+ "'" (assoc-ref inputs "xgboost") "'"))))
+ #t))
+ (replace 'check
+ ;; Python-specific tests are located in tests/python.
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "tests/python"
+ ;; FIXME: CLI tests fail with PermissionError.
+ "--ignore" "tests/python/test_cli.py" "-k"
+ (string-append
+ "not test_cli_regression_demo"
+ ;; The tests below open a network connection.
+ " and not test_model_compatibility"
+ " and not test_get_group"
+ " and not test_cv_no_shuffle"
+ " and not test_cv"
+ " and not test_training"
+ ;; "'['./runexp.sh']' returned non-zero exit status 1"
+ " and not test_cli_binary_classification")))
+ #t)))))
+ (native-inputs
+ `(("python-pandas" ,python-pandas)
+ ("python-pytest" ,python-pytest)
+ ("python-scikit-learn" ,python-scikit-learn)))
+ (inputs
+ `(("xgboost" ,xgboost)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python interface for the XGBoost library")))
+
(define-public python-iml
(package
(name "python-iml")
--
2.31.1
V
V
Vinicius Monego wrote on 27 Jun 2021 19:30
[PATCH v3 2/3] gnu: Add xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210627173047.2576-2-monego@posteo.net
* gnu/packages/machine-learning.scm (xgboost): New variable.
* gnu/packages/patches/xgboost-use-system-dmlc-core.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Add it.
---
Removed the python patch, updated to 1.4.2 and removed "in C++" from synopsis.

gnu/local.mk | 1 +
gnu/packages/machine-learning.scm | 32 +++++++++++++++++
.../xgboost-use-system-dmlc-core.patch | 34 +++++++++++++++++++
3 files changed, 67 insertions(+)
create mode 100644 gnu/packages/patches/xgboost-use-system-dmlc-core.patch

Toggle diff (97 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index f7ff9af997..19db9787dc 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1842,6 +1842,7 @@ dist_patch_DATA = \
%D%/packages/patches/xf86-video-voodoo-pcitag.patch \
%D%/packages/patches/xfce4-panel-plugins.patch \
%D%/packages/patches/xfce4-settings-defaults.patch \
+ %D%/packages/patches/xgboost-use-system-dmlc-core.patch \
%D%/packages/patches/xmonad-dynamic-linking.patch \
%D%/packages/patches/xplanet-1.3.1-cxx11-eof.patch \
%D%/packages/patches/xplanet-1.3.1-libdisplay_DisplayOutput.cpp.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 9d6c5505f7..bbdfba960e 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1959,6 +1959,38 @@ offers the bricks to build efficient and scalable distributed machine
learning libraries.")
(license license:asl2.0))))
+(define-public xgboost
+ (package
+ (name "xgboost")
+ (version "1.4.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/xgboost")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "xgboost-use-system-dmlc-core.patch"))
+ (sha256
+ (base32 "00liz816ahk9zj3jv3m2fqwlf6xxfbgvpmpl72iklx32vl192w5d"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (inputs
+ `(("dmlc-core" ,dmlc-core)))
+ (home-page "https://xgboost.ai/")
+ (synopsis "Gradient boosting (GBDT, GBRT or GBM) library")
+ (description
+ "XGBoost is an optimized distributed gradient boosting library designed
+to be highly efficient, flexible and portable. It implements machine learning
+algorithms under the Gradient Boosting framework. XGBoost provides a parallel
+tree boosting (also known as GBDT, GBM) that solve many data science problems
+in a fast and accurate way.")
+ (license license:asl2.0)))
+
(define-public python-iml
(package
(name "python-iml")
diff --git a/gnu/packages/patches/xgboost-use-system-dmlc-core.patch b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
new file mode 100644
index 0000000000..c654694fec
--- /dev/null
+++ b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
@@ -0,0 +1,34 @@
+From 34167cc105e47589b86b6f62da76e0ab744002dd Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:35:30 -0300
+Subject: [PATCH] Use dmlc-core from Guix.
+
+---
+This patch is a subset of the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/cmake.patch/
+
+Rabit is now developed as part of xgboost, so we don't build it separately.
+
+ CMakeLists.txt | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6cc19fbd..3b42bc17 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -150,11 +150,9 @@ endif (USE_OPENMP)
+
+ # dmlc-core
+ msvc_use_static_runtime()
+-add_subdirectory(${xgboost_SOURCE_DIR}/dmlc-core)
+-set_target_properties(dmlc PROPERTIES
+- CXX_STANDARD 14
+- CXX_STANDARD_REQUIRED ON
+- POSITION_INDEPENDENT_CODE ON)
++add_library(dmlc SHARED IMPORTED)
++find_library(DMLC_LIBRARY dmlc)
++set_property(TARGET dmlc PROPERTY IMPORTED_LOCATION "${DMLC_LIBRARY}")
+ if (MSVC)
+ target_compile_options(dmlc PRIVATE
+ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
+--
+2.31.1
--
2.32.0
V
V
Vinicius Monego wrote on 27 Jun 2021 19:30
[PATCH v3 1/3] gnu: Add dmlc-core.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210627173047.2576-1-monego@posteo.net
* gnu/packages/machine-learning.scm (dmlc-core): New variable.
---
No changes.

gnu/packages/machine-learning.scm | 32 +++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

Toggle diff (45 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 837ebbba67..9d6c5505f7 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1927,6 +1927,38 @@ together building blocks and a subclassing API with an imperative style for
advanced research.")
(license license:asl2.0)))
+(define-public dmlc-core
+ ;; Version 0.4 is too old for xgboost.
+ (let ((version "0.5")
+ (commit "f00e3ec7abc9f293a1b7061157b0a4e22a735cf5")
+ (revision "0"))
+ (package
+ (name "dmlc-core")
+ (version (git-version version revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/dmlc-core")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1x4ad1jhn84fywlk031fmv1kxyiscclmrqn9hhj8gz0mh7z9vcrh"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags
+ (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (home-page "https://github.com/dmlc/dmlc-core")
+ (synopsis "Common bricks library for machine learning")
+ (description
+ "DMLC-Core is the backbone library to support all DMLC projects,
+offers the bricks to build efficient and scalable distributed machine
+learning libraries.")
+ (license license:asl2.0))))
+
(define-public python-iml
(package
(name "python-iml")
--
2.32.0
V
V
Vinicius Monego wrote on 27 Jun 2021 19:30
[PATCH v3 3/3] gnu: Add python-xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210627173047.2576-3-monego@posteo.net
* gnu/packages/machine-learning.scm (python-xgboost): New variable.
* gnu/packages/patches/python-xgboost-use-system-libxgboost.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Add it.
---
Changed source to inherit from xgboost.
Added phase after 'install to add a VERSION file and symlink libxgboost, so it can be found at runtime. This change allowed to greatly simplify the patch.
Also removed #t from phases.
If this patchset is good enough now, I will do the same changes to LightGBM: http://issues.guix.gnu.org/48785

gnu/local.mk | 1 +
gnu/packages/machine-learning.scm | 66 +++++++++++++++++++
...python-xgboost-use-system-libxgboost.patch | 18 +++++
3 files changed, 85 insertions(+)
create mode 100644 gnu/packages/patches/python-xgboost-use-system-libxgboost.patch

Toggle diff (116 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 19db9787dc..821fd390a4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1632,6 +1632,7 @@ dist_patch_DATA = \
%D%/packages/patches/python-unittest2-python3-compat.patch \
%D%/packages/patches/python-unittest2-remove-argparse.patch \
%D%/packages/patches/python-waitress-fix-tests.patch \
+ %D%/packages/patches/python-xgboost-use-system-libxgboost.patch \
%D%/packages/patches/pypy3-7.3.1-fix-tests.patch \
%D%/packages/patches/qemu-build-info-manual.patch \
%D%/packages/patches/qemu-CVE-2021-20203.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index bbdfba960e..69b96ffd61 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1991,6 +1991,72 @@ tree boosting (also known as GBDT, GBM) that solve many data science problems
in a fast and accurate way.")
(license license:asl2.0)))
+(define-public python-xgboost
+ (package
+ (inherit xgboost)
+ (name "python-xgboost")
+ (source
+ (origin
+ (inherit (package-source xgboost))
+ (patches (search-patches "python-xgboost-use-system-libxgboost.patch"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda* (#:key inputs #:allow-other-keys)
+ ;; Move python-package content to parent directory to silence
+ ;; some warnings about files not being found if we chdir.
+ (rename-file "python-package/xgboost" "xgboost")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/setup.cfg" "setup.cfg")
+ (rename-file "python-package/setup.py" "setup.py")))
+ (add-after 'install 'install-version-and-libxgboost
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (pylib (string-append out "/lib/python"
+ ,(version-major+minor
+ (package-version python))
+ "/site-packages"))
+ (xgbdir (string-append pylib "/xgboost"))
+ (version-file (string-append xgbdir "/VERSION"))
+ (libxgboost (string-append (assoc-ref inputs "xgboost")
+ "/lib/libxgboost.so")))
+ (with-output-to-file version-file
+ (lambda ()
+ (display ,(package-version xgboost))))
+ (mkdir-p (string-append xgbdir "/lib"))
+ (symlink libxgboost (string-append xgbdir "/lib"
+ "/libxgboost.so")))))
+ (replace 'check
+ ;; Python-specific tests are located in tests/python.
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "tests/python"
+ ;; FIXME: CLI tests fail with PermissionError.
+ "--ignore" "tests/python/test_cli.py" "-k"
+ (string-append
+ "not test_cli_regression_demo"
+ ;; The tests below open a network connection.
+ " and not test_model_compatibility"
+ " and not test_get_group"
+ " and not test_cv_no_shuffle"
+ " and not test_cv"
+ " and not test_training"
+ ;; "'['./runexp.sh']' returned non-zero exit status 1"
+ " and not test_cli_binary_classification"))))))))
+ (native-inputs
+ `(("python-pandas" ,python-pandas)
+ ("python-pytest" ,python-pytest)
+ ("python-scikit-learn" ,python-scikit-learn)))
+ (inputs
+ `(("xgboost" ,xgboost)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python interface for the XGBoost library")))
+
(define-public python-iml
(package
(name "python-iml")
diff --git a/gnu/packages/patches/python-xgboost-use-system-libxgboost.patch b/gnu/packages/patches/python-xgboost-use-system-libxgboost.patch
new file mode 100644
index 0000000000..ce82309afd
--- /dev/null
+++ b/gnu/packages/patches/python-xgboost-use-system-libxgboost.patch
@@ -0,0 +1,18 @@
+This patch was imported from Debian: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/setup.py.patch/
+
+Description: the libxgboost.so has been installed by another package already
+Forwarded: no need
+--- a/python-package/setup.py
++++ b/python-package/setup.py
+@@ -286,10 +286,8 @@
+ 'numpy',
+ 'scipy',
+ ],
+- ext_modules=[CMakeExtension('libxgboost')],
+ cmdclass={
+ 'build_ext': BuildExt,
+ 'sdist': Sdist,
+- 'install_lib': InstallLib,
+ 'install': Install
+ },
+ extras_require={
\ No newline at end of file
--
2.32.0
V
V
Vinicius Monego wrote on 28 Jun 2021 01:11
[PATCH v4 3/3] gnu: Add python-xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210627231156.25391-1-monego@posteo.net
* gnu/packages/machine-learning.scm (python-xgboost): New variable.
---
Replaced the patch file with substitutions in 'preparations and changed the lambda arguments to _.

gnu/packages/machine-learning.scm | 67 +++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)

Toggle diff (80 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 726d491868..b8d79821e0 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -1991,6 +1991,73 @@ tree boosting (also known as GBDT, GBM) that solve many data science problems
in a fast and accurate way.")
(license license:asl2.0)))
+(define-public python-xgboost
+ (package
+ (inherit xgboost)
+ (name "python-xgboost")
+ (source (package-source xgboost))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda _
+ ;; Move python-package content to parent directory to silence
+ ;; some warnings about files not being found if we chdir.
+ (rename-file "python-package/xgboost" "xgboost")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/setup.cfg" "setup.cfg")
+ (rename-file "python-package/setup.py" "setup.py")
+ ;; Skip rebuilding libxgboost.so.
+ (substitute* "setup.py"
+ (("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "")
+ (("'install_lib': InstallLib,") ""))))
+ (add-after 'install 'install-version-and-libxgboost
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (pylib (string-append out "/lib/python"
+ ,(version-major+minor
+ (package-version python))
+ "/site-packages"))
+ (xgbdir (string-append pylib "/xgboost"))
+ (version-file (string-append xgbdir "/VERSION"))
+ (libxgboost (string-append (assoc-ref inputs "xgboost")
+ "/lib/libxgboost.so")))
+ (with-output-to-file version-file
+ (lambda ()
+ (display ,(package-version xgboost))))
+ (mkdir-p (string-append xgbdir "/lib"))
+ (symlink libxgboost (string-append xgbdir "/lib"
+ "/libxgboost.so")))))
+ (replace 'check
+ ;; Python-specific tests are located in tests/python.
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "tests/python"
+ ;; FIXME: CLI tests fail with PermissionError.
+ "--ignore" "tests/python/test_cli.py" "-k"
+ (string-append
+ "not test_cli_regression_demo"
+ ;; The tests below open a network connection.
+ " and not test_model_compatibility"
+ " and not test_get_group"
+ " and not test_cv_no_shuffle"
+ " and not test_cv"
+ " and not test_training"
+ ;; "'['./runexp.sh']' returned non-zero exit status 1"
+ " and not test_cli_binary_classification"))))))))
+ (native-inputs
+ `(("python-pandas" ,python-pandas)
+ ("python-pytest" ,python-pytest)
+ ("python-scikit-learn" ,python-scikit-learn)))
+ (inputs
+ `(("xgboost" ,xgboost)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python interface for the XGBoost library")))
+
(define-public python-iml
(package
(name "python-iml")
--
2.32.0
V
V
Vinicius Monego wrote on 25 Sep 2021 21:36
[PATCH v5 1/3] gnu: Add dmlc-core.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210925193651.155981-1-monego@posteo.net
* gnu/packages/machine-learning.scm (dmlc-core): New variable.
---
Checked out from v0.5 tag instead of a commit.

gnu/packages/machine-learning.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

Toggle diff (41 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 9b5d4c1743..a4768211a0 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -2310,6 +2310,34 @@ learning models. This package provides the \"lite\" variant for mobile
devices.")
(license license:asl2.0)))
+(define-public dmlc-core
+ (package
+ (name "dmlc-core")
+ (version "0.5")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/dmlc-core")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1x4ad1jhn84fywlk031fmv1kxyiscclmrqn9hhj8gz0mh7z9vcrh"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags
+ (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (home-page "https://github.com/dmlc/dmlc-core")
+ (synopsis "Common bricks library for machine learning")
+ (description
+ "DMLC-Core is the backbone library to support all DMLC projects,
+offers the bricks to build efficient and scalable distributed machine
+learning libraries.")
+ (license license:asl2.0)))
+
(define-public python-iml
(package
(name "python-iml")
--
2.30.2
V
V
Vinicius Monego wrote on 25 Sep 2021 21:36
[PATCH v5 2/3] gnu: Add xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210925193651.155981-2-monego@posteo.net
* gnu/packages/machine-learning.scm (xgboost): New variable.
* gnu/packages/patches/xgboost-use-system-dmlc-core.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Add it.
---
gnu/local.mk | 1 +
gnu/packages/machine-learning.scm | 32 +++++++++++++++++
.../xgboost-use-system-dmlc-core.patch | 34 +++++++++++++++++++
3 files changed, 67 insertions(+)
create mode 100644 gnu/packages/patches/xgboost-use-system-dmlc-core.patch

Toggle diff (97 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 7d706f6f6e..22fc393f0e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1888,6 +1888,7 @@ dist_patch_DATA = \
%D%/packages/patches/xf86-video-voodoo-pcitag.patch \
%D%/packages/patches/xfce4-panel-plugins.patch \
%D%/packages/patches/xfce4-settings-defaults.patch \
+ %D%/packages/patches/xgboost-use-system-dmlc-core.patch \
%D%/packages/patches/xmonad-dynamic-linking.patch \
%D%/packages/patches/xnnpack-system-libraries.patch \
%D%/packages/patches/xplanet-1.3.1-cxx11-eof.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index a4768211a0..454088b1a5 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -2338,6 +2338,38 @@ offers the bricks to build efficient and scalable distributed machine
learning libraries.")
(license license:asl2.0)))
+(define-public xgboost
+ (package
+ (name "xgboost")
+ (version "1.4.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/dmlc/xgboost")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (patches (search-patches "xgboost-use-system-dmlc-core.patch"))
+ (sha256
+ (base32 "00liz816ahk9zj3jv3m2fqwlf6xxfbgvpmpl72iklx32vl192w5d"))))
+ (build-system cmake-build-system)
+ (arguments
+ `(#:configure-flags (list "-DGOOGLE_TEST=ON")))
+ (native-inputs
+ `(("googletest" ,googletest)
+ ("python" ,python-wrapper)))
+ (inputs
+ `(("dmlc-core" ,dmlc-core)))
+ (home-page "https://xgboost.ai/")
+ (synopsis "Gradient boosting (GBDT, GBRT or GBM) library")
+ (description
+ "XGBoost is an optimized distributed gradient boosting library designed
+to be highly efficient, flexible and portable. It implements machine learning
+algorithms under the Gradient Boosting framework. XGBoost provides a parallel
+tree boosting (also known as GBDT, GBM) that solve many data science problems
+in a fast and accurate way.")
+ (license license:asl2.0)))
+
(define-public python-iml
(package
(name "python-iml")
diff --git a/gnu/packages/patches/xgboost-use-system-dmlc-core.patch b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
new file mode 100644
index 0000000000..c654694fec
--- /dev/null
+++ b/gnu/packages/patches/xgboost-use-system-dmlc-core.patch
@@ -0,0 +1,34 @@
+From 34167cc105e47589b86b6f62da76e0ab744002dd Mon Sep 17 00:00:00 2001
+From: Vinicius Monego <monego@posteo.net>
+Date: Tue, 11 May 2021 19:35:30 -0300
+Subject: [PATCH] Use dmlc-core from Guix.
+
+---
+This patch is a subset of the following Debian patch: https://sources.debian.org/src/xgboost/1.2.1-1/debian/patches/cmake.patch/
+
+Rabit is now developed as part of xgboost, so we don't build it separately.
+
+ CMakeLists.txt | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6cc19fbd..3b42bc17 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -150,11 +150,9 @@ endif (USE_OPENMP)
+
+ # dmlc-core
+ msvc_use_static_runtime()
+-add_subdirectory(${xgboost_SOURCE_DIR}/dmlc-core)
+-set_target_properties(dmlc PROPERTIES
+- CXX_STANDARD 14
+- CXX_STANDARD_REQUIRED ON
+- POSITION_INDEPENDENT_CODE ON)
++add_library(dmlc SHARED IMPORTED)
++find_library(DMLC_LIBRARY dmlc)
++set_property(TARGET dmlc PROPERTY IMPORTED_LOCATION "${DMLC_LIBRARY}")
+ if (MSVC)
+ target_compile_options(dmlc PRIVATE
+ -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
+--
+2.31.1
--
2.30.2
V
V
Vinicius Monego wrote on 25 Sep 2021 21:36
[PATCH v5 3/3] gnu: Add python-xgboost.
(address . 48388@debbugs.gnu.org)(name . Vinicius Monego)(address . monego@posteo.net)
20210925193651.155981-3-monego@posteo.net
* gnu/packages/machine-learning.scm (python-xgboost): New variable.
---
Skipped a test that fails in Pandas 1.3.0.

gnu/packages/machine-learning.scm | 69 +++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)

Toggle diff (82 lines)
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 454088b1a5..5e17b09e89 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -2370,6 +2370,75 @@ tree boosting (also known as GBDT, GBM) that solve many data science problems
in a fast and accurate way.")
(license license:asl2.0)))
+(define-public python-xgboost
+ (package
+ (inherit xgboost)
+ (name "python-xgboost")
+ (source (package-source xgboost))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'preparations
+ (lambda _
+ ;; Move python-package content to parent directory to silence
+ ;; some warnings about files not being found if we chdir.
+ (rename-file "python-package/xgboost" "xgboost")
+ (rename-file "python-package/README.rst" "README.rst")
+ (rename-file "python-package/setup.cfg" "setup.cfg")
+ (rename-file "python-package/setup.py" "setup.py")
+ ;; Skip rebuilding libxgboost.so.
+ (substitute* "setup.py"
+ (("ext_modules=\\[CMakeExtension\\('libxgboost'\\)\\],") "")
+ (("'install_lib': InstallLib,") ""))))
+ (add-after 'install 'install-version-and-libxgboost
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ (pylib (string-append out "/lib/python"
+ ,(version-major+minor
+ (package-version python))
+ "/site-packages"))
+ (xgbdir (string-append pylib "/xgboost"))
+ (version-file (string-append xgbdir "/VERSION"))
+ (libxgboost (string-append (assoc-ref inputs "xgboost")
+ "/lib/libxgboost.so")))
+ (with-output-to-file version-file
+ (lambda ()
+ (display ,(package-version xgboost))))
+ (mkdir-p (string-append xgbdir "/lib"))
+ (symlink libxgboost (string-append xgbdir "/lib"
+ "/libxgboost.so")))))
+ (replace 'check
+ ;; Python-specific tests are located in tests/python.
+ (lambda* (#:key inputs outputs tests? #:allow-other-keys)
+ (when tests?
+ (add-installed-pythonpath inputs outputs)
+ (invoke "pytest" "tests/python"
+ ;; FIXME: CLI tests fail with PermissionError.
+ "--ignore" "tests/python/test_cli.py" "-k"
+ (string-append
+ "not test_cli_regression_demo"
+ ;; The tests below open a network connection.
+ " and not test_model_compatibility"
+ " and not test_get_group"
+ " and not test_cv_no_shuffle"
+ " and not test_cv"
+ " and not test_training"
+ ;; FIXME: May pass in the next version.
+ " and not test_pandas"
+ ;; "'['./runexp.sh']' returned non-zero exit status 1"
+ " and not test_cli_binary_classification"))))))))
+ (native-inputs
+ `(("python-pandas" ,python-pandas)
+ ("python-pytest" ,python-pytest)
+ ("python-scikit-learn" ,python-scikit-learn)))
+ (inputs
+ `(("xgboost" ,xgboost)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (synopsis "Python interface for the XGBoost library")))
+
(define-public python-iml
(package
(name "python-iml")
--
2.30.2
L
L
Leo Famulari wrote on 25 Sep 2021 22:14
Re: [bug#48388] [PATCH v5 1/3] gnu: Add dmlc-core.
(name . Vinicius Monego)(address . monego@posteo.net)(address . 48388-done@debbugs.gnu.org)
YU+DKsLfVM6++E9h@jasmine.lan
On Sat, Sep 25, 2021 at 07:36:49PM +0000, Vinicius Monego wrote:
Toggle quote (2 lines)
> * gnu/packages/machine-learning.scm (dmlc-core): New variable.

Thanks! I pushed v5 of this patch series as commit
40a6d8eb7de42248c886c447a299256853054912
Closed
?