Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / machine-learning.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017 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 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages machine-learning)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix utils)
27 #:use-module (guix download)
28 #:use-module (guix svn-download)
29 #:use-module (guix build-system cmake)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system ocaml)
32 #:use-module (guix build-system python)
33 #:use-module (guix build-system r)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages boost)
37 #:use-module (gnu packages check)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages cran)
40 #:use-module (gnu packages dejagnu)
41 #:use-module (gnu packages gcc)
42 #:use-module (gnu packages image)
43 #:use-module (gnu packages maths)
44 #:use-module (gnu packages ocaml)
45 #:use-module (gnu packages perl)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages statistics)
49 #:use-module (gnu packages swig)
50 #:use-module (gnu packages xml)
51 #:use-module (gnu packages xorg))
52
53 (define-public libsvm
54 (package
55 (name "libsvm")
56 (version "3.22")
57 (source
58 (origin
59 (method url-fetch)
60 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
61 name "-" version ".tar.gz"))
62 (sha256
63 (base32
64 "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd"))))
65 (build-system gnu-build-system)
66 (arguments
67 `(#:tests? #f ;no "check" target
68 #:phases (modify-phases %standard-phases
69 (delete 'configure)
70 (replace
71 'install ; no ‘install’ target
72 (lambda* (#:key outputs #:allow-other-keys)
73 (let* ((out (assoc-ref outputs "out"))
74 (bin (string-append out "/bin/")))
75 (mkdir-p bin)
76 (for-each (lambda (file)
77 (copy-file file (string-append bin file)))
78 '("svm-train"
79 "svm-predict"
80 "svm-scale")))
81 #t)))))
82 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
83 (synopsis "Library for Support Vector Machines")
84 (description
85 "LIBSVM is a machine learning library for support vector
86 classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
87 distribution estimation (one-class SVM). It supports multi-class
88 classification.")
89 (license license:bsd-3)))
90
91 (define-public python-libsvm
92 (package (inherit libsvm)
93 (name "python-libsvm")
94 (build-system gnu-build-system)
95 (arguments
96 `(#:tests? #f ;no "check" target
97 #:make-flags '("-C" "python")
98 #:phases
99 (modify-phases %standard-phases
100 (delete 'configure)
101 (replace
102 'install ; no ‘install’ target
103 (lambda* (#:key inputs outputs #:allow-other-keys)
104 (let ((site (string-append (assoc-ref outputs "out")
105 "/lib/python"
106 (string-take
107 (string-take-right
108 (assoc-ref inputs "python") 5) 3)
109 "/site-packages/")))
110 (substitute* "python/svm.py"
111 (("../libsvm.so.2") "libsvm.so.2"))
112 (mkdir-p site)
113 (for-each (lambda (file)
114 (copy-file file (string-append site (basename file))))
115 (find-files "python" "\\.py"))
116 (copy-file "libsvm.so.2"
117 (string-append site "libsvm.so.2")))
118 #t)))))
119 (inputs
120 `(("python" ,python)))
121 (synopsis "Python bindings of libSVM")))
122
123 (define-public ghmm
124 ;; The latest release candidate is several years and a couple of fixes have
125 ;; been published since. This is why we download the sources from the SVN
126 ;; repository.
127 (let ((svn-revision 2341))
128 (package
129 (name "ghmm")
130 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
131 (source (origin
132 (method svn-fetch)
133 (uri (svn-reference
134 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
135 (revision svn-revision)))
136 (file-name (string-append name "-" version))
137 (sha256
138 (base32
139 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
140 (build-system gnu-build-system)
141 (arguments
142 `(#:imported-modules (,@%gnu-build-system-modules
143 (guix build python-build-system))
144 #:phases
145 (modify-phases %standard-phases
146 (add-after 'unpack 'enter-dir
147 (lambda _ (chdir "ghmm") #t))
148 (delete 'check)
149 (add-after 'install 'check
150 (assoc-ref %standard-phases 'check))
151 (add-before 'check 'fix-PYTHONPATH
152 (lambda* (#:key inputs outputs #:allow-other-keys)
153 (let ((python-version ((@@ (guix build python-build-system)
154 get-python-version)
155 (assoc-ref inputs "python"))))
156 (setenv "PYTHONPATH"
157 (string-append (getenv "PYTHONPATH")
158 ":" (assoc-ref outputs "out")
159 "/lib/python" python-version
160 "/site-packages")))
161 #t))
162 (add-after 'enter-dir 'fix-runpath
163 (lambda* (#:key outputs #:allow-other-keys)
164 (substitute* "ghmmwrapper/setup.py"
165 (("^(.*)extra_compile_args = \\[" line indent)
166 (string-append indent
167 "extra_link_args = [\"-Wl,-rpath="
168 (assoc-ref outputs "out") "/lib\"],\n"
169 line
170 "\"-Wl,-rpath="
171 (assoc-ref outputs "out")
172 "/lib\", ")))
173 #t))
174 (add-after 'enter-dir 'disable-broken-tests
175 (lambda _
176 (substitute* "tests/Makefile.am"
177 ;; GHMM_SILENT_TESTS is assumed to be a command.
178 (("TESTS_ENVIRONMENT.*") "")
179 ;; Do not build broken tests.
180 (("chmm .*") "")
181 (("read_fa .*") "")
182 (("mcmc .*") "")
183 (("label_higher_order_test.*$")
184 "label_higher_order_test\n"))
185
186 ;; These Python unittests are broken as there is no gato.
187 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
188 (substitute* "ghmmwrapper/ghmmunittests.py"
189 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
190 line indent)
191 (string-append indent
192 "@unittest.skip(\"Disabled by Guix\")\n"
193 line)))
194 #t))
195 (add-after 'disable-broken-tests 'autogen
196 (lambda _
197 (zero? (system* "bash" "autogen.sh")))))))
198 (inputs
199 `(("python" ,python-2) ; only Python 2 is supported
200 ("libxml2" ,libxml2)))
201 (native-inputs
202 `(("pkg-config" ,pkg-config)
203 ("dejagnu" ,dejagnu)
204 ("swig" ,swig)
205 ("autoconf" ,autoconf)
206 ("automake" ,automake)
207 ("libtool" ,libtool)))
208 (home-page "http://ghmm.org")
209 (synopsis "Hidden Markov Model library")
210 (description
211 "The General Hidden Markov Model library (GHMM) is a C library with
212 additional Python bindings implementing a wide range of types of @dfn{Hidden
213 Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
214 training, HMM clustering, HMM mixtures.")
215 (license license:lgpl2.0+))))
216
217 (define-public mcl
218 (package
219 (name "mcl")
220 (version "14.137")
221 (source (origin
222 (method url-fetch)
223 (uri (string-append
224 "http://micans.org/mcl/src/mcl-"
225 (string-replace-substring version "." "-")
226 ".tar.gz"))
227 (sha256
228 (base32
229 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
230 (build-system gnu-build-system)
231 (arguments
232 `(#:configure-flags (list "--enable-blast")))
233 (inputs
234 `(("perl" ,perl)))
235 (home-page "http://micans.org/mcl/")
236 (synopsis "Clustering algorithm for graphs")
237 (description
238 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
239 fast and scalable unsupervised cluster algorithm for graphs (also known as
240 networks) based on simulation of (stochastic) flow in graphs.")
241 ;; In the LICENCE file and web page it says "The software is licensed
242 ;; under the GNU General Public License, version 3.", but in several of
243 ;; the source code files it suggests GPL3 or later.
244 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
245 (license license:gpl3)))
246
247 (define-public ocaml-mcl
248 (package
249 (name "ocaml-mcl")
250 (version "12-068oasis4")
251 (source
252 (origin
253 (method url-fetch)
254 (uri (string-append
255 "https://github.com/fhcrc/mcl/archive/"
256 version ".tar.gz"))
257 (file-name (string-append name "-" version ".tar.gz"))
258 (sha256
259 (base32
260 "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110"))))
261 (build-system ocaml-build-system)
262 (arguments
263 `(#:phases
264 (modify-phases %standard-phases
265 (add-before 'configure 'patch-paths
266 (lambda _
267 (substitute* "configure"
268 (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh"))))
269 (substitute* "setup.ml"
270 (("LDFLAGS=-fPIC")
271 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))))
272 #t)))))
273 (home-page "https://github.com/fhcrc/mcl")
274 (synopsis "OCaml wrappers around MCL")
275 (description
276 "This package provides OCaml bindings for the MCL graph clustering
277 algorithm.")
278 (license license:gpl3)))
279
280 (define-public ocaml4.01-mcl
281 (package-with-ocaml4.01 ocaml-mcl))
282
283 (define-public randomjungle
284 (package
285 (name "randomjungle")
286 (version "2.1.0")
287 (source
288 (origin
289 (method url-fetch)
290 (uri (string-append
291 "http://www.imbs-luebeck.de/imbs/sites/default/files/u59/"
292 "randomjungle-" version ".tar_.gz"))
293 (sha256
294 (base32
295 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
296 (build-system gnu-build-system)
297 (arguments
298 `(#:configure-flags
299 (list (string-append "--with-boost="
300 (assoc-ref %build-inputs "boost")))
301 #:phases
302 (modify-phases %standard-phases
303 (add-before
304 'configure 'set-CXXFLAGS
305 (lambda _
306 (setenv "CXXFLAGS" "-fpermissive ")
307 #t)))))
308 (inputs
309 `(("boost" ,boost)
310 ("gsl" ,gsl)
311 ("libxml2" ,libxml2)
312 ("zlib" ,zlib)))
313 (native-inputs
314 `(("gfortran" ,gfortran)
315 ("gfortran:lib" ,gfortran "lib")))
316 ;; Non-portable assembly instructions are used so building fails on
317 ;; platforms other than x86_64 or i686.
318 (supported-systems '("x86_64-linux" "i686-linux"))
319 (home-page "http://www.imbs-luebeck.de/imbs/de/node/227/")
320 (synopsis "Implementation of the Random Forests machine learning method")
321 (description
322 "Random Jungle is an implementation of Random Forests. It is supposed to
323 analyse high dimensional data. In genetics, it can be used for analysing big
324 Genome Wide Association (GWA) data. Random Forests is a powerful machine
325 learning method. Most interesting features are variable selection, missing
326 value imputation, classifier creation, generalization error estimation and
327 sample proximities between pairs of cases.")
328 (license license:gpl3+)))
329
330 (define-public shogun
331 (package
332 (name "shogun")
333 (version "4.0.0")
334 (source
335 (origin
336 (method url-fetch)
337 (uri (string-append
338 "ftp://shogun-toolbox.org/shogun/releases/"
339 (version-major+minor version)
340 "/sources/shogun-" version ".tar.bz2"))
341 (sha256
342 (base32
343 "159nlijnb7mnrv9za80wnm1shwvy45hgrqzn51hxy7gw4z6d6fdb"))
344 (modules '((guix build utils)
345 (ice-9 rdelim)))
346 (snippet
347 '(begin
348 ;; Remove non-free sources and files referencing them
349 (for-each delete-file
350 (find-files "src/shogun/classifier/svm/"
351 "SVMLight\\.(cpp|h)"))
352 (for-each delete-file
353 (find-files "examples/undocumented/libshogun/"
354 (string-append
355 "(classifier_.*svmlight.*|"
356 "evaluation_cross_validation_locked_comparison).cpp")))
357 ;; Remove non-free functions.
358 (define (delete-ifdefs file)
359 (with-atomic-file-replacement file
360 (lambda (in out)
361 (let loop ((line (read-line in 'concat))
362 (skipping? #f))
363 (if (eof-object? line)
364 #t
365 (let ((skip-next?
366 (or (and skipping?
367 (not (string-prefix?
368 "#endif //USE_SVMLIGHT" line)))
369 (string-prefix?
370 "#ifdef USE_SVMLIGHT" line))))
371 (when (or (not skipping?)
372 (and skipping? (not skip-next?)))
373 (display line out))
374 (loop (read-line in 'concat) skip-next?)))))))
375 (for-each delete-ifdefs (find-files "src/shogun/kernel/"
376 "^Kernel\\.(cpp|h)"))))))
377 (build-system cmake-build-system)
378 (arguments
379 '(#:tests? #f ;no check target
380 #:phases
381 (modify-phases %standard-phases
382 (add-after 'unpack 'delete-broken-symlinks
383 (lambda _
384 (for-each delete-file '("applications/arts/data"
385 "applications/asp/data"
386 "applications/easysvm/data"
387 "applications/msplicer/data"
388 "applications/ocr/data"
389 "examples/documented/data"
390 "examples/documented/matlab_static"
391 "examples/documented/octave_static"
392 "examples/undocumented/data"
393 "examples/undocumented/matlab_static"
394 "examples/undocumented/octave_static"
395 "tests/integration/data"
396 "tests/integration/matlab_static"
397 "tests/integration/octave_static"
398 "tests/integration/python_modular/tests"))
399 #t))
400 (add-after 'unpack 'change-R-target-path
401 (lambda* (#:key outputs #:allow-other-keys)
402 (substitute* '("src/interfaces/r_modular/CMakeLists.txt"
403 "src/interfaces/r_static/CMakeLists.txt"
404 "examples/undocumented/r_modular/CMakeLists.txt")
405 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
406 (string-append (assoc-ref outputs "out")
407 "/lib/R/library/")))
408 #t))
409 (add-after 'unpack 'fix-octave-modules
410 (lambda* (#:key outputs #:allow-other-keys)
411 (substitute* '("src/interfaces/octave_modular/CMakeLists.txt"
412 "src/interfaces/octave_static/CMakeLists.txt")
413 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
414 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave"))
415
416 ;; change target directory
417 (substitute* "src/interfaces/octave_modular/CMakeLists.txt"
418 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
419 (string-append (assoc-ref outputs "out")
420 "/share/octave/packages")))
421 #t))
422 (add-before 'build 'set-HOME
423 ;; $HOME needs to be set at some point during the build phase
424 (lambda _ (setenv "HOME" "/tmp") #t)))
425 #:configure-flags
426 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
427 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
428 ;;"-DJavaModular=ON" ;requires unpackaged jblas
429 ;;"-DRubyModular=ON" ;requires unpackaged ruby-narray
430 ;;"-DPerlModular=ON" ;"FindPerlLibs" does not exist
431 ;;"-DLuaModular=ON" ;fails because lua doesn't build pkgconfig file
432 "-DOctaveModular=ON"
433 "-DOctaveStatic=ON"
434 "-DPythonModular=ON"
435 "-DPythonStatic=ON"
436 "-DRModular=ON"
437 "-DRStatic=ON"
438 "-DCmdLineStatic=ON")))
439 (inputs
440 `(("python" ,python)
441 ("numpy" ,python-numpy)
442 ("r-minimal" ,r-minimal)
443 ("octave" ,octave)
444 ("swig" ,swig)
445 ("hdf5" ,hdf5)
446 ("atlas" ,atlas)
447 ("arpack" ,arpack-ng)
448 ("lapack" ,lapack)
449 ("glpk" ,glpk)
450 ("libxml2" ,libxml2)
451 ("lzo" ,lzo)
452 ("zlib" ,zlib)))
453 (native-inputs
454 `(("pkg-config" ,pkg-config)))
455 ;; Non-portable SSE instructions are used so building fails on platforms
456 ;; other than x86_64.
457 (supported-systems '("x86_64-linux"))
458 (home-page "http://shogun-toolbox.org/")
459 (synopsis "Machine learning toolbox")
460 (description
461 "The Shogun Machine learning toolbox provides a wide range of unified and
462 efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
463 combine multiple data representations, algorithm classes, and general purpose
464 tools. This enables both rapid prototyping of data pipelines and extensibility
465 in terms of new algorithms.")
466 (license license:gpl3+)))
467
468 (define-public r-adaptivesparsity
469 (package
470 (name "r-adaptivesparsity")
471 (version "1.4")
472 (source (origin
473 (method url-fetch)
474 (uri (cran-uri "AdaptiveSparsity" version))
475 (sha256
476 (base32
477 "1az7isvalf3kmdiycrfl6s9k9xqk22k1mc6rh8v0jmcz402qyq8z"))))
478 (properties
479 `((upstream-name . "AdaptiveSparsity")))
480 (build-system r-build-system)
481 (arguments
482 `(#:phases
483 (modify-phases %standard-phases
484 (add-after 'unpack 'link-against-armadillo
485 (lambda _
486 (substitute* "src/Makevars"
487 (("PKG_LIBS=" prefix)
488 (string-append prefix "-larmadillo"))))))))
489 (propagated-inputs
490 `(("r-rcpp" ,r-rcpp)
491 ("r-rcpparmadillo" ,r-rcpparmadillo)))
492 (inputs
493 `(("armadillo" ,armadillo)))
494 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
495 (synopsis "Adaptive sparsity models")
496 (description
497 "This package implements the Figueiredo machine learning algorithm for
498 adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
499 geometric models.")
500 (license license:lgpl3+)))
501
502 (define-public r-kernlab
503 (package
504 (name "r-kernlab")
505 (version "0.9-25")
506 (source
507 (origin
508 (method url-fetch)
509 (uri (cran-uri "kernlab" version))
510 (sha256
511 (base32
512 "0qnaq9x3j2xc6jrmmd98wc6hkzch487s4p3a9lnc00xvahkhgpmr"))))
513 (build-system r-build-system)
514 (home-page "https://cran.r-project.org/web/packages/kernlab")
515 (synopsis "Kernel-based machine learning tools")
516 (description
517 "This package provides kernel-based machine learning methods for
518 classification, regression, clustering, novelty detection, quantile regression
519 and dimensionality reduction. Among other methods @code{kernlab} includes
520 Support Vector Machines, Spectral Clustering, Kernel PCA, Gaussian Processes
521 and a QP solver.")
522 (license license:gpl2)))
523
524 (define-public dlib
525 (package
526 (name "dlib")
527 (version "19.7")
528 (source (origin
529 (method url-fetch)
530 (uri (string-append
531 "http://dlib.net/files/dlib-" version ".tar.bz2"))
532 (sha256
533 (base32
534 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
535 (modules '((guix build utils)))
536 (snippet
537 '(begin
538 ;; Delete ~13MB of bundled dependencies.
539 (delete-file-recursively "dlib/external")
540 (delete-file-recursively "docs/dlib/external")
541 #t))))
542 (build-system cmake-build-system)
543 (arguments
544 `(#:phases
545 (modify-phases %standard-phases
546 (add-after 'unpack 'disable-asserts
547 (lambda _
548 ;; config.h recommends explicitly enabling or disabling asserts
549 ;; when building as a shared library. By default neither is set.
550 (substitute* "dlib/config.h"
551 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
552 #t))
553 (add-after 'disable-asserts 'disable-failing-tests
554 (lambda _
555 ;; One test times out on MIPS, so we need to disable it.
556 ;; Others are flaky on some platforms.
557 (let* ((system ,(or (%current-target-system)
558 (%current-system)))
559 (disabled-tests (cond
560 ((string-prefix? "mips64" system)
561 '("object_detector" ; timeout
562 "data_io"))
563 ((string-prefix? "armhf" system)
564 '("learning_to_track"))
565 ((string-prefix? "i686" system)
566 '("optimization"))
567 (else '()))))
568 (for-each
569 (lambda (test)
570 (substitute* "dlib/test/makefile"
571 (((string-append "SRC \\+= " test "\\.cpp")) "")))
572 disabled-tests)
573 #t)))
574 (replace 'check
575 (lambda _
576 ;; No test target, so we build and run the unit tests here.
577 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
578 (with-directory-excursion test-dir
579 (and (zero? (system* "make" "-j" (number->string (parallel-job-count))))
580 (zero? (system* "./dtest" "--runall")))))))
581 (add-after 'install 'delete-static-library
582 (lambda* (#:key outputs #:allow-other-keys)
583 (delete-file (string-append (assoc-ref outputs "out")
584 "/lib/libdlib.a"))
585 #t)))))
586 (native-inputs
587 `(("pkg-config" ,pkg-config)))
588 (inputs
589 `(("giflib" ,giflib)
590 ("lapack" ,lapack)
591 ("libjpeg" ,libjpeg)
592 ("libpng" ,libpng)
593 ("libx11" ,libx11)
594 ("openblas" ,openblas)
595 ("zlib" ,zlib)))
596 (synopsis
597 "Toolkit for making machine learning and data analysis applications in C++")
598 (description
599 "Dlib is a modern C++ toolkit containing machine learning algorithms and
600 tools. It is used in both industry and academia in a wide range of domains
601 including robotics, embedded devices, mobile phones, and large high performance
602 computing environments.")
603 (home-page "http://dlib.net")
604 (license license:boost1.0)))
605
606 (define-public python-scikit-learn
607 (package
608 (name "python-scikit-learn")
609 (version "0.19.1")
610 (source
611 (origin
612 (method url-fetch)
613 (uri (string-append
614 "https://github.com/scikit-learn/scikit-learn/archive/"
615 version ".tar.gz"))
616 (file-name (string-append name "-" version ".tar.gz"))
617 (sha256
618 (base32
619 "18n8775kyfwbvcjjjzda9c5sqy4737c0hrmj6qj1ps2jmlqzair9"))
620 (patches (search-patches
621 "python-scikit-learn-fix-test-non-determinism.patch"))))
622 (build-system python-build-system)
623 (arguments
624 `(#:phases
625 (modify-phases %standard-phases
626 (delete 'check)
627 (add-after 'install 'check
628 ;; Running tests from the source directory requires
629 ;; an "inplace" build with paths relative to CWD.
630 ;; http://scikit-learn.org/stable/developers/advanced_installation.html#testing
631 ;; Use the installed version instead.
632 (lambda* (#:key inputs outputs #:allow-other-keys)
633 (add-installed-pythonpath inputs outputs)
634 ;; some tests require access to "$HOME"
635 (setenv "HOME" "/tmp")
636 ;; Step out of the source directory just to be sure.
637 (chdir "..")
638 (zero? (system* "nosetests" "-v" "sklearn")))))))
639 (inputs
640 `(("openblas" ,openblas)))
641 (native-inputs
642 `(("python-nose" ,python-nose)
643 ("python-cython" ,python-cython)))
644 (propagated-inputs
645 `(("python-numpy" ,python-numpy)
646 ("python-scipy" ,python-scipy)))
647 (home-page "http://scikit-learn.org/")
648 (synopsis "Machine Learning in Python")
649 (description
650 "Scikit-learn provides simple and efficient tools for data
651 mining and data analysis.")
652 (license license:bsd-3)))
653
654 (define-public python2-scikit-learn
655 (package-with-python2 python-scikit-learn))