Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
3c441be0 | 2 | ;;; Copyright © 2015, 2016, 2017, 2018 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> |
3a354e10 | 7 | ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net> |
a9b34762 MM |
8 | ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org> |
9 | ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com> | |
2dab4188 | 10 | ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com> |
741115b6 RW |
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) | |
23aab4ab | 32 | #:use-module (guix svn-download) |
c1670a81 | 33 | #:use-module (guix build-system cmake) |
741115b6 | 34 | #:use-module (guix build-system gnu) |
0a3063d6 | 35 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 36 | #:use-module (guix build-system python) |
8406138b | 37 | #:use-module (guix build-system r) |
a9b34762 | 38 | #:use-module (guix git-download) |
71f80f54 | 39 | #:use-module (gnu packages) |
5a14e81e | 40 | #:use-module (gnu packages algebra) |
23aab4ab | 41 | #:use-module (gnu packages autotools) |
0931c609 | 42 | #:use-module (gnu packages boost) |
be6eb2f1 | 43 | #:use-module (gnu packages check) |
0931c609 | 44 | #:use-module (gnu packages compression) |
9e37e537 | 45 | #:use-module (gnu packages cran) |
23aab4ab | 46 | #:use-module (gnu packages dejagnu) |
0931c609 | 47 | #:use-module (gnu packages gcc) |
5f0ff6a9 | 48 | #:use-module (gnu packages image) |
0931c609 | 49 | #:use-module (gnu packages maths) |
112c2c01 | 50 | #:use-module (gnu packages mpi) |
0a3063d6 | 51 | #:use-module (gnu packages ocaml) |
3929f46c | 52 | #:use-module (gnu packages onc-rpc) |
791c11d6 | 53 | #:use-module (gnu packages perl) |
c1670a81 | 54 | #:use-module (gnu packages pkg-config) |
0931c609 | 55 | #:use-module (gnu packages python) |
c1670a81 RW |
56 | #:use-module (gnu packages statistics) |
57 | #:use-module (gnu packages swig) | |
5f0ff6a9 MB |
58 | #:use-module (gnu packages xml) |
59 | #:use-module (gnu packages xorg)) | |
741115b6 | 60 | |
a9b34762 MM |
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 | ||
741115b6 RW |
93 | (define-public libsvm |
94 | (package | |
95 | (name "libsvm") | |
d1308c5e | 96 | (version "3.22") |
741115b6 RW |
97 | (source |
98 | (origin | |
99 | (method url-fetch) | |
d1308c5e TGR |
100 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
101 | name "-" version ".tar.gz")) | |
741115b6 RW |
102 | (sha256 |
103 | (base32 | |
d1308c5e | 104 | "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd")))) |
741115b6 RW |
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 | |
d1308c5e | 111 | 'install ; no ‘install’ target |
741115b6 RW |
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))) | |
71f80f54 RW |
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 | |
d1308c5e | 142 | 'install ; no ‘install’ target |
71f80f54 RW |
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"))) | |
0931c609 | 162 | |
23aab4ab RW |
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 | |
ced12a7b RW |
182 | `(#:imported-modules (,@%gnu-build-system-modules |
183 | (guix build python-build-system)) | |
184 | #:phases | |
23aab4ab RW |
185 | (modify-phases %standard-phases |
186 | (add-after 'unpack 'enter-dir | |
187 | (lambda _ (chdir "ghmm") #t)) | |
ced12a7b RW |
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"))) | |
23aab4ab RW |
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)) | |
d10092b8 | 235 | (add-after 'disable-broken-tests 'autogen |
23aab4ab | 236 | (lambda _ |
3107259f | 237 | (invoke "bash" "autogen.sh")))))) |
23aab4ab RW |
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 | |
d1e4ad1b | 253 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
254 | training, HMM clustering, HMM mixtures.") |
255 | (license license:lgpl2.0+)))) | |
256 | ||
791c11d6 BW |
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 | ||
0a3063d6 BW |
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 | ||
b32208e7 BW |
320 | (define-public ocaml4.01-mcl |
321 | (package-with-ocaml4.01 ocaml-mcl)) | |
322 | ||
0931c609 RW |
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 | |
25e0037a EF |
354 | `(("gfortran" ,gfortran) |
355 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
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")) | |
0931c609 RW |
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+))) | |
c1670a81 RW |
369 | |
370 | (define-public shogun | |
371 | (package | |
372 | (name "shogun") | |
5a14e81e | 373 | (version "6.1.3") |
c1670a81 RW |
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 | |
5a14e81e | 383 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
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?))))))) | |
5a14e81e KK |
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" | |
c0d7c124 | 428 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 429 | #t)))) |
c1670a81 RW |
430 | (build-system cmake-build-system) |
431 | (arguments | |
432 | '(#:tests? #f ;no check target | |
433 | #:phases | |
dc1d3cde KK |
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" | |
5a14e81e KK |
442 | "examples/meta/data" |
443 | "examples/undocumented/data")) | |
dc1d3cde KK |
444 | #t)) |
445 | (add-after 'unpack 'change-R-target-path | |
446 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
447 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
448 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
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) | |
5a14e81e | 455 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 456 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
457 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
458 | ;; change target directory | |
dc1d3cde KK |
459 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
460 | (string-append (assoc-ref outputs "out") | |
461 | "/share/octave/packages"))) | |
5a14e81e KK |
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")) | |
dc1d3cde | 467 | #t)) |
5a14e81e KK |
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))) | |
dc1d3cde | 474 | (add-before 'build 'set-HOME |
c1670a81 | 475 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 476 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
477 | #:configure-flags |
478 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
479 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
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"))) | |
c1670a81 RW |
488 | (inputs |
489 | `(("python" ,python) | |
490 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 491 | ("r-minimal" ,r-minimal) |
c1670a81 RW |
492 | ("octave" ,octave) |
493 | ("swig" ,swig) | |
5a14e81e | 494 | ("eigen" ,eigen) |
c1670a81 RW |
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 | |
5a14e81e KK |
504 | `(("pkg-config" ,pkg-config) |
505 | ("rxcpp" ,rxcpp))) | |
6b5b656f RW |
506 | ;; Non-portable SSE instructions are used so building fails on platforms |
507 | ;; other than x86_64. | |
508 | (supported-systems '("x86_64-linux")) | |
c1670a81 RW |
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+))) | |
8406138b | 518 | |
3a354e10 KK |
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 | ||
8406138b RW |
560 | (define-public r-adaptivesparsity |
561 | (package | |
562 | (name "r-adaptivesparsity") | |
c0608f81 | 563 | (version "1.6") |
8406138b RW |
564 | (source (origin |
565 | (method url-fetch) | |
566 | (uri (cran-uri "AdaptiveSparsity" version)) | |
567 | (sha256 | |
568 | (base32 | |
c0608f81 | 569 | "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91")))) |
8406138b RW |
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 | |
c0608f81 RW |
582 | `(("r-mass" ,r-mass) |
583 | ("r-matrix" ,r-matrix) | |
584 | ("r-rcpp" ,r-rcpp) | |
8406138b | 585 | ("r-rcpparmadillo" ,r-rcpparmadillo))) |
60e36bff LC |
586 | (inputs |
587 | `(("armadillo" ,armadillo))) | |
e9960d8c | 588 | (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity") |
8406138b RW |
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+))) | |
e4785eb8 | 595 | |
f05c7eb4 RW |
596 | (define-public r-kernlab |
597 | (package | |
598 | (name "r-kernlab") | |
c28d8d8d | 599 | (version "0.9-27") |
f05c7eb4 RW |
600 | (source |
601 | (origin | |
602 | (method url-fetch) | |
603 | (uri (cran-uri "kernlab" version)) | |
604 | (sha256 | |
605 | (base32 | |
c28d8d8d | 606 | "1m0xqf6gyvwayz7w3c83y32ayvnlz0jicj8ijk808zq9sh7dbbgn")))) |
f05c7eb4 | 607 | (build-system r-build-system) |
e9960d8c | 608 | (home-page "https://cran.r-project.org/web/packages/kernlab") |
f05c7eb4 RW |
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 | ||
5f0ff6a9 MB |
618 | (define-public dlib |
619 | (package | |
620 | (name "dlib") | |
abe97a58 | 621 | (version "19.7") |
5f0ff6a9 MB |
622 | (source (origin |
623 | (method url-fetch) | |
624 | (uri (string-append | |
625 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
626 | (sha256 | |
627 | (base32 | |
abe97a58 | 628 | "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2")) |
5f0ff6a9 MB |
629 | (modules '((guix build utils))) |
630 | (snippet | |
631 | '(begin | |
632 | ;; Delete ~13MB of bundled dependencies. | |
633 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
634 | (delete-file-recursively "docs/dlib/external") |
635 | #t)))) | |
5f0ff6a9 MB |
636 | (build-system cmake-build-system) |
637 | (arguments | |
677bc34d | 638 | `(#:phases |
5f0ff6a9 MB |
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)) | |
4fba38db MB |
647 | (add-after 'disable-asserts 'disable-failing-tests |
648 | (lambda _ | |
649 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 650 | ;; Others are flaky on some platforms. |
4fba38db MB |
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) | |
a343c461 | 658 | '("learning_to_track")) |
4fba38db | 659 | ((string-prefix? "i686" system) |
0ef7ea66 | 660 | '("optimization")) |
4fba38db | 661 | (else '())))) |
4fba38db MB |
662 | (for-each |
663 | (lambda (test) | |
664 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
665 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
666 | disabled-tests) | |
667 | #t))) | |
5f0ff6a9 MB |
668 | (replace 'check |
669 | (lambda _ | |
670 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 671 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 672 | (with-directory-excursion test-dir |
8448e6bf TGR |
673 | (invoke "make" "-j" (number->string (parallel-job-count))) |
674 | (invoke "./dtest" "--runall")) | |
675 | #t))) | |
5f0ff6a9 MB |
676 | (add-after 'install 'delete-static-library |
677 | (lambda* (#:key outputs #:allow-other-keys) | |
0ef7ea66 MB |
678 | (delete-file (string-append (assoc-ref outputs "out") |
679 | "/lib/libdlib.a")) | |
680 | #t))))) | |
5f0ff6a9 | 681 | (native-inputs |
3929f46c TGR |
682 | `(("pkg-config" ,pkg-config) |
683 | ;; For tests. | |
684 | ("libnsl" ,libnsl))) | |
5f0ff6a9 | 685 | (inputs |
f40841e9 | 686 | `(("giflib" ,giflib) |
4fba38db | 687 | ("lapack" ,lapack) |
5f0ff6a9 MB |
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))) | |
be6eb2f1 RW |
702 | |
703 | (define-public python-scikit-learn | |
704 | (package | |
705 | (name "python-scikit-learn") | |
d3cdb25d | 706 | (version "0.19.1") |
be6eb2f1 RW |
707 | (source |
708 | (origin | |
709 | (method url-fetch) | |
710 | (uri (string-append | |
711 | "https://github.com/scikit-learn/scikit-learn/archive/" | |
712 | version ".tar.gz")) | |
713 | (file-name (string-append name "-" version ".tar.gz")) | |
714 | (sha256 | |
715 | (base32 | |
8a6cd65a BW |
716 | "18n8775kyfwbvcjjjzda9c5sqy4737c0hrmj6qj1ps2jmlqzair9")) |
717 | (patches (search-patches | |
718 | "python-scikit-learn-fix-test-non-determinism.patch")))) | |
be6eb2f1 RW |
719 | (build-system python-build-system) |
720 | (arguments | |
721 | `(#:phases | |
722 | (modify-phases %standard-phases | |
723 | (delete 'check) | |
724 | (add-after 'install 'check | |
725 | ;; Running tests from the source directory requires | |
726 | ;; an "inplace" build with paths relative to CWD. | |
727 | ;; http://scikit-learn.org/stable/developers/advanced_installation.html#testing | |
728 | ;; Use the installed version instead. | |
729 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
730 | (add-installed-pythonpath inputs outputs) | |
731 | ;; some tests require access to "$HOME" | |
732 | (setenv "HOME" "/tmp") | |
733 | ;; Step out of the source directory just to be sure. | |
734 | (chdir "..") | |
e96ba83f | 735 | (invoke "nosetests" "-v" "sklearn")))))) |
be6eb2f1 RW |
736 | (inputs |
737 | `(("openblas" ,openblas))) | |
738 | (native-inputs | |
739 | `(("python-nose" ,python-nose) | |
740 | ("python-cython" ,python-cython))) | |
741 | (propagated-inputs | |
742 | `(("python-numpy" ,python-numpy) | |
743 | ("python-scipy" ,python-scipy))) | |
744 | (home-page "http://scikit-learn.org/") | |
745 | (synopsis "Machine Learning in Python") | |
746 | (description | |
747 | "Scikit-learn provides simple and efficient tools for data | |
748 | mining and data analysis.") | |
749 | (license license:bsd-3))) | |
750 | ||
751 | (define-public python2-scikit-learn | |
752 | (package-with-python2 python-scikit-learn)) | |
2dab4188 FT |
753 | |
754 | (define-public python-autograd | |
755 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
756 | (revision "0") | |
757 | (version (git-version "0.0.0" revision commit))) | |
758 | (package | |
759 | (name "python-autograd") | |
760 | (home-page "https://github.com/HIPS/autograd") | |
761 | (source (origin | |
762 | (method git-fetch) | |
763 | (uri (git-reference | |
764 | (url home-page) | |
765 | (commit commit))) | |
766 | (sha256 | |
767 | (base32 | |
768 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
769 | (file-name (git-file-name name version)))) | |
770 | (version version) | |
771 | (build-system python-build-system) | |
772 | (native-inputs | |
773 | `(("python-nose" ,python-nose) | |
774 | ("python-pytest" ,python-pytest))) | |
775 | (propagated-inputs | |
776 | `(("python-future" ,python-future) | |
777 | ("python-numpy" ,python-numpy))) | |
778 | (arguments | |
779 | `(#:phases (modify-phases %standard-phases | |
780 | (replace 'check | |
781 | (lambda _ | |
782 | (invoke "py.test" "-v")))))) | |
783 | (synopsis "Efficiently computes derivatives of NumPy code") | |
784 | (description "Autograd can automatically differentiate native Python and | |
785 | NumPy code. It can handle a large subset of Python's features, including loops, | |
786 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
787 | of derivatives. It supports reverse-mode differentiation | |
788 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
789 | scalar-valued functions with respect to array-valued arguments, as well as | |
790 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
791 | main intended application of Autograd is gradient-based optimization.") | |
792 | (license license:expat)))) | |
793 | ||
794 | (define-public python2-autograd | |
795 | (package-with-python2 python-autograd)) | |
112c2c01 FT |
796 | |
797 | (define-public lightgbm | |
798 | (package | |
799 | (name "lightgbm") | |
800 | (version "2.0.12") | |
801 | (source (origin | |
802 | (method url-fetch) | |
803 | (uri (string-append | |
804 | "https://github.com/Microsoft/LightGBM/archive/v" | |
805 | version ".tar.gz")) | |
806 | (sha256 | |
807 | (base32 | |
808 | "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1")) | |
809 | (file-name (string-append name "-" version ".tar.gz")))) | |
810 | (native-inputs | |
811 | `(("python-pytest" ,python-pytest) | |
812 | ("python-nose" ,python-nose))) | |
813 | (inputs | |
814 | `(("openmpi" ,openmpi))) | |
815 | (propagated-inputs | |
816 | `(("python-numpy" ,python-numpy) | |
817 | ("python-scipy" ,python-scipy))) | |
818 | (arguments | |
819 | `(#:configure-flags | |
820 | '("-DUSE_MPI=ON") | |
821 | #:phases | |
822 | (modify-phases %standard-phases | |
823 | (replace 'check | |
824 | (lambda* (#:key outputs #:allow-other-keys) | |
825 | (with-directory-excursion ,(string-append "../LightGBM-" version) | |
826 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) | |
827 | (build-system cmake-build-system) | |
828 | (home-page "https://github.com/Microsoft/LightGBM") | |
829 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
830 | (description "LightGBM is a gradient boosting framework that uses tree | |
831 | based learning algorithms. It is designed to be distributed and efficient with | |
832 | the following advantages: | |
833 | ||
834 | @itemize | |
835 | @item Faster training speed and higher efficiency | |
836 | @item Lower memory usage | |
837 | @item Better accuracy | |
838 | @item Parallel and GPU learning supported (not enabled in this package) | |
839 | @item Capable of handling large-scale data | |
840 | @end itemize\n") | |
841 | (license license:expat))) | |
a8fb82a8 FT |
842 | |
843 | (define-public vowpal-wabbit | |
844 | ;; Language bindings not included. | |
845 | (package | |
846 | (name "vowpal-wabbit") | |
847 | (version "8.5.0") | |
848 | (source (origin | |
849 | (method url-fetch) | |
850 | (uri (string-append | |
851 | "https://github.com/JohnLangford/vowpal_wabbit/archive/" | |
852 | version ".tar.gz")) | |
853 | (sha256 | |
854 | (base32 | |
855 | "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr")) | |
856 | (file-name (string-append name "-" version ".tar.gz")))) | |
857 | (inputs | |
858 | `(("boost" ,boost) | |
859 | ("zlib" ,zlib))) | |
860 | (arguments | |
861 | `(#:configure-flags | |
862 | (list (string-append "--with-boost=" | |
863 | (assoc-ref %build-inputs "boost"))))) | |
864 | (build-system gnu-build-system) | |
865 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
866 | (synopsis "Fast machine learning library for online learning") | |
867 | (description "Vowpal Wabbit is a machine learning system with techniques | |
868 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
869 | interactive learning.") | |
870 | (license license:bsd-3))) |