1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net>
8 ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org>
9 ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com>
10 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
11 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
12 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages machine-learning)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
34 #:use-module (guix svn-download)
35 #:use-module (guix build-system cmake)
36 #:use-module (guix build-system gnu)
37 #:use-module (guix build-system ocaml)
38 #:use-module (guix build-system python)
39 #:use-module (guix build-system r)
40 #:use-module (guix git-download)
41 #:use-module (gnu packages)
42 #:use-module (gnu packages algebra)
43 #:use-module (gnu packages audio)
44 #:use-module (gnu packages autotools)
45 #:use-module (gnu packages base)
46 #:use-module (gnu packages boost)
47 #:use-module (gnu packages check)
48 #:use-module (gnu packages compression)
49 #:use-module (gnu packages cran)
50 #:use-module (gnu packages dejagnu)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages glib)
53 #:use-module (gnu packages gstreamer)
54 #:use-module (gnu packages image)
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages maths)
57 #:use-module (gnu packages mpi)
58 #:use-module (gnu packages ocaml)
59 #:use-module (gnu packages onc-rpc)
60 #:use-module (gnu packages perl)
61 #:use-module (gnu packages pkg-config)
62 #:use-module (gnu packages python)
63 #:use-module (gnu packages python-xyz)
64 #:use-module (gnu packages statistics)
65 #:use-module (gnu packages swig)
66 #:use-module (gnu packages xml)
67 #:use-module (gnu packages xorg))
70 ;; The last release is >100 commits behind, so we package from git.
71 (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7"))
74 (version (string-append "2.2.0-1." (string-take commit 8)))
78 (url "https://github.com/libfann/fann.git")
80 (file-name (string-append name "-" version "-checkout"))
83 "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x"))))
84 (build-system cmake-build-system)
87 (modify-phases %standard-phases
89 (lambda* (#:key outputs #:allow-other-keys)
90 (let* ((out (assoc-ref outputs "out")))
91 (with-directory-excursion (string-append (getcwd) "/tests")
92 (invoke "./fann_tests"))))))))
93 (home-page "http://leenissen.dk/fann/wp/")
94 (synopsis "Fast Artificial Neural Network")
96 "FANN is a free open source neural network library, which implements
97 multilayer artificial neural networks in C with support for both fully
98 connected and sparsely connected networks.")
99 (license license:lgpl2.1))))
101 (define-public libsvm
108 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
109 name "-" version ".tar.gz"))
112 "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd"))))
113 (build-system gnu-build-system)
115 `(#:tests? #f ;no "check" target
116 #:phases (modify-phases %standard-phases
119 'install ; no ‘install’ target
120 (lambda* (#:key outputs #:allow-other-keys)
121 (let* ((out (assoc-ref outputs "out"))
122 (bin (string-append out "/bin/")))
124 (for-each (lambda (file)
125 (copy-file file (string-append bin file)))
130 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
131 (synopsis "Library for Support Vector Machines")
133 "LIBSVM is a machine learning library for support vector
134 classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
135 distribution estimation (one-class SVM). It supports multi-class
137 (license license:bsd-3)))
139 (define-public python-libsvm
140 (package (inherit libsvm)
141 (name "python-libsvm")
142 (build-system gnu-build-system)
144 `(#:tests? #f ;no "check" target
145 #:make-flags '("-C" "python")
147 (modify-phases %standard-phases
150 'install ; no ‘install’ target
151 (lambda* (#:key inputs outputs #:allow-other-keys)
152 (let ((site (string-append (assoc-ref outputs "out")
156 (assoc-ref inputs "python") 5) 3)
158 (substitute* "python/svm.py"
159 (("../libsvm.so.2") "libsvm.so.2"))
161 (for-each (lambda (file)
162 (copy-file file (string-append site (basename file))))
163 (find-files "python" "\\.py"))
164 (copy-file "libsvm.so.2"
165 (string-append site "libsvm.so.2")))
168 `(("python" ,python)))
169 (synopsis "Python bindings of libSVM")))
172 ;; The latest release candidate is several years and a couple of fixes have
173 ;; been published since. This is why we download the sources from the SVN
175 (let ((svn-revision 2341))
178 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
182 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
183 (revision svn-revision)))
184 (file-name (string-append name "-" version))
187 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
188 (build-system gnu-build-system)
190 `(#:imported-modules (,@%gnu-build-system-modules
191 (guix build python-build-system))
193 (modify-phases %standard-phases
194 (add-after 'unpack 'enter-dir
195 (lambda _ (chdir "ghmm") #t))
197 (add-after 'install 'check
198 (assoc-ref %standard-phases 'check))
199 (add-before 'check 'fix-PYTHONPATH
200 (lambda* (#:key inputs outputs #:allow-other-keys)
201 (let ((python-version ((@@ (guix build python-build-system)
203 (assoc-ref inputs "python"))))
205 (string-append (getenv "PYTHONPATH")
206 ":" (assoc-ref outputs "out")
207 "/lib/python" python-version
210 (add-after 'enter-dir 'fix-runpath
211 (lambda* (#:key outputs #:allow-other-keys)
212 (substitute* "ghmmwrapper/setup.py"
213 (("^(.*)extra_compile_args = \\[" line indent)
214 (string-append indent
215 "extra_link_args = [\"-Wl,-rpath="
216 (assoc-ref outputs "out") "/lib\"],\n"
219 (assoc-ref outputs "out")
222 (add-after 'enter-dir 'disable-broken-tests
224 (substitute* "tests/Makefile.am"
225 ;; GHMM_SILENT_TESTS is assumed to be a command.
226 (("TESTS_ENVIRONMENT.*") "")
227 ;; Do not build broken tests.
231 (("label_higher_order_test.*$")
232 "label_higher_order_test\n"))
234 ;; These Python unittests are broken as there is no gato.
235 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
236 (substitute* "ghmmwrapper/ghmmunittests.py"
237 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
239 (string-append indent
240 "@unittest.skip(\"Disabled by Guix\")\n"
243 (add-after 'disable-broken-tests 'autogen
245 (invoke "bash" "autogen.sh"))))))
247 `(("python" ,python-2) ; only Python 2 is supported
248 ("libxml2" ,libxml2)))
250 `(("pkg-config" ,pkg-config)
253 ("autoconf" ,autoconf)
254 ("automake" ,automake)
255 ("libtool" ,libtool)))
256 (home-page "http://ghmm.org")
257 (synopsis "Hidden Markov Model library")
259 "The General Hidden Markov Model library (GHMM) is a C library with
260 additional Python bindings implementing a wide range of types of @dfn{Hidden
261 Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
262 training, HMM clustering, HMM mixtures.")
263 (license license:lgpl2.0+))))
272 "http://micans.org/mcl/src/mcl-"
273 (string-replace-substring version "." "-")
277 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
278 (build-system gnu-build-system)
280 `(#:configure-flags (list "--enable-blast")))
283 (home-page "http://micans.org/mcl/")
284 (synopsis "Clustering algorithm for graphs")
286 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
287 fast and scalable unsupervised cluster algorithm for graphs (also known as
288 networks) based on simulation of (stochastic) flow in graphs.")
289 ;; In the LICENCE file and web page it says "The software is licensed
290 ;; under the GNU General Public License, version 3.", but in several of
291 ;; the source code files it suggests GPL3 or later.
292 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
293 (license license:gpl3)))
295 (define-public ocaml-mcl
298 (version "12-068oasis4")
303 "https://github.com/fhcrc/mcl/archive/"
305 (file-name (string-append name "-" version ".tar.gz"))
308 "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110"))))
309 (build-system ocaml-build-system)
311 `(#:ocaml ,ocaml-4.02
312 #:findlib ,ocaml4.02-findlib
314 (modify-phases %standard-phases
315 (add-before 'configure 'patch-paths
317 (substitute* "configure"
318 (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh"))))
319 (substitute* "setup.ml"
321 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))))
323 (home-page "https://github.com/fhcrc/mcl")
324 (synopsis "OCaml wrappers around MCL")
326 "This package provides OCaml bindings for the MCL graph clustering
328 (license license:gpl3)))
330 (define-public randomjungle
332 (name "randomjungle")
338 "https://www.imbs.uni-luebeck.de/fileadmin/files/Software"
339 "/randomjungle/randomjungle-" version ".tar_.gz"))
340 (patches (search-patches "randomjungle-disable-static-build.patch"))
343 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
344 (build-system gnu-build-system)
347 (list "--disable-static"
348 (string-append "--with-boost="
349 (assoc-ref %build-inputs "boost")))
351 (modify-phases %standard-phases
353 'configure 'set-CXXFLAGS
355 (setenv "CXXFLAGS" "-fpermissive ")
363 `(("gfortran" ,gfortran)
364 ("gfortran:lib" ,gfortran "lib")))
365 ;; Non-portable assembly instructions are used so building fails on
366 ;; platforms other than x86_64 or i686.
367 (supported-systems '("x86_64-linux" "i686-linux"))
368 (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224")
369 (synopsis "Implementation of the Random Forests machine learning method")
371 "Random Jungle is an implementation of Random Forests. It is supposed to
372 analyse high dimensional data. In genetics, it can be used for analysing big
373 Genome Wide Association (GWA) data. Random Forests is a powerful machine
374 learning method. Most interesting features are variable selection, missing
375 value imputation, classifier creation, generalization error estimation and
376 sample proximities between pairs of cases.")
377 (license license:gpl3+)))
379 (define-public openfst
385 (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
386 "FstDownload/openfst-" version ".tar.gz"))
389 "0x9wfcqd8hq4h349s7j77sr60h8xjdfshqw1m3a2n6z5bdr9qkm1"))))
390 (build-system gnu-build-system)
391 (home-page "http://www.openfst.org")
392 (synopsis "Library for weighted finite-state transducers")
393 (description "OpenFst is a library for constructing, combining,
394 optimizing, and searching weighted finite-state transducers (FSTs).")
395 (license license:asl2.0)))
397 (define-public shogun
405 "ftp://shogun-toolbox.org/shogun/releases/"
406 (version-major+minor version)
407 "/sources/shogun-" version ".tar.bz2"))
410 "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp"))
411 (modules '((guix build utils)
415 ;; Remove non-free sources and files referencing them
416 (for-each delete-file
417 (find-files "src/shogun/classifier/svm/"
418 "SVMLight\\.(cpp|h)"))
419 (for-each delete-file
420 (find-files "examples/undocumented/libshogun/"
422 "(classifier_.*svmlight.*|"
423 "evaluation_cross_validation_locked_comparison).cpp")))
424 ;; Remove non-free functions.
425 (define (delete-ifdefs file)
426 (with-atomic-file-replacement file
428 (let loop ((line (read-line in 'concat))
430 (if (eof-object? line)
435 "#endif //USE_SVMLIGHT" line)))
437 "#ifdef USE_SVMLIGHT" line))))
438 (when (or (not skipping?)
439 (and skipping? (not skip-next?)))
441 (loop (read-line in 'concat) skip-next?)))))))
442 (for-each delete-ifdefs
444 (find-files "src/shogun/classifier/mkl"
445 "^MKLClassification\\.cpp")
446 (find-files "src/shogun/classifier/svm"
447 "^SVMLightOneClass\\.(cpp|h)")
448 (find-files "src/shogun/multiclass"
449 "^ScatterSVM\\.(cpp|h)")
450 (find-files "src/shogun/kernel/"
451 "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)")
452 (find-files "src/shogun/regression/svr"
453 "^(MKLRegression|SVRLight)\\.(cpp|h)")
454 (find-files "src/shogun/transfer/domain_adaptation"
455 "^DomainAdaptationSVM\\.(cpp|h)")))
457 (build-system cmake-build-system)
459 '(#:tests? #f ;no check target
461 (modify-phases %standard-phases
462 (add-after 'unpack 'delete-broken-symlinks
464 (for-each delete-file '("applications/arts/data"
465 "applications/asp/data"
466 "applications/easysvm/data"
467 "applications/msplicer/data"
468 "applications/ocr/data"
470 "examples/undocumented/data"))
472 (add-after 'unpack 'change-R-target-path
473 (lambda* (#:key outputs #:allow-other-keys)
474 (substitute* '("src/interfaces/r/CMakeLists.txt"
475 "examples/meta/r/CMakeLists.txt")
476 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
477 (string-append (assoc-ref outputs "out")
480 (add-after 'unpack 'fix-octave-modules
481 (lambda* (#:key outputs #:allow-other-keys)
482 (substitute* "src/interfaces/octave/CMakeLists.txt"
483 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
484 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave")
485 ;; change target directory
486 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
487 (string-append (assoc-ref outputs "out")
488 "/share/octave/packages")))
489 (substitute* '("src/interfaces/octave/swig_typemaps.i"
490 "src/interfaces/octave/sg_print_functions.cpp")
491 ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave.
492 (("octave/config\\.h") "octave/octave-config.h")
493 (("octave/oct-obj.h") "octave/ovl.h"))
495 (add-after 'unpack 'move-rxcpp
496 (lambda* (#:key inputs #:allow-other-keys)
497 (let ((rxcpp-dir "shogun/third-party/rxcpp"))
499 (install-file (assoc-ref inputs "rxcpp") rxcpp-dir)
501 (add-before 'build 'set-HOME
502 ;; $HOME needs to be set at some point during the build phase
503 (lambda _ (setenv "HOME" "/tmp") #t)))
505 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
506 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
507 "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags
508 ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas
509 ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray
510 ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist
511 ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file
512 "-DINTERFACE_OCTAVE=ON"
513 "-DINTERFACE_PYTHON=ON"
514 "-DINTERFACE_R=ON")))
517 ("numpy" ,python-numpy)
518 ("r-minimal" ,r-minimal)
519 ("octave" ,octave-cli)
524 ("arpack" ,arpack-ng)
531 `(("pkg-config" ,pkg-config)
533 ;; Non-portable SSE instructions are used so building fails on platforms
534 ;; other than x86_64.
535 (supported-systems '("x86_64-linux"))
536 (home-page "http://shogun-toolbox.org/")
537 (synopsis "Machine learning toolbox")
539 "The Shogun Machine learning toolbox provides a wide range of unified and
540 efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
541 combine multiple data representations, algorithm classes, and general purpose
542 tools. This enables both rapid prototyping of data pipelines and extensibility
543 in terms of new algorithms.")
544 (license license:gpl3+)))
553 (uri (string-append "https://github.com/ReactiveX/RxCpp/archive/v"
557 "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh"))
558 (file-name (string-append name "-" version ".tar.gz"))))
559 (build-system cmake-build-system)
562 (modify-phases %standard-phases
563 (add-after 'unpack 'remove-werror
565 (substitute* (find-files ".")
570 (invoke "ctest"))))))
572 `(("catch" ,catch-framework)))
573 (home-page "http://reactivex.io/")
574 (synopsis "Reactive Extensions for C++")
576 "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for
577 values-distributed-in-time. ReactiveX is a library for composing asynchronous
578 and event-based programs by using observable sequences.
580 It extends the observer pattern to support sequences of data and/or events and
581 adds operators that allow you to compose sequences together declaratively while
582 abstracting away concerns about things like low-level threading,
583 synchronization, thread-safety, concurrent data structures, and non-blocking
585 (license license:asl2.0)))
587 (define-public r-adaptivesparsity
589 (name "r-adaptivesparsity")
593 (uri (cran-uri "AdaptiveSparsity" version))
596 "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91"))))
598 `((upstream-name . "AdaptiveSparsity")))
599 (build-system r-build-system)
602 (modify-phases %standard-phases
603 (add-after 'unpack 'link-against-armadillo
605 (substitute* "src/Makevars"
606 (("PKG_LIBS=" prefix)
607 (string-append prefix "-larmadillo"))))))))
610 ("r-matrix" ,r-matrix)
612 ("r-rcpparmadillo" ,r-rcpparmadillo)))
614 `(("armadillo" ,armadillo)))
615 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
616 (synopsis "Adaptive sparsity models")
618 "This package implements the Figueiredo machine learning algorithm for
619 adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
621 (license license:lgpl3+)))
623 (define-public r-kernlab
630 (uri (cran-uri "kernlab" version))
633 "1m0xqf6gyvwayz7w3c83y32ayvnlz0jicj8ijk808zq9sh7dbbgn"))))
634 (build-system r-build-system)
635 (home-page "https://cran.r-project.org/web/packages/kernlab")
636 (synopsis "Kernel-based machine learning tools")
638 "This package provides kernel-based machine learning methods for
639 classification, regression, clustering, novelty detection, quantile regression
640 and dimensionality reduction. Among other methods @code{kernlab} includes
641 Support Vector Machines, Spectral Clustering, Kernel PCA, Gaussian Processes
643 (license license:gpl2)))
652 "http://dlib.net/files/dlib-" version ".tar.bz2"))
655 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
656 (modules '((guix build utils)))
659 ;; Delete ~13MB of bundled dependencies.
660 (delete-file-recursively "dlib/external")
661 (delete-file-recursively "docs/dlib/external")
663 (build-system cmake-build-system)
666 (modify-phases %standard-phases
667 (add-after 'unpack 'disable-asserts
669 ;; config.h recommends explicitly enabling or disabling asserts
670 ;; when building as a shared library. By default neither is set.
671 (substitute* "dlib/config.h"
672 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
674 (add-after 'disable-asserts 'disable-failing-tests
676 ;; One test times out on MIPS, so we need to disable it.
677 ;; Others are flaky on some platforms.
678 (let* ((system ,(or (%current-target-system)
680 (disabled-tests (cond
681 ((string-prefix? "mips64" system)
682 '("object_detector" ; timeout
684 ((string-prefix? "armhf" system)
685 '("learning_to_track"))
686 ((string-prefix? "i686" system)
691 (substitute* "dlib/test/makefile"
692 (((string-append "SRC \\+= " test "\\.cpp")) "")))
697 ;; No test target, so we build and run the unit tests here.
698 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
699 (with-directory-excursion test-dir
700 (invoke "make" "-j" (number->string (parallel-job-count)))
701 (invoke "./dtest" "--runall"))
703 (add-after 'install 'delete-static-library
704 (lambda* (#:key outputs #:allow-other-keys)
705 (delete-file (string-append (assoc-ref outputs "out")
709 `(("pkg-config" ,pkg-config)
718 ("openblas" ,openblas)
721 "Toolkit for making machine learning and data analysis applications in C++")
723 "Dlib is a modern C++ toolkit containing machine learning algorithms and
724 tools. It is used in both industry and academia in a wide range of domains
725 including robotics, embedded devices, mobile phones, and large high performance
726 computing environments.")
727 (home-page "http://dlib.net")
728 (license license:boost1.0)))
730 (define-public python-scikit-learn
732 (name "python-scikit-learn")
738 (url "https://github.com/scikit-learn/scikit-learn.git")
740 (file-name (git-file-name name version))
743 "0fkhwg3xn1s7ln9q1szq6kwc4jhwvjh8w4kmv9wcrqy7cq3lbv0d"))))
744 (build-system python-build-system)
747 (modify-phases %standard-phases
748 (add-after 'build 'build-ext
749 (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t))
752 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
753 (setenv "OPENBLAS_NUM_THREADS" "1")
755 ;; Some tests require write access to $HOME.
756 (setenv "HOME" "/tmp")
758 (invoke "pytest" "sklearn" "-m" "not network")))
759 ;; FIXME: This fails with permission denied
760 (delete 'reset-gzip-timestamps))))
762 `(("openblas" ,openblas)))
764 `(("python-pytest" ,python-pytest)
765 ("python-pandas" ,python-pandas) ;for tests
766 ("python-cython" ,python-cython)))
768 `(("python-numpy" ,python-numpy)
769 ("python-scipy" ,python-scipy)))
770 (home-page "http://scikit-learn.org/")
771 (synopsis "Machine Learning in Python")
773 "Scikit-learn provides simple and efficient tools for data mining and
775 (license license:bsd-3)))
777 (define-public python2-scikit-learn
778 (package-with-python2 python-scikit-learn))
780 (define-public python-autograd
781 (let* ((commit "442205dfefe407beffb33550846434baa90c4de7")
783 (version (git-version "0.0.0" revision commit)))
785 (name "python-autograd")
786 (home-page "https://github.com/HIPS/autograd")
794 "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4"))
795 (file-name (git-file-name name version))))
797 (build-system python-build-system)
799 `(("python-nose" ,python-nose)
800 ("python-pytest" ,python-pytest)))
802 `(("python-future" ,python-future)
803 ("python-numpy" ,python-numpy)))
805 `(#:phases (modify-phases %standard-phases
808 (invoke "py.test" "-v"))))))
809 (synopsis "Efficiently computes derivatives of NumPy code")
810 (description "Autograd can automatically differentiate native Python and
811 NumPy code. It can handle a large subset of Python's features, including loops,
812 ifs, recursion and closures, and it can even take derivatives of derivatives
813 of derivatives. It supports reverse-mode differentiation
814 (a.k.a. backpropagation), which means it can efficiently take gradients of
815 scalar-valued functions with respect to array-valued arguments, as well as
816 forward-mode differentiation, and the two can be composed arbitrarily. The
817 main intended application of Autograd is gradient-based optimization.")
818 (license license:expat))))
820 (define-public python2-autograd
821 (package-with-python2 python-autograd))
823 (define-public lightgbm
830 "https://github.com/Microsoft/LightGBM/archive/v"
834 "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1"))
835 (file-name (string-append name "-" version ".tar.gz"))))
837 `(("python-pytest" ,python-pytest)
838 ("python-nose" ,python-nose)))
840 `(("openmpi" ,openmpi)))
842 `(("python-numpy" ,python-numpy)
843 ("python-scipy" ,python-scipy)))
848 (modify-phases %standard-phases
850 (lambda* (#:key outputs #:allow-other-keys)
851 (with-directory-excursion ,(string-append "../LightGBM-" version)
852 (invoke "pytest" "tests/c_api_test/test_.py")))))))
853 (build-system cmake-build-system)
854 (home-page "https://github.com/Microsoft/LightGBM")
855 (synopsis "Gradient boosting framework based on decision tree algorithms")
856 (description "LightGBM is a gradient boosting framework that uses tree
857 based learning algorithms. It is designed to be distributed and efficient with
858 the following advantages:
861 @item Faster training speed and higher efficiency
862 @item Lower memory usage
863 @item Better accuracy
864 @item Parallel and GPU learning supported (not enabled in this package)
865 @item Capable of handling large-scale data
867 (license license:expat)))
869 (define-public vowpal-wabbit
870 ;; Language bindings not included.
872 (name "vowpal-wabbit")
877 "https://github.com/JohnLangford/vowpal_wabbit/archive/"
881 "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr"))
882 (file-name (string-append name "-" version ".tar.gz"))))
888 (list (string-append "--with-boost="
889 (assoc-ref %build-inputs "boost")))))
890 (build-system gnu-build-system)
891 (home-page "https://github.com/JohnLangford/vowpal_wabbit")
892 (synopsis "Fast machine learning library for online learning")
893 (description "Vowpal Wabbit is a machine learning system with techniques
894 such as online, hashing, allreduce, reductions, learning2search, active, and
895 interactive learning.")
896 (license license:bsd-3)))
898 (define-public python2-fastlmm
900 (name "python2-fastlmm")
905 (uri (pypi-uri "fastlmm" version ".zip"))
908 "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m"))))
909 (build-system python-build-system)
911 `(#:tests? #f ; some test files are missing
912 #:python ,python-2)) ; only Python 2.7 is supported
914 `(("python2-numpy" ,python2-numpy)
915 ("python2-scipy" ,python2-scipy)
916 ("python2-matplotlib" ,python2-matplotlib)
917 ("python2-pandas" ,python2-pandas)
918 ("python2-scikit-learn" ,python2-scikit-learn)
919 ("python2-pysnptools" ,python2-pysnptools)))
922 ("python2-cython" ,python2-cython)
923 ("python2-mock" ,python2-mock)
924 ("python2-nose" ,python2-nose)))
925 (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/")
926 (synopsis "Perform genome-wide association studies on large data sets")
928 "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed
929 Models, is a program for performing both single-SNP and SNP-set genome-wide
930 association studies (GWAS) on extremely large data sets.")
931 (license license:asl2.0)))
933 ;; There have been no proper releases yet.
935 (let ((commit "2f95609f0bb085bd3a1dc5eb0a39f3edea59e606")
939 (version (git-version "0" revision commit))
943 (url "https://github.com/kaldi-asr/kaldi.git")
945 (file-name (git-file-name name version))
948 "082qh3pfi7hvncylp4xsmkfahbd7gb0whdfa4rwrx7fxk9rdh3kz"))))
949 (build-system gnu-build-system)
951 `(#:test-target "test"
953 (modify-phases %standard-phases
954 (add-after 'unpack 'chdir
955 (lambda _ (chdir "src") #t))
957 (lambda* (#:key build system inputs outputs #:allow-other-keys)
958 (when (not (or (string-prefix? "x86_64" system)
959 (string-prefix? "i686" system)))
960 (substitute* "makefiles/linux_openblas.mk"
961 (("-msse -msse2") "")))
962 (substitute* "makefiles/default_rules.mk"
963 (("/bin/bash") (which "bash")))
964 (substitute* "Makefile"
965 (("ext_depend: check_portaudio")
967 (substitute* '("online/Makefile"
969 "gst-plugin/Makefile")
970 (("../../tools/portaudio/install")
971 (assoc-ref inputs "portaudio")))
973 ;; This `configure' script doesn't support variables passed as
974 ;; arguments, nor does it support "prefix".
975 (let ((out (assoc-ref outputs "out"))
976 (openblas (assoc-ref inputs "openblas"))
977 (openfst (assoc-ref inputs "openfst")))
978 (substitute* "configure"
979 (("check_for_slow_expf;") "")
980 ;; This affects the RPATH and also serves as the installation
982 (("KALDILIBDIR=`pwd`/lib")
983 (string-append "KALDILIBDIR=" out "/lib")))
984 (mkdir-p out) ; must exist
985 (setenv "CONFIG_SHELL" (which "bash"))
986 (setenv "OPENFST_VER" ,(package-version openfst))
987 (invoke "./configure"
990 (string-append "--openblas-root=" openblas)
991 (string-append "--fst-root=" openfst)))))
992 (add-after 'build 'build-ext-and-gstreamer-plugin
994 (invoke "make" "-C" "online" "depend")
995 (invoke "make" "-C" "online")
996 (invoke "make" "-C" "onlinebin" "depend")
997 (invoke "make" "-C" "onlinebin")
998 (invoke "make" "-C" "gst-plugin" "depend")
999 (invoke "make" "-C" "gst-plugin")
1001 ;; TODO: also install the executables.
1003 (lambda* (#:key outputs #:allow-other-keys)
1004 (let* ((out (assoc-ref outputs "out"))
1005 (lib (string-append out "/lib")))
1007 (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" lib)
1010 `(("alsa-lib" ,alsa-lib)
1011 ("gfortran" ,gfortran "lib")
1013 ("gstreamer" ,gstreamer)
1015 ("openblas" ,openblas)
1016 ("openfst" ,openfst)
1017 ("portaudio" ,portaudio)
1018 ("python" ,python)))
1020 `(("glib" ,glib "bin") ; glib-genmarshal
1023 ("pkg-config" ,pkg-config)
1025 (home-page "https://kaldi-asr.org/")
1026 (synopsis "Speech recognition toolkit")
1027 (description "Kaldi is an extensible toolkit for speech recognition
1029 (license license:asl2.0))))