gnu: OpenSSH: Update to 7.9p1.
[jackhill/guix/guix.git] / gnu / packages / machine-learning.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017, 2018 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 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages machine-learning)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
32 #:use-module (guix svn-download)
33 #:use-module (guix build-system cmake)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system ocaml)
36 #:use-module (guix build-system python)
37 #:use-module (guix build-system r)
38 #:use-module (guix git-download)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages algebra)
41 #:use-module (gnu packages autotools)
42 #:use-module (gnu packages boost)
43 #:use-module (gnu packages check)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages cran)
46 #:use-module (gnu packages dejagnu)
47 #:use-module (gnu packages gcc)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages maths)
50 #:use-module (gnu packages mpi)
51 #:use-module (gnu packages ocaml)
52 #:use-module (gnu packages onc-rpc)
53 #:use-module (gnu packages perl)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages statistics)
57 #:use-module (gnu packages swig)
58 #:use-module (gnu packages xml)
59 #:use-module (gnu packages xorg))
60
61 (define-public fann
62 ;; The last release is >100 commits behind, so we package from git.
63 (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7"))
64 (package
65 (name "fann")
66 (version (string-append "2.2.0-1." (string-take commit 8)))
67 (source (origin
68 (method git-fetch)
69 (uri (git-reference
70 (url "https://github.com/libfann/fann.git")
71 (commit commit)))
72 (file-name (string-append name "-" version "-checkout"))
73 (sha256
74 (base32
75 "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x"))))
76 (build-system cmake-build-system)
77 (arguments
78 `(#:phases
79 (modify-phases %standard-phases
80 (replace 'check
81 (lambda* (#:key outputs #:allow-other-keys)
82 (let* ((out (assoc-ref outputs "out")))
83 (with-directory-excursion (string-append (getcwd) "/tests")
84 (invoke "./fann_tests"))))))))
85 (home-page "http://leenissen.dk/fann/wp/")
86 (synopsis "Fast Artificial Neural Network")
87 (description
88 "FANN is a free open source neural network library, which implements
89 multilayer artificial neural networks in C with support for both fully
90 connected and sparsely connected networks.")
91 (license license:lgpl2.1))))
92
93 (define-public libsvm
94 (package
95 (name "libsvm")
96 (version "3.22")
97 (source
98 (origin
99 (method url-fetch)
100 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
101 name "-" version ".tar.gz"))
102 (sha256
103 (base32
104 "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd"))))
105 (build-system gnu-build-system)
106 (arguments
107 `(#:tests? #f ;no "check" target
108 #:phases (modify-phases %standard-phases
109 (delete 'configure)
110 (replace
111 'install ; no ‘install’ target
112 (lambda* (#:key outputs #:allow-other-keys)
113 (let* ((out (assoc-ref outputs "out"))
114 (bin (string-append out "/bin/")))
115 (mkdir-p bin)
116 (for-each (lambda (file)
117 (copy-file file (string-append bin file)))
118 '("svm-train"
119 "svm-predict"
120 "svm-scale")))
121 #t)))))
122 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
123 (synopsis "Library for Support Vector Machines")
124 (description
125 "LIBSVM is a machine learning library for support vector
126 classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
127 distribution estimation (one-class SVM). It supports multi-class
128 classification.")
129 (license license:bsd-3)))
130
131 (define-public python-libsvm
132 (package (inherit libsvm)
133 (name "python-libsvm")
134 (build-system gnu-build-system)
135 (arguments
136 `(#:tests? #f ;no "check" target
137 #:make-flags '("-C" "python")
138 #:phases
139 (modify-phases %standard-phases
140 (delete 'configure)
141 (replace
142 'install ; no ‘install’ target
143 (lambda* (#:key inputs outputs #:allow-other-keys)
144 (let ((site (string-append (assoc-ref outputs "out")
145 "/lib/python"
146 (string-take
147 (string-take-right
148 (assoc-ref inputs "python") 5) 3)
149 "/site-packages/")))
150 (substitute* "python/svm.py"
151 (("../libsvm.so.2") "libsvm.so.2"))
152 (mkdir-p site)
153 (for-each (lambda (file)
154 (copy-file file (string-append site (basename file))))
155 (find-files "python" "\\.py"))
156 (copy-file "libsvm.so.2"
157 (string-append site "libsvm.so.2")))
158 #t)))))
159 (inputs
160 `(("python" ,python)))
161 (synopsis "Python bindings of libSVM")))
162
163 (define-public ghmm
164 ;; The latest release candidate is several years and a couple of fixes have
165 ;; been published since. This is why we download the sources from the SVN
166 ;; repository.
167 (let ((svn-revision 2341))
168 (package
169 (name "ghmm")
170 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
171 (source (origin
172 (method svn-fetch)
173 (uri (svn-reference
174 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
175 (revision svn-revision)))
176 (file-name (string-append name "-" version))
177 (sha256
178 (base32
179 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
180 (build-system gnu-build-system)
181 (arguments
182 `(#:imported-modules (,@%gnu-build-system-modules
183 (guix build python-build-system))
184 #:phases
185 (modify-phases %standard-phases
186 (add-after 'unpack 'enter-dir
187 (lambda _ (chdir "ghmm") #t))
188 (delete 'check)
189 (add-after 'install 'check
190 (assoc-ref %standard-phases 'check))
191 (add-before 'check 'fix-PYTHONPATH
192 (lambda* (#:key inputs outputs #:allow-other-keys)
193 (let ((python-version ((@@ (guix build python-build-system)
194 get-python-version)
195 (assoc-ref inputs "python"))))
196 (setenv "PYTHONPATH"
197 (string-append (getenv "PYTHONPATH")
198 ":" (assoc-ref outputs "out")
199 "/lib/python" python-version
200 "/site-packages")))
201 #t))
202 (add-after 'enter-dir 'fix-runpath
203 (lambda* (#:key outputs #:allow-other-keys)
204 (substitute* "ghmmwrapper/setup.py"
205 (("^(.*)extra_compile_args = \\[" line indent)
206 (string-append indent
207 "extra_link_args = [\"-Wl,-rpath="
208 (assoc-ref outputs "out") "/lib\"],\n"
209 line
210 "\"-Wl,-rpath="
211 (assoc-ref outputs "out")
212 "/lib\", ")))
213 #t))
214 (add-after 'enter-dir 'disable-broken-tests
215 (lambda _
216 (substitute* "tests/Makefile.am"
217 ;; GHMM_SILENT_TESTS is assumed to be a command.
218 (("TESTS_ENVIRONMENT.*") "")
219 ;; Do not build broken tests.
220 (("chmm .*") "")
221 (("read_fa .*") "")
222 (("mcmc .*") "")
223 (("label_higher_order_test.*$")
224 "label_higher_order_test\n"))
225
226 ;; These Python unittests are broken as there is no gato.
227 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
228 (substitute* "ghmmwrapper/ghmmunittests.py"
229 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
230 line indent)
231 (string-append indent
232 "@unittest.skip(\"Disabled by Guix\")\n"
233 line)))
234 #t))
235 (add-after 'disable-broken-tests 'autogen
236 (lambda _
237 (invoke "bash" "autogen.sh"))))))
238 (inputs
239 `(("python" ,python-2) ; only Python 2 is supported
240 ("libxml2" ,libxml2)))
241 (native-inputs
242 `(("pkg-config" ,pkg-config)
243 ("dejagnu" ,dejagnu)
244 ("swig" ,swig)
245 ("autoconf" ,autoconf)
246 ("automake" ,automake)
247 ("libtool" ,libtool)))
248 (home-page "http://ghmm.org")
249 (synopsis "Hidden Markov Model library")
250 (description
251 "The General Hidden Markov Model library (GHMM) is a C library with
252 additional Python bindings implementing a wide range of types of @dfn{Hidden
253 Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
254 training, HMM clustering, HMM mixtures.")
255 (license license:lgpl2.0+))))
256
257 (define-public mcl
258 (package
259 (name "mcl")
260 (version "14.137")
261 (source (origin
262 (method url-fetch)
263 (uri (string-append
264 "http://micans.org/mcl/src/mcl-"
265 (string-replace-substring version "." "-")
266 ".tar.gz"))
267 (sha256
268 (base32
269 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
270 (build-system gnu-build-system)
271 (arguments
272 `(#:configure-flags (list "--enable-blast")))
273 (inputs
274 `(("perl" ,perl)))
275 (home-page "http://micans.org/mcl/")
276 (synopsis "Clustering algorithm for graphs")
277 (description
278 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
279 fast and scalable unsupervised cluster algorithm for graphs (also known as
280 networks) based on simulation of (stochastic) flow in graphs.")
281 ;; In the LICENCE file and web page it says "The software is licensed
282 ;; under the GNU General Public License, version 3.", but in several of
283 ;; the source code files it suggests GPL3 or later.
284 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
285 (license license:gpl3)))
286
287 (define-public ocaml-mcl
288 (package
289 (name "ocaml-mcl")
290 (version "12-068oasis4")
291 (source
292 (origin
293 (method url-fetch)
294 (uri (string-append
295 "https://github.com/fhcrc/mcl/archive/"
296 version ".tar.gz"))
297 (file-name (string-append name "-" version ".tar.gz"))
298 (sha256
299 (base32
300 "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110"))))
301 (build-system ocaml-build-system)
302 (arguments
303 `(#:phases
304 (modify-phases %standard-phases
305 (add-before 'configure 'patch-paths
306 (lambda _
307 (substitute* "configure"
308 (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh"))))
309 (substitute* "setup.ml"
310 (("LDFLAGS=-fPIC")
311 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))))
312 #t)))))
313 (home-page "https://github.com/fhcrc/mcl")
314 (synopsis "OCaml wrappers around MCL")
315 (description
316 "This package provides OCaml bindings for the MCL graph clustering
317 algorithm.")
318 (license license:gpl3)))
319
320 (define-public ocaml4.01-mcl
321 (package-with-ocaml4.01 ocaml-mcl))
322
323 (define-public randomjungle
324 (package
325 (name "randomjungle")
326 (version "2.1.0")
327 (source
328 (origin
329 (method url-fetch)
330 (uri (string-append
331 "http://www.imbs-luebeck.de/imbs/sites/default/files/u59/"
332 "randomjungle-" version ".tar_.gz"))
333 (sha256
334 (base32
335 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
336 (build-system gnu-build-system)
337 (arguments
338 `(#:configure-flags
339 (list (string-append "--with-boost="
340 (assoc-ref %build-inputs "boost")))
341 #:phases
342 (modify-phases %standard-phases
343 (add-before
344 'configure 'set-CXXFLAGS
345 (lambda _
346 (setenv "CXXFLAGS" "-fpermissive ")
347 #t)))))
348 (inputs
349 `(("boost" ,boost)
350 ("gsl" ,gsl)
351 ("libxml2" ,libxml2)
352 ("zlib" ,zlib)))
353 (native-inputs
354 `(("gfortran" ,gfortran)
355 ("gfortran:lib" ,gfortran "lib")))
356 ;; Non-portable assembly instructions are used so building fails on
357 ;; platforms other than x86_64 or i686.
358 (supported-systems '("x86_64-linux" "i686-linux"))
359 (home-page "http://www.imbs-luebeck.de/imbs/de/node/227/")
360 (synopsis "Implementation of the Random Forests machine learning method")
361 (description
362 "Random Jungle is an implementation of Random Forests. It is supposed to
363 analyse high dimensional data. In genetics, it can be used for analysing big
364 Genome Wide Association (GWA) data. Random Forests is a powerful machine
365 learning method. Most interesting features are variable selection, missing
366 value imputation, classifier creation, generalization error estimation and
367 sample proximities between pairs of cases.")
368 (license license:gpl3+)))
369
370 (define-public shogun
371 (package
372 (name "shogun")
373 (version "6.1.3")
374 (source
375 (origin
376 (method url-fetch)
377 (uri (string-append
378 "ftp://shogun-toolbox.org/shogun/releases/"
379 (version-major+minor version)
380 "/sources/shogun-" version ".tar.bz2"))
381 (sha256
382 (base32
383 "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp"))
384 (modules '((guix build utils)
385 (ice-9 rdelim)))
386 (snippet
387 '(begin
388 ;; Remove non-free sources and files referencing them
389 (for-each delete-file
390 (find-files "src/shogun/classifier/svm/"
391 "SVMLight\\.(cpp|h)"))
392 (for-each delete-file
393 (find-files "examples/undocumented/libshogun/"
394 (string-append
395 "(classifier_.*svmlight.*|"
396 "evaluation_cross_validation_locked_comparison).cpp")))
397 ;; Remove non-free functions.
398 (define (delete-ifdefs file)
399 (with-atomic-file-replacement file
400 (lambda (in out)
401 (let loop ((line (read-line in 'concat))
402 (skipping? #f))
403 (if (eof-object? line)
404 #t
405 (let ((skip-next?
406 (or (and skipping?
407 (not (string-prefix?
408 "#endif //USE_SVMLIGHT" line)))
409 (string-prefix?
410 "#ifdef USE_SVMLIGHT" line))))
411 (when (or (not skipping?)
412 (and skipping? (not skip-next?)))
413 (display line out))
414 (loop (read-line in 'concat) skip-next?)))))))
415 (for-each delete-ifdefs
416 (append
417 (find-files "src/shogun/classifier/mkl"
418 "^MKLClassification\\.cpp")
419 (find-files "src/shogun/classifier/svm"
420 "^SVMLightOneClass\\.(cpp|h)")
421 (find-files "src/shogun/multiclass"
422 "^ScatterSVM\\.(cpp|h)")
423 (find-files "src/shogun/kernel/"
424 "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)")
425 (find-files "src/shogun/regression/svr"
426 "^(MKLRegression|SVRLight)\\.(cpp|h)")
427 (find-files "src/shogun/transfer/domain_adaptation"
428 "^DomainAdaptationSVM\\.(cpp|h)")))
429 #t))))
430 (build-system cmake-build-system)
431 (arguments
432 '(#:tests? #f ;no check target
433 #:phases
434 (modify-phases %standard-phases
435 (add-after 'unpack 'delete-broken-symlinks
436 (lambda _
437 (for-each delete-file '("applications/arts/data"
438 "applications/asp/data"
439 "applications/easysvm/data"
440 "applications/msplicer/data"
441 "applications/ocr/data"
442 "examples/meta/data"
443 "examples/undocumented/data"))
444 #t))
445 (add-after 'unpack 'change-R-target-path
446 (lambda* (#:key outputs #:allow-other-keys)
447 (substitute* '("src/interfaces/r/CMakeLists.txt"
448 "examples/meta/r/CMakeLists.txt")
449 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
450 (string-append (assoc-ref outputs "out")
451 "/lib/R/library/")))
452 #t))
453 (add-after 'unpack 'fix-octave-modules
454 (lambda* (#:key outputs #:allow-other-keys)
455 (substitute* "src/interfaces/octave/CMakeLists.txt"
456 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
457 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave")
458 ;; change target directory
459 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
460 (string-append (assoc-ref outputs "out")
461 "/share/octave/packages")))
462 (substitute* '("src/interfaces/octave/swig_typemaps.i"
463 "src/interfaces/octave/sg_print_functions.cpp")
464 ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave.
465 (("octave/config\\.h") "octave/octave-config.h")
466 (("octave/oct-obj.h") "octave/ovl.h"))
467 #t))
468 (add-after 'unpack 'move-rxcpp
469 (lambda* (#:key inputs #:allow-other-keys)
470 (let ((rxcpp-dir "shogun/third-party/rxcpp"))
471 (mkdir-p rxcpp-dir)
472 (install-file (assoc-ref inputs "rxcpp") rxcpp-dir)
473 #t)))
474 (add-before 'build 'set-HOME
475 ;; $HOME needs to be set at some point during the build phase
476 (lambda _ (setenv "HOME" "/tmp") #t)))
477 #:configure-flags
478 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
479 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
480 "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags
481 ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas
482 ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray
483 ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist
484 ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file
485 "-DINTERFACE_OCTAVE=ON"
486 "-DINTERFACE_PYTHON=ON"
487 "-DINTERFACE_R=ON")))
488 (inputs
489 `(("python" ,python)
490 ("numpy" ,python-numpy)
491 ("r-minimal" ,r-minimal)
492 ("octave" ,octave)
493 ("swig" ,swig)
494 ("eigen" ,eigen)
495 ("hdf5" ,hdf5)
496 ("atlas" ,atlas)
497 ("arpack" ,arpack-ng)
498 ("lapack" ,lapack)
499 ("glpk" ,glpk)
500 ("libxml2" ,libxml2)
501 ("lzo" ,lzo)
502 ("zlib" ,zlib)))
503 (native-inputs
504 `(("pkg-config" ,pkg-config)
505 ("rxcpp" ,rxcpp)))
506 ;; Non-portable SSE instructions are used so building fails on platforms
507 ;; other than x86_64.
508 (supported-systems '("x86_64-linux"))
509 (home-page "http://shogun-toolbox.org/")
510 (synopsis "Machine learning toolbox")
511 (description
512 "The Shogun Machine learning toolbox provides a wide range of unified and
513 efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
514 combine multiple data representations, algorithm classes, and general purpose
515 tools. This enables both rapid prototyping of data pipelines and extensibility
516 in terms of new algorithms.")
517 (license license:gpl3+)))
518
519 (define-public rxcpp
520 (package
521 (name "rxcpp")
522 (version "4.0.0")
523 (source
524 (origin
525 (method url-fetch)
526 (uri (string-append "https://github.com/ReactiveX/RxCpp/archive/v"
527 version ".tar.gz"))
528 (sha256
529 (base32
530 "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh"))
531 (file-name (string-append name "-" version ".tar.gz"))))
532 (build-system cmake-build-system)
533 (arguments
534 `(#:phases
535 (modify-phases %standard-phases
536 (add-after 'unpack 'remove-werror
537 (lambda _
538 (substitute* (find-files ".")
539 (("-Werror") ""))
540 #t))
541 (replace 'check
542 (lambda _
543 (invoke "ctest"))))))
544 (native-inputs
545 `(("catch" ,catch-framework)))
546 (home-page "http://reactivex.io/")
547 (synopsis "Reactive Extensions for C++")
548 (description
549 "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for
550 values-distributed-in-time. ReactiveX is a library for composing asynchronous
551 and event-based programs by using observable sequences.
552
553 It extends the observer pattern to support sequences of data and/or events and
554 adds operators that allow you to compose sequences together declaratively while
555 abstracting away concerns about things like low-level threading,
556 synchronization, thread-safety, concurrent data structures, and non-blocking
557 I/O.")
558 (license license:asl2.0)))
559
560 (define-public r-adaptivesparsity
561 (package
562 (name "r-adaptivesparsity")
563 (version "1.6")
564 (source (origin
565 (method url-fetch)
566 (uri (cran-uri "AdaptiveSparsity" version))
567 (sha256
568 (base32
569 "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91"))))
570 (properties
571 `((upstream-name . "AdaptiveSparsity")))
572 (build-system r-build-system)
573 (arguments
574 `(#:phases
575 (modify-phases %standard-phases
576 (add-after 'unpack 'link-against-armadillo
577 (lambda _
578 (substitute* "src/Makevars"
579 (("PKG_LIBS=" prefix)
580 (string-append prefix "-larmadillo"))))))))
581 (propagated-inputs
582 `(("r-mass" ,r-mass)
583 ("r-matrix" ,r-matrix)
584 ("r-rcpp" ,r-rcpp)
585 ("r-rcpparmadillo" ,r-rcpparmadillo)))
586 (inputs
587 `(("armadillo" ,armadillo)))
588 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
589 (synopsis "Adaptive sparsity models")
590 (description
591 "This package implements the Figueiredo machine learning algorithm for
592 adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
593 geometric models.")
594 (license license:lgpl3+)))
595
596 (define-public r-kernlab
597 (package
598 (name "r-kernlab")
599 (version "0.9-27")
600 (source
601 (origin
602 (method url-fetch)
603 (uri (cran-uri "kernlab" version))
604 (sha256
605 (base32
606 "1m0xqf6gyvwayz7w3c83y32ayvnlz0jicj8ijk808zq9sh7dbbgn"))))
607 (build-system r-build-system)
608 (home-page "https://cran.r-project.org/web/packages/kernlab")
609 (synopsis "Kernel-based machine learning tools")
610 (description
611 "This package provides kernel-based machine learning methods for
612 classification, regression, clustering, novelty detection, quantile regression
613 and dimensionality reduction. Among other methods @code{kernlab} includes
614 Support Vector Machines, Spectral Clustering, Kernel PCA, Gaussian Processes
615 and a QP solver.")
616 (license license:gpl2)))
617
618 (define-public dlib
619 (package
620 (name "dlib")
621 (version "19.7")
622 (source (origin
623 (method url-fetch)
624 (uri (string-append
625 "http://dlib.net/files/dlib-" version ".tar.bz2"))
626 (sha256
627 (base32
628 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
629 (modules '((guix build utils)))
630 (snippet
631 '(begin
632 ;; Delete ~13MB of bundled dependencies.
633 (delete-file-recursively "dlib/external")
634 (delete-file-recursively "docs/dlib/external")
635 #t))))
636 (build-system cmake-build-system)
637 (arguments
638 `(#:phases
639 (modify-phases %standard-phases
640 (add-after 'unpack 'disable-asserts
641 (lambda _
642 ;; config.h recommends explicitly enabling or disabling asserts
643 ;; when building as a shared library. By default neither is set.
644 (substitute* "dlib/config.h"
645 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
646 #t))
647 (add-after 'disable-asserts 'disable-failing-tests
648 (lambda _
649 ;; One test times out on MIPS, so we need to disable it.
650 ;; Others are flaky on some platforms.
651 (let* ((system ,(or (%current-target-system)
652 (%current-system)))
653 (disabled-tests (cond
654 ((string-prefix? "mips64" system)
655 '("object_detector" ; timeout
656 "data_io"))
657 ((string-prefix? "armhf" system)
658 '("learning_to_track"))
659 ((string-prefix? "i686" system)
660 '("optimization"))
661 (else '()))))
662 (for-each
663 (lambda (test)
664 (substitute* "dlib/test/makefile"
665 (((string-append "SRC \\+= " test "\\.cpp")) "")))
666 disabled-tests)
667 #t)))
668 (replace 'check
669 (lambda _
670 ;; No test target, so we build and run the unit tests here.
671 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
672 (with-directory-excursion test-dir
673 (invoke "make" "-j" (number->string (parallel-job-count)))
674 (invoke "./dtest" "--runall"))
675 #t)))
676 (add-after 'install 'delete-static-library
677 (lambda* (#:key outputs #:allow-other-keys)
678 (delete-file (string-append (assoc-ref outputs "out")
679 "/lib/libdlib.a"))
680 #t)))))
681 (native-inputs
682 `(("pkg-config" ,pkg-config)
683 ;; For tests.
684 ("libnsl" ,libnsl)))
685 (inputs
686 `(("giflib" ,giflib)
687 ("lapack" ,lapack)
688 ("libjpeg" ,libjpeg)
689 ("libpng" ,libpng)
690 ("libx11" ,libx11)
691 ("openblas" ,openblas)
692 ("zlib" ,zlib)))
693 (synopsis
694 "Toolkit for making machine learning and data analysis applications in C++")
695 (description
696 "Dlib is a modern C++ toolkit containing machine learning algorithms and
697 tools. It is used in both industry and academia in a wide range of domains
698 including robotics, embedded devices, mobile phones, and large high performance
699 computing environments.")
700 (home-page "http://dlib.net")
701 (license license:boost1.0)))
702
703 (define-public python-scikit-learn
704 (package
705 (name "python-scikit-learn")
706 (version "0.19.2")
707 (source
708 (origin
709 (method git-fetch)
710 (uri (git-reference
711 (url "https://github.com/scikit-learn/scikit-learn.git")
712 (commit version)))
713 (file-name (git-file-name name version))
714 (sha256
715 (base32
716 "1dk9hdj01c0bny4ps78b7869fjw9gr6qklxf6wyql8h6nh4k19xm"))
717 (patches (search-patches
718 "python-scikit-learn-fix-test-non-determinism.patch"))))
719 (build-system python-build-system)
720 (arguments
721 `(#:phases
722 (modify-phases %standard-phases
723 (add-after 'build 'build-ext
724 (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t))
725 (replace 'check
726 (lambda _
727 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
728 (setenv "OPENBLAS_NUM_THREADS" "1")
729 ;; Disable tests that require network access
730 (delete-file "sklearn/datasets/tests/test_mldata.py")
731 (delete-file "sklearn/datasets/tests/test_rcv1.py")
732 (invoke "pytest" "sklearn")
733 #t))
734 ;; FIXME: This fails with permission denied
735 (delete 'reset-gzip-timestamps))))
736 (inputs
737 `(("openblas" ,openblas)))
738 (native-inputs
739 `(("python-pytest" ,python-pytest)
740 ("python-pandas" ,python-pandas) ;for tests
741 ("python-cython" ,python-cython)))
742 (propagated-inputs
743 `(("python-numpy" ,python-numpy)
744 ("python-scipy" ,python-scipy)))
745 (home-page "http://scikit-learn.org/")
746 (synopsis "Machine Learning in Python")
747 (description
748 "Scikit-learn provides simple and efficient tools for data mining and
749 data analysis.")
750 (license license:bsd-3)))
751
752 (define-public python2-scikit-learn
753 (let ((parent (package-with-python2 python-scikit-learn)))
754 (package (inherit parent)
755 (arguments
756 (substitute-keyword-arguments (package-arguments parent)
757 ((#:phases phases)
758 `(modify-phases ,phases
759 (replace 'check
760 (lambda _
761 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
762 (setenv "OPENBLAS_NUM_THREADS" "1")
763 ;; Some tests expect to be able to write to HOME.
764 (setenv "HOME" "/tmp")
765 ;; Disable tests that require network access
766 (delete-file "sklearn/datasets/tests/test_kddcup99.py")
767 (delete-file "sklearn/datasets/tests/test_mldata.py")
768 (delete-file "sklearn/datasets/tests/test_rcv1.py")
769 (invoke "pytest" "sklearn")
770 #t)))))))))
771
772 (define-public python-autograd
773 (let* ((commit "442205dfefe407beffb33550846434baa90c4de7")
774 (revision "0")
775 (version (git-version "0.0.0" revision commit)))
776 (package
777 (name "python-autograd")
778 (home-page "https://github.com/HIPS/autograd")
779 (source (origin
780 (method git-fetch)
781 (uri (git-reference
782 (url home-page)
783 (commit commit)))
784 (sha256
785 (base32
786 "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4"))
787 (file-name (git-file-name name version))))
788 (version version)
789 (build-system python-build-system)
790 (native-inputs
791 `(("python-nose" ,python-nose)
792 ("python-pytest" ,python-pytest)))
793 (propagated-inputs
794 `(("python-future" ,python-future)
795 ("python-numpy" ,python-numpy)))
796 (arguments
797 `(#:phases (modify-phases %standard-phases
798 (replace 'check
799 (lambda _
800 (invoke "py.test" "-v"))))))
801 (synopsis "Efficiently computes derivatives of NumPy code")
802 (description "Autograd can automatically differentiate native Python and
803 NumPy code. It can handle a large subset of Python's features, including loops,
804 ifs, recursion and closures, and it can even take derivatives of derivatives
805 of derivatives. It supports reverse-mode differentiation
806 (a.k.a. backpropagation), which means it can efficiently take gradients of
807 scalar-valued functions with respect to array-valued arguments, as well as
808 forward-mode differentiation, and the two can be composed arbitrarily. The
809 main intended application of Autograd is gradient-based optimization.")
810 (license license:expat))))
811
812 (define-public python2-autograd
813 (package-with-python2 python-autograd))
814
815 (define-public lightgbm
816 (package
817 (name "lightgbm")
818 (version "2.0.12")
819 (source (origin
820 (method url-fetch)
821 (uri (string-append
822 "https://github.com/Microsoft/LightGBM/archive/v"
823 version ".tar.gz"))
824 (sha256
825 (base32
826 "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1"))
827 (file-name (string-append name "-" version ".tar.gz"))))
828 (native-inputs
829 `(("python-pytest" ,python-pytest)
830 ("python-nose" ,python-nose)))
831 (inputs
832 `(("openmpi" ,openmpi)))
833 (propagated-inputs
834 `(("python-numpy" ,python-numpy)
835 ("python-scipy" ,python-scipy)))
836 (arguments
837 `(#:configure-flags
838 '("-DUSE_MPI=ON")
839 #:phases
840 (modify-phases %standard-phases
841 (replace 'check
842 (lambda* (#:key outputs #:allow-other-keys)
843 (with-directory-excursion ,(string-append "../LightGBM-" version)
844 (invoke "pytest" "tests/c_api_test/test_.py")))))))
845 (build-system cmake-build-system)
846 (home-page "https://github.com/Microsoft/LightGBM")
847 (synopsis "Gradient boosting framework based on decision tree algorithms")
848 (description "LightGBM is a gradient boosting framework that uses tree
849 based learning algorithms. It is designed to be distributed and efficient with
850 the following advantages:
851
852 @itemize
853 @item Faster training speed and higher efficiency
854 @item Lower memory usage
855 @item Better accuracy
856 @item Parallel and GPU learning supported (not enabled in this package)
857 @item Capable of handling large-scale data
858 @end itemize\n")
859 (license license:expat)))
860
861 (define-public vowpal-wabbit
862 ;; Language bindings not included.
863 (package
864 (name "vowpal-wabbit")
865 (version "8.5.0")
866 (source (origin
867 (method url-fetch)
868 (uri (string-append
869 "https://github.com/JohnLangford/vowpal_wabbit/archive/"
870 version ".tar.gz"))
871 (sha256
872 (base32
873 "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr"))
874 (file-name (string-append name "-" version ".tar.gz"))))
875 (inputs
876 `(("boost" ,boost)
877 ("zlib" ,zlib)))
878 (arguments
879 `(#:configure-flags
880 (list (string-append "--with-boost="
881 (assoc-ref %build-inputs "boost")))))
882 (build-system gnu-build-system)
883 (home-page "https://github.com/JohnLangford/vowpal_wabbit")
884 (synopsis "Fast machine learning library for online learning")
885 (description "Vowpal Wabbit is a machine learning system with techniques
886 such as online, hashing, allreduce, reductions, learning2search, active, and
887 interactive learning.")
888 (license license:bsd-3)))