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