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