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