;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;;
;;; This file is part of GNU Guix.
;;;
#:use-module (guix packages)
#:use-module (guix utils)
#:use-module (guix download)
+ #:use-module (guix svn-download)
#:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
+ #:use-module (guix build-system ocaml)
+ #:use-module (guix build-system python)
#:use-module (guix build-system r)
#:use-module (gnu packages)
+ #:use-module (gnu packages autotools)
#:use-module (gnu packages boost)
+ #:use-module (gnu packages check)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages cran)
+ #:use-module (gnu packages dejagnu)
#:use-module (gnu packages gcc)
+ #:use-module (gnu packages image)
#:use-module (gnu packages maths)
+ #:use-module (gnu packages ocaml)
+ #:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages statistics)
#:use-module (gnu packages swig)
- #:use-module (gnu packages xml))
+ #:use-module (gnu packages xml)
+ #:use-module (gnu packages xorg))
(define-public libsvm
(package
`(("python" ,python)))
(synopsis "Python bindings of libSVM")))
+(define-public ghmm
+ ;; The latest release candidate is several years and a couple of fixes have
+ ;; been published since. This is why we download the sources from the SVN
+ ;; repository.
+ (let ((svn-revision 2341))
+ (package
+ (name "ghmm")
+ (version (string-append "0.9-rc3-0." (number->string svn-revision)))
+ (source (origin
+ (method svn-fetch)
+ (uri (svn-reference
+ (url "http://svn.code.sf.net/p/ghmm/code/trunk")
+ (revision svn-revision)))
+ (file-name (string-append name "-" version))
+ (sha256
+ (base32
+ "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:imported-modules (,@%gnu-build-system-modules
+ (guix build python-build-system))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'enter-dir
+ (lambda _ (chdir "ghmm") #t))
+ (delete 'check)
+ (add-after 'install 'check
+ (assoc-ref %standard-phases 'check))
+ (add-before 'check 'fix-PYTHONPATH
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((python-version ((@@ (guix build python-build-system)
+ get-python-version)
+ (assoc-ref inputs "python"))))
+ (setenv "PYTHONPATH"
+ (string-append (getenv "PYTHONPATH")
+ ":" (assoc-ref outputs "out")
+ "/lib/python" python-version
+ "/site-packages")))
+ #t))
+ (add-after 'enter-dir 'fix-runpath
+ (lambda* (#:key outputs #:allow-other-keys)
+ (substitute* "ghmmwrapper/setup.py"
+ (("^(.*)extra_compile_args = \\[" line indent)
+ (string-append indent
+ "extra_link_args = [\"-Wl,-rpath="
+ (assoc-ref outputs "out") "/lib\"],\n"
+ line
+ "\"-Wl,-rpath="
+ (assoc-ref outputs "out")
+ "/lib\", ")))
+ #t))
+ (add-after 'enter-dir 'disable-broken-tests
+ (lambda _
+ (substitute* "tests/Makefile.am"
+ ;; GHMM_SILENT_TESTS is assumed to be a command.
+ (("TESTS_ENVIRONMENT.*") "")
+ ;; Do not build broken tests.
+ (("chmm .*") "")
+ (("read_fa .*") "")
+ (("mcmc .*") "")
+ (("label_higher_order_test.*$")
+ "label_higher_order_test\n"))
+
+ ;; These Python unittests are broken as there is no gato.
+ ;; See https://sourceforge.net/p/ghmm/support-requests/3/
+ (substitute* "ghmmwrapper/ghmmunittests.py"
+ (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
+ line indent)
+ (string-append indent
+ "@unittest.skip(\"Disabled by Guix\")\n"
+ line)))
+ #t))
+ (add-after 'disable-broken-tests 'autogen
+ (lambda _
+ (zero? (system* "bash" "autogen.sh")))))))
+ (inputs
+ `(("python" ,python-2) ; only Python 2 is supported
+ ("libxml2" ,libxml2)))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)
+ ("dejagnu" ,dejagnu)
+ ("swig" ,swig)
+ ("autoconf" ,autoconf)
+ ("automake" ,automake)
+ ("libtool" ,libtool)))
+ (home-page "http://ghmm.org")
+ (synopsis "Hidden Markov Model library")
+ (description
+ "The General Hidden Markov Model library (GHMM) is a C library with
+additional Python bindings implementing a wide range of types of @dfn{Hidden
+Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
+training, HMM clustering, HMM mixtures.")
+ (license license:lgpl2.0+))))
+
+(define-public mcl
+ (package
+ (name "mcl")
+ (version "14.137")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "http://micans.org/mcl/src/mcl-"
+ (string-replace-substring version "." "-")
+ ".tar.gz"))
+ (sha256
+ (base32
+ "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:configure-flags (list "--enable-blast")))
+ (inputs
+ `(("perl" ,perl)))
+ (home-page "http://micans.org/mcl/")
+ (synopsis "Clustering algorithm for graphs")
+ (description
+ "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
+fast and scalable unsupervised cluster algorithm for graphs (also known as
+networks) based on simulation of (stochastic) flow in graphs.")
+ ;; In the LICENCE file and web page it says "The software is licensed
+ ;; under the GNU General Public License, version 3.", but in several of
+ ;; the source code files it suggests GPL3 or later.
+ ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
+ (license license:gpl3)))
+
+(define-public ocaml-mcl
+ (package
+ (name "ocaml-mcl")
+ (version "12-068oasis4")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/fhcrc/mcl/archive/"
+ version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110"))))
+ (build-system ocaml-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-before 'configure 'patch-paths
+ (lambda _
+ (substitute* "configure"
+ (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh"))))
+ (substitute* "setup.ml"
+ (("LDFLAGS=-fPIC")
+ (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))))
+ #t)))))
+ (home-page "https://github.com/fhcrc/mcl")
+ (synopsis "OCaml wrappers around MCL")
+ (description
+ "This package provides OCaml bindings for the MCL graph clustering
+algorithm.")
+ (license license:gpl3)))
+
+(define-public ocaml4.01-mcl
+ (package-with-ocaml4.01 ocaml-mcl))
+
(define-public randomjungle
(package
(name "randomjungle")
("libxml2" ,libxml2)
("zlib" ,zlib)))
(native-inputs
- `(("gfortran" ,gfortran)))
+ `(("gfortran" ,gfortran)
+ ("gfortran:lib" ,gfortran "lib")))
+ ;; Non-portable assembly instructions are used so building fails on
+ ;; platforms other than x86_64 or i686.
+ (supported-systems '("x86_64-linux" "i686-linux"))
(home-page "http://www.imbs-luebeck.de/imbs/de/node/227/")
(synopsis "Implementation of the Random Forests machine learning method")
(description
(arguments
'(#:tests? #f ;no check target
#:phases
- (alist-cons-after
- 'unpack 'delete-broken-symlinks
- (lambda _
- (for-each delete-file '("applications/arts/data"
- "applications/asp/data"
- "applications/easysvm/data"
- "applications/msplicer/data"
- "applications/ocr/data"
- "examples/documented/data"
- "examples/documented/matlab_static"
- "examples/documented/octave_static"
- "examples/undocumented/data"
- "examples/undocumented/matlab_static"
- "examples/undocumented/octave_static"
- "tests/integration/data"
- "tests/integration/matlab_static"
- "tests/integration/octave_static"
- "tests/integration/python_modular/tests"))
- #t)
- (alist-cons-after
- 'unpack 'change-R-target-path
- (lambda* (#:key outputs #:allow-other-keys)
- (substitute* '("src/interfaces/r_modular/CMakeLists.txt"
- "src/interfaces/r_static/CMakeLists.txt"
- "examples/undocumented/r_modular/CMakeLists.txt")
- (("\\$\\{R_COMPONENT_LIB_PATH\\}")
- (string-append (assoc-ref outputs "out")
- "/lib/R/library/")))
- #t)
- (alist-cons-after
- 'unpack 'fix-octave-modules
- (lambda* (#:key outputs #:allow-other-keys)
- (substitute* '("src/interfaces/octave_modular/CMakeLists.txt"
- "src/interfaces/octave_static/CMakeLists.txt")
- (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
- "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave"))
+ (modify-phases %standard-phases
+ (add-after 'unpack 'delete-broken-symlinks
+ (lambda _
+ (for-each delete-file '("applications/arts/data"
+ "applications/asp/data"
+ "applications/easysvm/data"
+ "applications/msplicer/data"
+ "applications/ocr/data"
+ "examples/documented/data"
+ "examples/documented/matlab_static"
+ "examples/documented/octave_static"
+ "examples/undocumented/data"
+ "examples/undocumented/matlab_static"
+ "examples/undocumented/octave_static"
+ "tests/integration/data"
+ "tests/integration/matlab_static"
+ "tests/integration/octave_static"
+ "tests/integration/python_modular/tests"))
+ #t))
+ (add-after 'unpack 'change-R-target-path
+ (lambda* (#:key outputs #:allow-other-keys)
+ (substitute* '("src/interfaces/r_modular/CMakeLists.txt"
+ "src/interfaces/r_static/CMakeLists.txt"
+ "examples/undocumented/r_modular/CMakeLists.txt")
+ (("\\$\\{R_COMPONENT_LIB_PATH\\}")
+ (string-append (assoc-ref outputs "out")
+ "/lib/R/library/")))
+ #t))
+ (add-after 'unpack 'fix-octave-modules
+ (lambda* (#:key outputs #:allow-other-keys)
+ (substitute* '("src/interfaces/octave_modular/CMakeLists.txt"
+ "src/interfaces/octave_static/CMakeLists.txt")
+ (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
+ "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave"))
- ;; change target directory
- (substitute* "src/interfaces/octave_modular/CMakeLists.txt"
- (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
- (string-append (assoc-ref outputs "out")
- "/share/octave/packages")))
- #t)
- (alist-cons-before
- 'build 'set-HOME
+ ;; change target directory
+ (substitute* "src/interfaces/octave_modular/CMakeLists.txt"
+ (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
+ (string-append (assoc-ref outputs "out")
+ "/share/octave/packages")))
+ #t))
+ (add-before 'build 'set-HOME
;; $HOME needs to be set at some point during the build phase
- (lambda _ (setenv "HOME" "/tmp") #t)
- %standard-phases))))
+ (lambda _ (setenv "HOME" "/tmp") #t)))
#:configure-flags
(list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
"-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
(inputs
`(("python" ,python)
("numpy" ,python-numpy)
- ("r" ,r)
+ ("r-minimal" ,r-minimal)
("octave" ,octave)
("swig" ,swig)
("hdf5" ,hdf5)
(propagated-inputs
`(("r-rcpp" ,r-rcpp)
("r-rcpparmadillo" ,r-rcpparmadillo)))
+ (inputs
+ `(("armadillo" ,armadillo)))
(home-page "http://cran.r-project.org/web/packages/AdaptiveSparsity")
(synopsis "Adaptive sparsity models")
(description
geometric models.")
(license license:lgpl3+)))
-(define-public r-nnet
+(define-public r-kernlab
(package
- (name "r-nnet")
- (version "7.3-12")
+ (name "r-kernlab")
+ (version "0.9-25")
(source
(origin
(method url-fetch)
- (uri (cran-uri "nnet" version))
+ (uri (cran-uri "kernlab" version))
(sha256
(base32
- "17amqnw9dpap2w8ivx53hxha2xrm0drwfnj32li0xk41hlz548r7"))))
+ "0qnaq9x3j2xc6jrmmd98wc6hkzch487s4p3a9lnc00xvahkhgpmr"))))
(build-system r-build-system)
- (home-page "http://www.stats.ox.ac.uk/pub/MASS4/")
- (synopsis "Feed-forward neural networks and multinomial log-linear models")
+ (home-page "http://cran.r-project.org/web/packages/kernlab")
+ (synopsis "Kernel-based machine learning tools")
(description
- "This package provides functions for feed-forward neural networks with a
-single hidden layer, and for multinomial log-linear models.")
- (license (list license:gpl2+ license:gpl3+))))
+ "This package provides kernel-based machine learning methods for
+classification, regression, clustering, novelty detection, quantile regression
+and dimensionality reduction. Among other methods @code{kernlab} includes
+Support Vector Machines, Spectral Clustering, Kernel PCA, Gaussian Processes
+and a QP solver.")
+ (license license:gpl2)))
+
+(define-public dlib
+ (package
+ (name "dlib")
+ (version "19.7")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append
+ "http://dlib.net/files/dlib-" version ".tar.bz2"))
+ (sha256
+ (base32
+ "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Delete ~13MB of bundled dependencies.
+ (delete-file-recursively "dlib/external")
+ (delete-file-recursively "docs/dlib/external")
+ #t))))
+ (build-system cmake-build-system)
+ (arguments
+ ;; Recent releases defaults to "lib64" on 64bit.
+ `(#:configure-flags (list (string-append "-DCMAKE_INSTALL_LIBDIR="
+ (assoc-ref %outputs "out")
+ "/lib"))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'disable-asserts
+ (lambda _
+ ;; config.h recommends explicitly enabling or disabling asserts
+ ;; when building as a shared library. By default neither is set.
+ (substitute* "dlib/config.h"
+ (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
+ #t))
+ (add-after 'disable-asserts 'disable-failing-tests
+ (lambda _
+ ;; One test times out on MIPS, so we need to disable it.
+ ;; Others are flaky on some platforms.
+ (let* ((system ,(or (%current-target-system)
+ (%current-system)))
+ (disabled-tests (cond
+ ((string-prefix? "mips64" system)
+ '("object_detector" ; timeout
+ "data_io"))
+ ((string-prefix? "armhf" system)
+ '("learning_to_track"))
+ ((string-prefix? "i686" system)
+ '("optimization"))
+ (else '()))))
+ (for-each
+ (lambda (test)
+ (substitute* "dlib/test/makefile"
+ (((string-append "SRC \\+= " test "\\.cpp")) "")))
+ disabled-tests)
+ #t)))
+ (replace 'check
+ (lambda _
+ ;; No test target, so we build and run the unit tests here.
+ (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
+ (with-directory-excursion test-dir
+ (and (zero? (system* "make" "-j" (number->string (parallel-job-count))))
+ (zero? (system* "./dtest" "--runall")))))))
+ (add-after 'install 'delete-static-library
+ (lambda* (#:key outputs #:allow-other-keys)
+ (delete-file (string-append (assoc-ref outputs "out")
+ "/lib/libdlib.a"))
+ #t)))))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)))
+ (inputs
+ `(("giflib" ,giflib)
+ ("lapack" ,lapack)
+ ("libjpeg" ,libjpeg)
+ ("libpng" ,libpng)
+ ("libx11" ,libx11)
+ ("openblas" ,openblas)
+ ("zlib" ,zlib)))
+ (synopsis
+ "Toolkit for making machine learning and data analysis applications in C++")
+ (description
+ "Dlib is a modern C++ toolkit containing machine learning algorithms and
+tools. It is used in both industry and academia in a wide range of domains
+including robotics, embedded devices, mobile phones, and large high performance
+computing environments.")
+ (home-page "http://dlib.net")
+ (license license:boost1.0)))
+
+(define-public python-scikit-learn
+ (package
+ (name "python-scikit-learn")
+ (version "0.19.0")
+ (source
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/scikit-learn/scikit-learn/archive/"
+ version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0g7q4ri75mj93wpa9bp83a3jmrf3dm5va9h7k4zkbcxr6bgqka15"))))
+ (build-system python-build-system)
+ (arguments
+ `(#:phases
+ (modify-phases %standard-phases
+ (delete 'check)
+ (add-after 'install 'check
+ ;; Running tests from the source directory requires
+ ;; an "inplace" build with paths relative to CWD.
+ ;; http://scikit-learn.org/stable/developers/advanced_installation.html#testing
+ ;; Use the installed version instead.
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (add-installed-pythonpath inputs outputs)
+ ;; some tests require access to "$HOME"
+ (setenv "HOME" "/tmp")
+ ;; Step out of the source directory just to be sure.
+ (chdir "..")
+ (zero? (system* "nosetests" "-v" "sklearn")))))))
+ (inputs
+ `(("openblas" ,openblas)))
+ (native-inputs
+ `(("python-nose" ,python-nose)
+ ("python-cython" ,python-cython)))
+ (propagated-inputs
+ `(("python-numpy" ,python-numpy)
+ ("python-scipy" ,python-scipy)))
+ (home-page "http://scikit-learn.org/")
+ (synopsis "Machine Learning in Python")
+ (description
+ "Scikit-learn provides simple and efficient tools for data
+mining and data analysis.")
+ (license license:bsd-3)))
+
+(define-public python2-scikit-learn
+ (package-with-python2 python-scikit-learn))