Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
0877b74f | 2 | ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net> |
d56d3ae7 | 3 | ;;; Copyright © 2016, 2020 Efraim Flashner <efraim@flashner.co.il> |
382550f0 | 4 | ;;; Copyright © 2016, 2017, 2020 Marius Bakke <mbakke@fastmail.com> |
be6eb2f1 | 5 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> |
5ed72097 | 6 | ;;; Copyright © 2018, 2019 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> |
d60b064d | 13 | ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr> |
6e760872 | 14 | ;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net> |
5e42d197 | 15 | ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> |
d9e9a261 | 16 | ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> |
741115b6 RW |
17 | ;;; |
18 | ;;; This file is part of GNU Guix. | |
19 | ;;; | |
20 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
21 | ;;; under the terms of the GNU General Public License as published by | |
22 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
23 | ;;; your option) any later version. | |
24 | ;;; | |
25 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
26 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 | ;;; GNU General Public License for more details. | |
29 | ;;; | |
30 | ;;; You should have received a copy of the GNU General Public License | |
31 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
32 | ||
33 | (define-module (gnu packages machine-learning) | |
34 | #:use-module ((guix licenses) #:prefix license:) | |
35 | #:use-module (guix packages) | |
36 | #:use-module (guix utils) | |
37 | #:use-module (guix download) | |
23aab4ab | 38 | #:use-module (guix svn-download) |
6e760872 | 39 | #:use-module (guix build-system asdf) |
c1670a81 | 40 | #:use-module (guix build-system cmake) |
741115b6 | 41 | #:use-module (guix build-system gnu) |
0a3063d6 | 42 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 43 | #:use-module (guix build-system python) |
8406138b | 44 | #:use-module (guix build-system r) |
a9b34762 | 45 | #:use-module (guix git-download) |
71f80f54 | 46 | #:use-module (gnu packages) |
0dfeb285 | 47 | #:use-module (gnu packages adns) |
5a14e81e | 48 | #:use-module (gnu packages algebra) |
b9445d0b | 49 | #:use-module (gnu packages audio) |
23aab4ab | 50 | #:use-module (gnu packages autotools) |
b9445d0b | 51 | #:use-module (gnu packages base) |
99260014 | 52 | #:use-module (gnu packages bash) |
0931c609 | 53 | #:use-module (gnu packages boost) |
be6eb2f1 | 54 | #:use-module (gnu packages check) |
0931c609 | 55 | #:use-module (gnu packages compression) |
9e37e537 | 56 | #:use-module (gnu packages cran) |
4fa16c9a | 57 | #:use-module (gnu packages databases) |
23aab4ab | 58 | #:use-module (gnu packages dejagnu) |
0931c609 | 59 | #:use-module (gnu packages gcc) |
b9445d0b | 60 | #:use-module (gnu packages glib) |
f1765b57 | 61 | #:use-module (gnu packages graphviz) |
b9445d0b | 62 | #:use-module (gnu packages gstreamer) |
5f0ff6a9 | 63 | #:use-module (gnu packages image) |
b9445d0b | 64 | #:use-module (gnu packages linux) |
88f06fd0 | 65 | #:use-module (gnu packages lisp-xyz) |
0931c609 | 66 | #:use-module (gnu packages maths) |
112c2c01 | 67 | #:use-module (gnu packages mpi) |
0a3063d6 | 68 | #:use-module (gnu packages ocaml) |
3929f46c | 69 | #:use-module (gnu packages onc-rpc) |
791c11d6 | 70 | #:use-module (gnu packages perl) |
c1670a81 | 71 | #:use-module (gnu packages pkg-config) |
0dfeb285 | 72 | #:use-module (gnu packages protobuf) |
0931c609 | 73 | #:use-module (gnu packages python) |
ec1224a7 | 74 | #:use-module (gnu packages python-science) |
10451f6b | 75 | #:use-module (gnu packages python-web) |
44d10b1f | 76 | #:use-module (gnu packages python-xyz) |
c61557b1 | 77 | #:use-module (gnu packages rpc) |
4fa16c9a | 78 | #:use-module (gnu packages serialization) |
f1765b57 | 79 | #:use-module (gnu packages sphinx) |
c1670a81 | 80 | #:use-module (gnu packages statistics) |
4fa16c9a | 81 | #:use-module (gnu packages sqlite) |
c1670a81 | 82 | #:use-module (gnu packages swig) |
99260014 | 83 | #:use-module (gnu packages web) |
5f0ff6a9 | 84 | #:use-module (gnu packages xml) |
39bb4937 RW |
85 | #:use-module (gnu packages xorg) |
86 | #:use-module (ice-9 match)) | |
741115b6 | 87 | |
a9b34762 MM |
88 | (define-public fann |
89 | ;; The last release is >100 commits behind, so we package from git. | |
90 | (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7")) | |
91 | (package | |
92 | (name "fann") | |
93 | (version (string-append "2.2.0-1." (string-take commit 8))) | |
94 | (source (origin | |
95 | (method git-fetch) | |
96 | (uri (git-reference | |
97 | (url "https://github.com/libfann/fann.git") | |
98 | (commit commit))) | |
99 | (file-name (string-append name "-" version "-checkout")) | |
100 | (sha256 | |
101 | (base32 | |
102 | "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x")))) | |
103 | (build-system cmake-build-system) | |
104 | (arguments | |
105 | `(#:phases | |
106 | (modify-phases %standard-phases | |
107 | (replace 'check | |
108 | (lambda* (#:key outputs #:allow-other-keys) | |
109 | (let* ((out (assoc-ref outputs "out"))) | |
110 | (with-directory-excursion (string-append (getcwd) "/tests") | |
111 | (invoke "./fann_tests")))))))) | |
112 | (home-page "http://leenissen.dk/fann/wp/") | |
113 | (synopsis "Fast Artificial Neural Network") | |
114 | (description | |
bd2bd80d MB |
115 | "FANN is a neural network library, which implements multilayer |
116 | artificial neural networks in C with support for both fully connected and | |
117 | sparsely connected networks.") | |
a9b34762 MM |
118 | (license license:lgpl2.1)))) |
119 | ||
741115b6 RW |
120 | (define-public libsvm |
121 | (package | |
122 | (name "libsvm") | |
2cffa2f2 | 123 | (version "3.23") |
741115b6 RW |
124 | (source |
125 | (origin | |
126 | (method url-fetch) | |
d1308c5e TGR |
127 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
128 | name "-" version ".tar.gz")) | |
741115b6 | 129 | (sha256 |
2cffa2f2 | 130 | (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5")))) |
741115b6 RW |
131 | (build-system gnu-build-system) |
132 | (arguments | |
2cffa2f2 | 133 | `(#:tests? #f ; no "check" target |
741115b6 RW |
134 | #:phases (modify-phases %standard-phases |
135 | (delete 'configure) | |
136 | (replace | |
d1308c5e | 137 | 'install ; no ‘install’ target |
741115b6 RW |
138 | (lambda* (#:key outputs #:allow-other-keys) |
139 | (let* ((out (assoc-ref outputs "out")) | |
140 | (bin (string-append out "/bin/"))) | |
141 | (mkdir-p bin) | |
142 | (for-each (lambda (file) | |
143 | (copy-file file (string-append bin file))) | |
144 | '("svm-train" | |
145 | "svm-predict" | |
146 | "svm-scale"))) | |
147 | #t))))) | |
62290cd4 | 148 | (home-page "https://www.csie.ntu.edu.tw/~cjlin/libsvm/") |
741115b6 RW |
149 | (synopsis "Library for Support Vector Machines") |
150 | (description | |
151 | "LIBSVM is a machine learning library for support vector | |
152 | classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and | |
153 | distribution estimation (one-class SVM). It supports multi-class | |
154 | classification.") | |
155 | (license license:bsd-3))) | |
71f80f54 RW |
156 | |
157 | (define-public python-libsvm | |
158 | (package (inherit libsvm) | |
159 | (name "python-libsvm") | |
160 | (build-system gnu-build-system) | |
161 | (arguments | |
2cffa2f2 | 162 | `(#:tests? #f ; no "check" target |
71f80f54 RW |
163 | #:make-flags '("-C" "python") |
164 | #:phases | |
165 | (modify-phases %standard-phases | |
166 | (delete 'configure) | |
167 | (replace | |
d1308c5e | 168 | 'install ; no ‘install’ target |
71f80f54 RW |
169 | (lambda* (#:key inputs outputs #:allow-other-keys) |
170 | (let ((site (string-append (assoc-ref outputs "out") | |
171 | "/lib/python" | |
172 | (string-take | |
173 | (string-take-right | |
174 | (assoc-ref inputs "python") 5) 3) | |
175 | "/site-packages/"))) | |
176 | (substitute* "python/svm.py" | |
177 | (("../libsvm.so.2") "libsvm.so.2")) | |
178 | (mkdir-p site) | |
179 | (for-each (lambda (file) | |
180 | (copy-file file (string-append site (basename file)))) | |
181 | (find-files "python" "\\.py")) | |
182 | (copy-file "libsvm.so.2" | |
183 | (string-append site "libsvm.so.2"))) | |
184 | #t))))) | |
185 | (inputs | |
186 | `(("python" ,python))) | |
187 | (synopsis "Python bindings of libSVM"))) | |
0931c609 | 188 | |
23aab4ab RW |
189 | (define-public ghmm |
190 | ;; The latest release candidate is several years and a couple of fixes have | |
191 | ;; been published since. This is why we download the sources from the SVN | |
192 | ;; repository. | |
193 | (let ((svn-revision 2341)) | |
194 | (package | |
195 | (name "ghmm") | |
196 | (version (string-append "0.9-rc3-0." (number->string svn-revision))) | |
197 | (source (origin | |
198 | (method svn-fetch) | |
199 | (uri (svn-reference | |
200 | (url "http://svn.code.sf.net/p/ghmm/code/trunk") | |
201 | (revision svn-revision))) | |
e3a69938 | 202 | (file-name (string-append name "-" version "-checkout")) |
23aab4ab RW |
203 | (sha256 |
204 | (base32 | |
205 | "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq")))) | |
206 | (build-system gnu-build-system) | |
207 | (arguments | |
ced12a7b RW |
208 | `(#:imported-modules (,@%gnu-build-system-modules |
209 | (guix build python-build-system)) | |
3cb8cb66 MB |
210 | #:modules ((guix build python-build-system) |
211 | ,@%gnu-build-system-modules) | |
ced12a7b | 212 | #:phases |
23aab4ab RW |
213 | (modify-phases %standard-phases |
214 | (add-after 'unpack 'enter-dir | |
215 | (lambda _ (chdir "ghmm") #t)) | |
ced12a7b RW |
216 | (delete 'check) |
217 | (add-after 'install 'check | |
218 | (assoc-ref %standard-phases 'check)) | |
219 | (add-before 'check 'fix-PYTHONPATH | |
220 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
9c2563a8 | 221 | (let ((python-version (python-version |
ced12a7b RW |
222 | (assoc-ref inputs "python")))) |
223 | (setenv "PYTHONPATH" | |
224 | (string-append (getenv "PYTHONPATH") | |
225 | ":" (assoc-ref outputs "out") | |
226 | "/lib/python" python-version | |
227 | "/site-packages"))) | |
23aab4ab RW |
228 | #t)) |
229 | (add-after 'enter-dir 'fix-runpath | |
230 | (lambda* (#:key outputs #:allow-other-keys) | |
231 | (substitute* "ghmmwrapper/setup.py" | |
232 | (("^(.*)extra_compile_args = \\[" line indent) | |
233 | (string-append indent | |
234 | "extra_link_args = [\"-Wl,-rpath=" | |
235 | (assoc-ref outputs "out") "/lib\"],\n" | |
236 | line | |
237 | "\"-Wl,-rpath=" | |
238 | (assoc-ref outputs "out") | |
239 | "/lib\", "))) | |
240 | #t)) | |
241 | (add-after 'enter-dir 'disable-broken-tests | |
242 | (lambda _ | |
243 | (substitute* "tests/Makefile.am" | |
244 | ;; GHMM_SILENT_TESTS is assumed to be a command. | |
245 | (("TESTS_ENVIRONMENT.*") "") | |
246 | ;; Do not build broken tests. | |
247 | (("chmm .*") "") | |
248 | (("read_fa .*") "") | |
249 | (("mcmc .*") "") | |
250 | (("label_higher_order_test.*$") | |
251 | "label_higher_order_test\n")) | |
252 | ||
253 | ;; These Python unittests are broken as there is no gato. | |
254 | ;; See https://sourceforge.net/p/ghmm/support-requests/3/ | |
255 | (substitute* "ghmmwrapper/ghmmunittests.py" | |
256 | (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)" | |
257 | line indent) | |
258 | (string-append indent | |
259 | "@unittest.skip(\"Disabled by Guix\")\n" | |
260 | line))) | |
a491856f | 261 | #t))))) |
23aab4ab RW |
262 | (inputs |
263 | `(("python" ,python-2) ; only Python 2 is supported | |
264 | ("libxml2" ,libxml2))) | |
265 | (native-inputs | |
266 | `(("pkg-config" ,pkg-config) | |
267 | ("dejagnu" ,dejagnu) | |
268 | ("swig" ,swig) | |
269 | ("autoconf" ,autoconf) | |
270 | ("automake" ,automake) | |
271 | ("libtool" ,libtool))) | |
272 | (home-page "http://ghmm.org") | |
273 | (synopsis "Hidden Markov Model library") | |
274 | (description | |
275 | "The General Hidden Markov Model library (GHMM) is a C library with | |
276 | additional Python bindings implementing a wide range of types of @dfn{Hidden | |
d1e4ad1b | 277 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
278 | training, HMM clustering, HMM mixtures.") |
279 | (license license:lgpl2.0+)))) | |
280 | ||
791c11d6 BW |
281 | (define-public mcl |
282 | (package | |
283 | (name "mcl") | |
284 | (version "14.137") | |
285 | (source (origin | |
286 | (method url-fetch) | |
287 | (uri (string-append | |
288 | "http://micans.org/mcl/src/mcl-" | |
289 | (string-replace-substring version "." "-") | |
290 | ".tar.gz")) | |
291 | (sha256 | |
292 | (base32 | |
293 | "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m")))) | |
294 | (build-system gnu-build-system) | |
295 | (arguments | |
296 | `(#:configure-flags (list "--enable-blast"))) | |
297 | (inputs | |
298 | `(("perl" ,perl))) | |
299 | (home-page "http://micans.org/mcl/") | |
300 | (synopsis "Clustering algorithm for graphs") | |
301 | (description | |
302 | "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a | |
303 | fast and scalable unsupervised cluster algorithm for graphs (also known as | |
304 | networks) based on simulation of (stochastic) flow in graphs.") | |
305 | ;; In the LICENCE file and web page it says "The software is licensed | |
306 | ;; under the GNU General Public License, version 3.", but in several of | |
307 | ;; the source code files it suggests GPL3 or later. | |
308 | ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html | |
309 | (license license:gpl3))) | |
310 | ||
0a3063d6 BW |
311 | (define-public ocaml-mcl |
312 | (package | |
313 | (name "ocaml-mcl") | |
314 | (version "12-068oasis4") | |
315 | (source | |
316 | (origin | |
fb168a31 RW |
317 | (method git-fetch) |
318 | (uri (git-reference | |
319 | (url "https://github.com/fhcrc/mcl.git") | |
320 | (commit version))) | |
321 | (file-name (git-file-name name version)) | |
0a3063d6 BW |
322 | (sha256 |
323 | (base32 | |
fb168a31 | 324 | "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p")))) |
0a3063d6 BW |
325 | (build-system ocaml-build-system) |
326 | (arguments | |
b24aaeec | 327 | `(#:phases |
0a3063d6 BW |
328 | (modify-phases %standard-phases |
329 | (add-before 'configure 'patch-paths | |
330 | (lambda _ | |
331 | (substitute* "configure" | |
b24aaeec | 332 | (("/bin/sh") (which "sh"))) |
0a3063d6 BW |
333 | (substitute* "setup.ml" |
334 | (("LDFLAGS=-fPIC") | |
b24aaeec RW |
335 | (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))) |
336 | (("-std=c89") "-std=gnu99") | |
337 | ||
338 | ;; This is a mutable string, which is no longer supported. Use | |
339 | ;; a byte buffer instead. | |
340 | (("String.make \\(String.length s\\)") | |
341 | "Bytes.make (String.length s)") | |
342 | ||
343 | ;; These two belong together. | |
344 | (("OASISString.replace_chars") | |
345 | "Bytes.to_string (OASISString.replace_chars") | |
346 | ((" s;") | |
347 | " s);")) | |
348 | (substitute* "myocamlbuild.ml" | |
349 | (("std=c89") "std=gnu99")) | |
350 | ;; Since we build with a more recent OCaml, we have to use C99 or | |
351 | ;; later. This causes problems with the old C code. | |
352 | (substitute* "src/impala/matrix.c" | |
353 | (("restrict") "restrict_")) | |
0a3063d6 | 354 | #t))))) |
b24aaeec RW |
355 | (native-inputs |
356 | `(("ocamlbuild" ,ocamlbuild))) | |
0a3063d6 BW |
357 | (home-page "https://github.com/fhcrc/mcl") |
358 | (synopsis "OCaml wrappers around MCL") | |
359 | (description | |
360 | "This package provides OCaml bindings for the MCL graph clustering | |
361 | algorithm.") | |
362 | (license license:gpl3))) | |
363 | ||
0931c609 RW |
364 | (define-public randomjungle |
365 | (package | |
366 | (name "randomjungle") | |
367 | (version "2.1.0") | |
368 | (source | |
369 | (origin | |
370 | (method url-fetch) | |
371 | (uri (string-append | |
df4c8434 BH |
372 | "https://www.imbs.uni-luebeck.de/fileadmin/files/Software" |
373 | "/randomjungle/randomjungle-" version ".tar_.gz")) | |
1e92d311 | 374 | (patches (search-patches "randomjungle-disable-static-build.patch")) |
0931c609 RW |
375 | (sha256 |
376 | (base32 | |
377 | "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w")))) | |
378 | (build-system gnu-build-system) | |
379 | (arguments | |
380 | `(#:configure-flags | |
1e92d311 MB |
381 | (list "--disable-static" |
382 | (string-append "--with-boost=" | |
0931c609 RW |
383 | (assoc-ref %build-inputs "boost"))) |
384 | #:phases | |
385 | (modify-phases %standard-phases | |
386 | (add-before | |
387 | 'configure 'set-CXXFLAGS | |
388 | (lambda _ | |
389 | (setenv "CXXFLAGS" "-fpermissive ") | |
390 | #t))))) | |
391 | (inputs | |
392 | `(("boost" ,boost) | |
393 | ("gsl" ,gsl) | |
394 | ("libxml2" ,libxml2) | |
395 | ("zlib" ,zlib))) | |
396 | (native-inputs | |
25e0037a EF |
397 | `(("gfortran" ,gfortran) |
398 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
399 | ;; Non-portable assembly instructions are used so building fails on |
400 | ;; platforms other than x86_64 or i686. | |
401 | (supported-systems '("x86_64-linux" "i686-linux")) | |
df4c8434 | 402 | (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224") |
0931c609 RW |
403 | (synopsis "Implementation of the Random Forests machine learning method") |
404 | (description | |
405 | "Random Jungle is an implementation of Random Forests. It is supposed to | |
406 | analyse high dimensional data. In genetics, it can be used for analysing big | |
407 | Genome Wide Association (GWA) data. Random Forests is a powerful machine | |
408 | learning method. Most interesting features are variable selection, missing | |
409 | value imputation, classifier creation, generalization error estimation and | |
410 | sample proximities between pairs of cases.") | |
411 | (license license:gpl3+))) | |
c1670a81 | 412 | |
7d4cab74 RW |
413 | (define-public openfst |
414 | (package | |
415 | (name "openfst") | |
5ed72097 | 416 | (version "1.7.2") |
7d4cab74 RW |
417 | (source (origin |
418 | (method url-fetch) | |
419 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
420 | "FstDownload/openfst-" version ".tar.gz")) | |
421 | (sha256 | |
422 | (base32 | |
5ed72097 | 423 | "0fqgk8195kz21is09gwzwnrg7fr9526bi9mh4apyskapz27pbhr1")))) |
7d4cab74 RW |
424 | (build-system gnu-build-system) |
425 | (home-page "http://www.openfst.org") | |
426 | (synopsis "Library for weighted finite-state transducers") | |
427 | (description "OpenFst is a library for constructing, combining, | |
428 | optimizing, and searching weighted finite-state transducers (FSTs).") | |
429 | (license license:asl2.0))) | |
430 | ||
c1670a81 RW |
431 | (define-public shogun |
432 | (package | |
433 | (name "shogun") | |
5a14e81e | 434 | (version "6.1.3") |
c1670a81 RW |
435 | (source |
436 | (origin | |
437 | (method url-fetch) | |
438 | (uri (string-append | |
439 | "ftp://shogun-toolbox.org/shogun/releases/" | |
440 | (version-major+minor version) | |
441 | "/sources/shogun-" version ".tar.bz2")) | |
442 | (sha256 | |
443 | (base32 | |
5a14e81e | 444 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
445 | (modules '((guix build utils) |
446 | (ice-9 rdelim))) | |
447 | (snippet | |
448 | '(begin | |
449 | ;; Remove non-free sources and files referencing them | |
450 | (for-each delete-file | |
451 | (find-files "src/shogun/classifier/svm/" | |
452 | "SVMLight\\.(cpp|h)")) | |
453 | (for-each delete-file | |
454 | (find-files "examples/undocumented/libshogun/" | |
455 | (string-append | |
456 | "(classifier_.*svmlight.*|" | |
457 | "evaluation_cross_validation_locked_comparison).cpp"))) | |
458 | ;; Remove non-free functions. | |
459 | (define (delete-ifdefs file) | |
460 | (with-atomic-file-replacement file | |
461 | (lambda (in out) | |
462 | (let loop ((line (read-line in 'concat)) | |
463 | (skipping? #f)) | |
464 | (if (eof-object? line) | |
465 | #t | |
466 | (let ((skip-next? | |
467 | (or (and skipping? | |
468 | (not (string-prefix? | |
469 | "#endif //USE_SVMLIGHT" line))) | |
470 | (string-prefix? | |
471 | "#ifdef USE_SVMLIGHT" line)))) | |
472 | (when (or (not skipping?) | |
473 | (and skipping? (not skip-next?))) | |
474 | (display line out)) | |
475 | (loop (read-line in 'concat) skip-next?))))))) | |
5a14e81e KK |
476 | (for-each delete-ifdefs |
477 | (append | |
478 | (find-files "src/shogun/classifier/mkl" | |
479 | "^MKLClassification\\.cpp") | |
480 | (find-files "src/shogun/classifier/svm" | |
481 | "^SVMLightOneClass\\.(cpp|h)") | |
482 | (find-files "src/shogun/multiclass" | |
483 | "^ScatterSVM\\.(cpp|h)") | |
484 | (find-files "src/shogun/kernel/" | |
485 | "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)") | |
486 | (find-files "src/shogun/regression/svr" | |
487 | "^(MKLRegression|SVRLight)\\.(cpp|h)") | |
488 | (find-files "src/shogun/transfer/domain_adaptation" | |
c0d7c124 | 489 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 490 | #t)))) |
c1670a81 RW |
491 | (build-system cmake-build-system) |
492 | (arguments | |
493 | '(#:tests? #f ;no check target | |
494 | #:phases | |
dc1d3cde KK |
495 | (modify-phases %standard-phases |
496 | (add-after 'unpack 'delete-broken-symlinks | |
497 | (lambda _ | |
498 | (for-each delete-file '("applications/arts/data" | |
499 | "applications/asp/data" | |
500 | "applications/easysvm/data" | |
501 | "applications/msplicer/data" | |
502 | "applications/ocr/data" | |
5a14e81e KK |
503 | "examples/meta/data" |
504 | "examples/undocumented/data")) | |
dc1d3cde KK |
505 | #t)) |
506 | (add-after 'unpack 'change-R-target-path | |
507 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
508 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
509 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
510 | (("\\$\\{R_COMPONENT_LIB_PATH\\}") |
511 | (string-append (assoc-ref outputs "out") | |
512 | "/lib/R/library/"))) | |
513 | #t)) | |
514 | (add-after 'unpack 'fix-octave-modules | |
515 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e | 516 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 517 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
518 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
519 | ;; change target directory | |
dc1d3cde KK |
520 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
521 | (string-append (assoc-ref outputs "out") | |
522 | "/share/octave/packages"))) | |
5a14e81e KK |
523 | (substitute* '("src/interfaces/octave/swig_typemaps.i" |
524 | "src/interfaces/octave/sg_print_functions.cpp") | |
525 | ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave. | |
526 | (("octave/config\\.h") "octave/octave-config.h") | |
527 | (("octave/oct-obj.h") "octave/ovl.h")) | |
dc1d3cde | 528 | #t)) |
5a14e81e KK |
529 | (add-after 'unpack 'move-rxcpp |
530 | (lambda* (#:key inputs #:allow-other-keys) | |
531 | (let ((rxcpp-dir "shogun/third-party/rxcpp")) | |
532 | (mkdir-p rxcpp-dir) | |
533 | (install-file (assoc-ref inputs "rxcpp") rxcpp-dir) | |
534 | #t))) | |
dc1d3cde | 535 | (add-before 'build 'set-HOME |
c1670a81 | 536 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 537 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
538 | #:configure-flags |
539 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
540 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
541 | "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags |
542 | ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas | |
543 | ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray | |
544 | ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist | |
545 | ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file | |
546 | "-DINTERFACE_OCTAVE=ON" | |
547 | "-DINTERFACE_PYTHON=ON" | |
548 | "-DINTERFACE_R=ON"))) | |
c1670a81 RW |
549 | (inputs |
550 | `(("python" ,python) | |
551 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 552 | ("r-minimal" ,r-minimal) |
5537603f | 553 | ("octave" ,octave-cli) |
c1670a81 | 554 | ("swig" ,swig) |
5a14e81e | 555 | ("eigen" ,eigen) |
c1670a81 RW |
556 | ("hdf5" ,hdf5) |
557 | ("atlas" ,atlas) | |
558 | ("arpack" ,arpack-ng) | |
559 | ("lapack" ,lapack) | |
560 | ("glpk" ,glpk) | |
561 | ("libxml2" ,libxml2) | |
562 | ("lzo" ,lzo) | |
563 | ("zlib" ,zlib))) | |
564 | (native-inputs | |
5a14e81e KK |
565 | `(("pkg-config" ,pkg-config) |
566 | ("rxcpp" ,rxcpp))) | |
6b5b656f RW |
567 | ;; Non-portable SSE instructions are used so building fails on platforms |
568 | ;; other than x86_64. | |
569 | (supported-systems '("x86_64-linux")) | |
df10a64e | 570 | (home-page "https://shogun-toolbox.org/") |
c1670a81 RW |
571 | (synopsis "Machine learning toolbox") |
572 | (description | |
573 | "The Shogun Machine learning toolbox provides a wide range of unified and | |
cc24c4cb VC |
574 | efficient Machine Learning (ML) methods. The toolbox seamlessly |
575 | combines multiple data representations, algorithm classes, and general purpose | |
c1670a81 RW |
576 | tools. This enables both rapid prototyping of data pipelines and extensibility |
577 | in terms of new algorithms.") | |
578 | (license license:gpl3+))) | |
8406138b | 579 | |
3a354e10 KK |
580 | (define-public rxcpp |
581 | (package | |
582 | (name "rxcpp") | |
e91a0bff | 583 | (version "4.1.0") |
3a354e10 KK |
584 | (source |
585 | (origin | |
5daafe0b TGR |
586 | (method git-fetch) |
587 | (uri (git-reference | |
588 | (url "https://github.com/ReactiveX/RxCpp.git") | |
589 | (commit (string-append "v" version)))) | |
3a354e10 | 590 | (sha256 |
5daafe0b TGR |
591 | (base32 "1rdpa3jlc181jd08nk437aar085h28i45s6nzrv65apb3xyyz0ij")) |
592 | (file-name (git-file-name name version)))) | |
3a354e10 KK |
593 | (build-system cmake-build-system) |
594 | (arguments | |
595 | `(#:phases | |
596 | (modify-phases %standard-phases | |
597 | (add-after 'unpack 'remove-werror | |
598 | (lambda _ | |
599 | (substitute* (find-files ".") | |
600 | (("-Werror") "")) | |
601 | #t)) | |
602 | (replace 'check | |
603 | (lambda _ | |
604 | (invoke "ctest")))))) | |
605 | (native-inputs | |
606 | `(("catch" ,catch-framework))) | |
607 | (home-page "http://reactivex.io/") | |
608 | (synopsis "Reactive Extensions for C++") | |
609 | (description | |
610 | "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for | |
611 | values-distributed-in-time. ReactiveX is a library for composing asynchronous | |
612 | and event-based programs by using observable sequences. | |
613 | ||
614 | It extends the observer pattern to support sequences of data and/or events and | |
615 | adds operators that allow you to compose sequences together declaratively while | |
616 | abstracting away concerns about things like low-level threading, | |
617 | synchronization, thread-safety, concurrent data structures, and non-blocking | |
618 | I/O.") | |
619 | (license license:asl2.0))) | |
620 | ||
8406138b RW |
621 | (define-public r-adaptivesparsity |
622 | (package | |
623 | (name "r-adaptivesparsity") | |
c0608f81 | 624 | (version "1.6") |
8406138b RW |
625 | (source (origin |
626 | (method url-fetch) | |
627 | (uri (cran-uri "AdaptiveSparsity" version)) | |
628 | (sha256 | |
629 | (base32 | |
c0608f81 | 630 | "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91")))) |
8406138b RW |
631 | (properties |
632 | `((upstream-name . "AdaptiveSparsity"))) | |
633 | (build-system r-build-system) | |
634 | (arguments | |
635 | `(#:phases | |
636 | (modify-phases %standard-phases | |
637 | (add-after 'unpack 'link-against-armadillo | |
638 | (lambda _ | |
639 | (substitute* "src/Makevars" | |
640 | (("PKG_LIBS=" prefix) | |
641 | (string-append prefix "-larmadillo")))))))) | |
642 | (propagated-inputs | |
c0608f81 RW |
643 | `(("r-mass" ,r-mass) |
644 | ("r-matrix" ,r-matrix) | |
645 | ("r-rcpp" ,r-rcpp) | |
8406138b | 646 | ("r-rcpparmadillo" ,r-rcpparmadillo))) |
60e36bff LC |
647 | (inputs |
648 | `(("armadillo" ,armadillo))) | |
e9960d8c | 649 | (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity") |
8406138b RW |
650 | (synopsis "Adaptive sparsity models") |
651 | (description | |
652 | "This package implements the Figueiredo machine learning algorithm for | |
653 | adaptive sparsity and the Wong algorithm for adaptively sparse gaussian | |
654 | geometric models.") | |
655 | (license license:lgpl3+))) | |
e4785eb8 | 656 | |
39bb4937 RW |
657 | (define-public gemmlowp-for-tensorflow |
658 | ;; The commit hash is taken from "tensorflow/workspace.bzl". | |
659 | (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98") | |
660 | (revision "2")) | |
661 | (package | |
662 | (name "gemmlowp") | |
663 | (version (git-version "0" revision commit)) | |
664 | (source (origin | |
665 | (method url-fetch) | |
666 | (uri (string-append "https://mirror.bazel.build/" | |
667 | "github.com/google/gemmlowp/archive/" | |
668 | commit ".zip")) | |
669 | (file-name (string-append "gemmlowp-" version ".zip")) | |
670 | (sha256 | |
671 | (base32 | |
672 | "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq")))) | |
673 | (build-system cmake-build-system) | |
674 | (arguments | |
675 | `(#:configure-flags | |
676 | (list ,@(match (%current-system) | |
677 | ((or "x86_64-linux" "i686-linux") | |
a32e3b90 | 678 | '("-DCMAKE_CXX_FLAGS=-msse2")) |
39bb4937 RW |
679 | (_ '()))) |
680 | #:phases | |
681 | (modify-phases %standard-phases | |
682 | ;; This directory contains the CMakeLists.txt. | |
683 | (add-after 'unpack 'chdir | |
684 | (lambda _ (chdir "contrib") #t)) | |
685 | ;; There is no install target | |
686 | (replace 'install | |
687 | (lambda* (#:key outputs #:allow-other-keys) | |
688 | (let* ((out (assoc-ref outputs "out")) | |
689 | (lib (string-append out "/lib/")) | |
690 | (inc (string-append out "/include/"))) | |
691 | (install-file "../build/libeight_bit_int_gemm.so" lib) | |
692 | (for-each (lambda (dir) | |
693 | (let ((target (string-append inc "/" dir))) | |
694 | (mkdir-p target) | |
695 | (for-each (lambda (h) | |
696 | (install-file h target)) | |
697 | (find-files (string-append "../" dir) | |
698 | "\\.h$")))) | |
699 | '("meta" "profiling" "public" "fixedpoint" | |
700 | "eight_bit_int_gemm" "internal")) | |
701 | #t)))))) | |
702 | (native-inputs | |
703 | `(("unzip" ,unzip))) | |
704 | (home-page "https://github.com/google/gemmlowp") | |
705 | (synopsis "Small self-contained low-precision GEMM library") | |
706 | (description | |
707 | "This is a small self-contained low-precision @dfn{general matrix | |
708 | multiplication} (GEMM) library. It is not a full linear algebra library. | |
709 | Low-precision means that the input and output matrix entries are integers on | |
710 | at most 8 bits. To avoid overflow, results are internally accumulated on more | |
711 | than 8 bits, and at the end only some significant 8 bits are kept.") | |
712 | (license license:asl2.0)))) | |
f05c7eb4 | 713 | |
5f0ff6a9 MB |
714 | (define-public dlib |
715 | (package | |
716 | (name "dlib") | |
abe97a58 | 717 | (version "19.7") |
5f0ff6a9 MB |
718 | (source (origin |
719 | (method url-fetch) | |
720 | (uri (string-append | |
721 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
722 | (sha256 | |
723 | (base32 | |
abe97a58 | 724 | "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2")) |
5f0ff6a9 MB |
725 | (modules '((guix build utils))) |
726 | (snippet | |
727 | '(begin | |
728 | ;; Delete ~13MB of bundled dependencies. | |
729 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
730 | (delete-file-recursively "docs/dlib/external") |
731 | #t)))) | |
5f0ff6a9 MB |
732 | (build-system cmake-build-system) |
733 | (arguments | |
677bc34d | 734 | `(#:phases |
5f0ff6a9 MB |
735 | (modify-phases %standard-phases |
736 | (add-after 'unpack 'disable-asserts | |
737 | (lambda _ | |
738 | ;; config.h recommends explicitly enabling or disabling asserts | |
739 | ;; when building as a shared library. By default neither is set. | |
740 | (substitute* "dlib/config.h" | |
741 | (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS")) | |
742 | #t)) | |
4fba38db MB |
743 | (add-after 'disable-asserts 'disable-failing-tests |
744 | (lambda _ | |
745 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 746 | ;; Others are flaky on some platforms. |
4fba38db MB |
747 | (let* ((system ,(or (%current-target-system) |
748 | (%current-system))) | |
749 | (disabled-tests (cond | |
750 | ((string-prefix? "mips64" system) | |
751 | '("object_detector" ; timeout | |
752 | "data_io")) | |
753 | ((string-prefix? "armhf" system) | |
a343c461 | 754 | '("learning_to_track")) |
4fba38db | 755 | ((string-prefix? "i686" system) |
0ef7ea66 | 756 | '("optimization")) |
4fba38db | 757 | (else '())))) |
4fba38db MB |
758 | (for-each |
759 | (lambda (test) | |
760 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
761 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
762 | disabled-tests) | |
763 | #t))) | |
5f0ff6a9 MB |
764 | (replace 'check |
765 | (lambda _ | |
766 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 767 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 768 | (with-directory-excursion test-dir |
8448e6bf TGR |
769 | (invoke "make" "-j" (number->string (parallel-job-count))) |
770 | (invoke "./dtest" "--runall")) | |
771 | #t))) | |
5f0ff6a9 MB |
772 | (add-after 'install 'delete-static-library |
773 | (lambda* (#:key outputs #:allow-other-keys) | |
0ef7ea66 MB |
774 | (delete-file (string-append (assoc-ref outputs "out") |
775 | "/lib/libdlib.a")) | |
776 | #t))))) | |
5f0ff6a9 | 777 | (native-inputs |
3929f46c TGR |
778 | `(("pkg-config" ,pkg-config) |
779 | ;; For tests. | |
780 | ("libnsl" ,libnsl))) | |
5f0ff6a9 | 781 | (inputs |
f40841e9 | 782 | `(("giflib" ,giflib) |
4fba38db | 783 | ("lapack" ,lapack) |
5f0ff6a9 MB |
784 | ("libjpeg" ,libjpeg) |
785 | ("libpng" ,libpng) | |
786 | ("libx11" ,libx11) | |
787 | ("openblas" ,openblas) | |
788 | ("zlib" ,zlib))) | |
789 | (synopsis | |
790 | "Toolkit for making machine learning and data analysis applications in C++") | |
791 | (description | |
792 | "Dlib is a modern C++ toolkit containing machine learning algorithms and | |
793 | tools. It is used in both industry and academia in a wide range of domains | |
794 | including robotics, embedded devices, mobile phones, and large high performance | |
795 | computing environments.") | |
796 | (home-page "http://dlib.net") | |
797 | (license license:boost1.0))) | |
be6eb2f1 RW |
798 | |
799 | (define-public python-scikit-learn | |
800 | (package | |
801 | (name "python-scikit-learn") | |
83a483aa | 802 | (version "0.22.1") |
be6eb2f1 RW |
803 | (source |
804 | (origin | |
4a89bdd1 RW |
805 | (method git-fetch) |
806 | (uri (git-reference | |
807 | (url "https://github.com/scikit-learn/scikit-learn.git") | |
808 | (commit version))) | |
809 | (file-name (git-file-name name version)) | |
be6eb2f1 RW |
810 | (sha256 |
811 | (base32 | |
83a483aa | 812 | "1xqxv210gsmjw094vc5ghq2y9lmm74qkk22pq6flcjzj51b86jxf")))) |
be6eb2f1 RW |
813 | (build-system python-build-system) |
814 | (arguments | |
815 | `(#:phases | |
816 | (modify-phases %standard-phases | |
4a89bdd1 RW |
817 | (add-after 'build 'build-ext |
818 | (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t)) | |
819 | (replace 'check | |
820 | (lambda _ | |
821 | ;; Restrict OpenBLAS threads to prevent segfaults while testing! | |
822 | (setenv "OPENBLAS_NUM_THREADS" "1") | |
7ff3f3d2 MB |
823 | |
824 | ;; Some tests require write access to $HOME. | |
825 | (setenv "HOME" "/tmp") | |
826 | ||
827 | (invoke "pytest" "sklearn" "-m" "not network"))) | |
71804546 BL |
828 | (add-before 'reset-gzip-timestamps 'make-files-writable |
829 | (lambda* (#:key outputs #:allow-other-keys) | |
830 | ;; Make sure .gz files are writable so that the | |
831 | ;; 'reset-gzip-timestamps' phase can do its work. | |
832 | (let ((out (assoc-ref outputs "out"))) | |
833 | (for-each make-file-writable | |
834 | (find-files out "\\.gz$")) | |
835 | #t)))))) | |
be6eb2f1 RW |
836 | (inputs |
837 | `(("openblas" ,openblas))) | |
838 | (native-inputs | |
d9e9a261 | 839 | `(("python-pytest" ,python-pytest) |
4a89bdd1 | 840 | ("python-pandas" ,python-pandas) ;for tests |
be6eb2f1 RW |
841 | ("python-cython" ,python-cython))) |
842 | (propagated-inputs | |
843 | `(("python-numpy" ,python-numpy) | |
d9e9a261 KH |
844 | ("python-scipy" ,python-scipy) |
845 | ("python-joblib" ,python-joblib))) | |
e51b34bb | 846 | (home-page "https://scikit-learn.org/") |
be6eb2f1 RW |
847 | (synopsis "Machine Learning in Python") |
848 | (description | |
4a89bdd1 RW |
849 | "Scikit-learn provides simple and efficient tools for data mining and |
850 | data analysis.") | |
382550f0 | 851 | (properties `((python2-variant . ,(delay python2-scikit-learn)))) |
be6eb2f1 RW |
852 | (license license:bsd-3))) |
853 | ||
382550f0 MB |
854 | ;; scikit-learn 0.22 and later only supports Python 3, so we stick with |
855 | ;; an older version here. | |
be6eb2f1 | 856 | (define-public python2-scikit-learn |
382550f0 MB |
857 | (let ((base (package-with-python2 (strip-python2-variant python-scikit-learn)))) |
858 | (package | |
859 | (inherit base) | |
860 | (version "0.20.4") | |
861 | (source (origin | |
862 | (method git-fetch) | |
863 | (uri (git-reference | |
864 | (url "https://github.com/scikit-learn/scikit-learn.git") | |
865 | (commit version))) | |
866 | (file-name (git-file-name "python-scikit-learn" version)) | |
867 | (sha256 | |
868 | (base32 | |
869 | "08zbzi8yx5wdlxfx9jap61vg1malc9ajf576w7a0liv6jvvrxlpj"))))))) | |
2dab4188 | 870 | |
639ae3f2 RJ |
871 | (define-public python-scikit-rebate |
872 | (package | |
873 | (name "python-scikit-rebate") | |
874 | (version "0.6") | |
875 | (source (origin | |
876 | (method url-fetch) | |
877 | (uri (pypi-uri "skrebate" version)) | |
878 | (sha256 | |
879 | (base32 | |
880 | "1h7qs9gjxpzqabzhb8rmpv3jpmi5iq41kqdibg48299h94iikiw7")))) | |
881 | (build-system python-build-system) | |
882 | ;; Pandas is only needed to run the tests. | |
883 | (native-inputs | |
884 | `(("python-pandas" ,python-pandas))) | |
885 | (propagated-inputs | |
886 | `(("python-numpy" ,python-numpy) | |
887 | ("python-scipy" ,python-scipy) | |
888 | ("python-scikit-learn" ,python-scikit-learn) | |
889 | ("python-joblib" ,python-joblib))) | |
890 | (home-page "https://epistasislab.github.io/scikit-rebate/") | |
891 | (synopsis "Relief-based feature selection algorithms for Python") | |
892 | (description "Scikit-rebate is a scikit-learn-compatible Python | |
893 | implementation of ReBATE, a suite of Relief-based feature selection algorithms | |
894 | for Machine Learning. These algorithms excel at identifying features that are | |
895 | predictive of the outcome in supervised learning problems, and are especially | |
896 | good at identifying feature interactions that are normally overlooked by | |
897 | standard feature selection algorithms.") | |
898 | (license license:expat))) | |
899 | ||
2dab4188 FT |
900 | (define-public python-autograd |
901 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
902 | (revision "0") | |
903 | (version (git-version "0.0.0" revision commit))) | |
904 | (package | |
905 | (name "python-autograd") | |
906 | (home-page "https://github.com/HIPS/autograd") | |
907 | (source (origin | |
908 | (method git-fetch) | |
909 | (uri (git-reference | |
910 | (url home-page) | |
911 | (commit commit))) | |
912 | (sha256 | |
913 | (base32 | |
914 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
915 | (file-name (git-file-name name version)))) | |
916 | (version version) | |
917 | (build-system python-build-system) | |
918 | (native-inputs | |
919 | `(("python-nose" ,python-nose) | |
920 | ("python-pytest" ,python-pytest))) | |
921 | (propagated-inputs | |
922 | `(("python-future" ,python-future) | |
923 | ("python-numpy" ,python-numpy))) | |
924 | (arguments | |
925 | `(#:phases (modify-phases %standard-phases | |
926 | (replace 'check | |
927 | (lambda _ | |
928 | (invoke "py.test" "-v")))))) | |
929 | (synopsis "Efficiently computes derivatives of NumPy code") | |
930 | (description "Autograd can automatically differentiate native Python and | |
931 | NumPy code. It can handle a large subset of Python's features, including loops, | |
932 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
933 | of derivatives. It supports reverse-mode differentiation | |
934 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
935 | scalar-valued functions with respect to array-valued arguments, as well as | |
936 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
937 | main intended application of Autograd is gradient-based optimization.") | |
938 | (license license:expat)))) | |
939 | ||
940 | (define-public python2-autograd | |
941 | (package-with-python2 python-autograd)) | |
112c2c01 FT |
942 | |
943 | (define-public lightgbm | |
944 | (package | |
945 | (name "lightgbm") | |
946 | (version "2.0.12") | |
947 | (source (origin | |
948 | (method url-fetch) | |
949 | (uri (string-append | |
950 | "https://github.com/Microsoft/LightGBM/archive/v" | |
951 | version ".tar.gz")) | |
952 | (sha256 | |
953 | (base32 | |
954 | "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1")) | |
955 | (file-name (string-append name "-" version ".tar.gz")))) | |
956 | (native-inputs | |
957 | `(("python-pytest" ,python-pytest) | |
958 | ("python-nose" ,python-nose))) | |
959 | (inputs | |
960 | `(("openmpi" ,openmpi))) | |
961 | (propagated-inputs | |
962 | `(("python-numpy" ,python-numpy) | |
963 | ("python-scipy" ,python-scipy))) | |
964 | (arguments | |
965 | `(#:configure-flags | |
966 | '("-DUSE_MPI=ON") | |
967 | #:phases | |
968 | (modify-phases %standard-phases | |
969 | (replace 'check | |
970 | (lambda* (#:key outputs #:allow-other-keys) | |
971 | (with-directory-excursion ,(string-append "../LightGBM-" version) | |
972 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) | |
973 | (build-system cmake-build-system) | |
974 | (home-page "https://github.com/Microsoft/LightGBM") | |
975 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
976 | (description "LightGBM is a gradient boosting framework that uses tree | |
977 | based learning algorithms. It is designed to be distributed and efficient with | |
978 | the following advantages: | |
979 | ||
980 | @itemize | |
981 | @item Faster training speed and higher efficiency | |
982 | @item Lower memory usage | |
983 | @item Better accuracy | |
984 | @item Parallel and GPU learning supported (not enabled in this package) | |
985 | @item Capable of handling large-scale data | |
986 | @end itemize\n") | |
987 | (license license:expat))) | |
a8fb82a8 FT |
988 | |
989 | (define-public vowpal-wabbit | |
990 | ;; Language bindings not included. | |
991 | (package | |
992 | (name "vowpal-wabbit") | |
993 | (version "8.5.0") | |
994 | (source (origin | |
4eb40497 EF |
995 | (method git-fetch) |
996 | (uri (git-reference | |
997 | (url "https://github.com/JohnLangford/vowpal_wabbit") | |
998 | (commit version))) | |
a8fb82a8 FT |
999 | (sha256 |
1000 | (base32 | |
4eb40497 EF |
1001 | "04bwzk6ifgnz3fmzid8b7avxf9n5pnx9xcjm61nkjng1vv0bpj8x")) |
1002 | (file-name (git-file-name name version)))) | |
a8fb82a8 FT |
1003 | (inputs |
1004 | `(("boost" ,boost) | |
1005 | ("zlib" ,zlib))) | |
1006 | (arguments | |
1007 | `(#:configure-flags | |
1008 | (list (string-append "--with-boost=" | |
4eb40497 EF |
1009 | (assoc-ref %build-inputs "boost"))) |
1010 | #:phases | |
1011 | (modify-phases %standard-phases | |
1012 | (add-after 'unpack 'make-files-writable | |
1013 | (lambda _ | |
1014 | (for-each make-file-writable (find-files "." ".*")) #t))))) | |
a8fb82a8 FT |
1015 | (build-system gnu-build-system) |
1016 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
1017 | (synopsis "Fast machine learning library for online learning") | |
1018 | (description "Vowpal Wabbit is a machine learning system with techniques | |
1019 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
1020 | interactive learning.") | |
1021 | (license license:bsd-3))) | |
915c6bf6 LC |
1022 | |
1023 | (define-public python2-fastlmm | |
1024 | (package | |
1025 | (name "python2-fastlmm") | |
1026 | (version "0.2.21") | |
1027 | (source | |
1028 | (origin | |
1029 | (method url-fetch) | |
1030 | (uri (pypi-uri "fastlmm" version ".zip")) | |
1031 | (sha256 | |
1032 | (base32 | |
1033 | "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m")))) | |
1034 | (build-system python-build-system) | |
1035 | (arguments | |
237ee6f2 RW |
1036 | `(#:tests? #f ; some test files are missing |
1037 | #:python ,python-2)) ; only Python 2.7 is supported | |
915c6bf6 LC |
1038 | (propagated-inputs |
1039 | `(("python2-numpy" ,python2-numpy) | |
1040 | ("python2-scipy" ,python2-scipy) | |
1041 | ("python2-matplotlib" ,python2-matplotlib) | |
1042 | ("python2-pandas" ,python2-pandas) | |
1043 | ("python2-scikit-learn" ,python2-scikit-learn) | |
1044 | ("python2-pysnptools" ,python2-pysnptools))) | |
1045 | (native-inputs | |
1046 | `(("unzip" ,unzip) | |
1047 | ("python2-cython" ,python2-cython) | |
1048 | ("python2-mock" ,python2-mock) | |
1049 | ("python2-nose" ,python2-nose))) | |
1050 | (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/") | |
1051 | (synopsis "Perform genome-wide association studies on large data sets") | |
1052 | (description | |
1053 | "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed | |
1054 | Models, is a program for performing both single-SNP and SNP-set genome-wide | |
1055 | association studies (GWAS) on extremely large data sets.") | |
1056 | (license license:asl2.0))) | |
b9445d0b RW |
1057 | |
1058 | ;; There have been no proper releases yet. | |
1059 | (define-public kaldi | |
0877b74f RW |
1060 | (let ((commit "d4791c0f3fc1a09c042dac365e120899ee2ad21e") |
1061 | (revision "2")) | |
b9445d0b RW |
1062 | (package |
1063 | (name "kaldi") | |
1064 | (version (git-version "0" revision commit)) | |
1065 | (source (origin | |
1066 | (method git-fetch) | |
1067 | (uri (git-reference | |
1068 | (url "https://github.com/kaldi-asr/kaldi.git") | |
1069 | (commit commit))) | |
1070 | (file-name (git-file-name name version)) | |
1071 | (sha256 | |
1072 | (base32 | |
0877b74f | 1073 | "07k80my6f19mhrkwbzhjsnpf9871wmrwkl0ym468i830w67qyjrz")))) |
b9445d0b RW |
1074 | (build-system gnu-build-system) |
1075 | (arguments | |
1076 | `(#:test-target "test" | |
1077 | #:phases | |
1078 | (modify-phases %standard-phases | |
1079 | (add-after 'unpack 'chdir | |
1080 | (lambda _ (chdir "src") #t)) | |
1081 | (replace 'configure | |
1082 | (lambda* (#:key build system inputs outputs #:allow-other-keys) | |
1083 | (when (not (or (string-prefix? "x86_64" system) | |
1084 | (string-prefix? "i686" system))) | |
1085 | (substitute* "makefiles/linux_openblas.mk" | |
1086 | (("-msse -msse2") ""))) | |
1087 | (substitute* "makefiles/default_rules.mk" | |
1088 | (("/bin/bash") (which "bash"))) | |
1089 | (substitute* "Makefile" | |
1090 | (("ext_depend: check_portaudio") | |
1091 | "ext_depend:")) | |
1092 | (substitute* '("online/Makefile" | |
1093 | "onlinebin/Makefile" | |
1094 | "gst-plugin/Makefile") | |
1095 | (("../../tools/portaudio/install") | |
1096 | (assoc-ref inputs "portaudio"))) | |
1097 | ||
1098 | ;; This `configure' script doesn't support variables passed as | |
1099 | ;; arguments, nor does it support "prefix". | |
1100 | (let ((out (assoc-ref outputs "out")) | |
1101 | (openblas (assoc-ref inputs "openblas")) | |
1102 | (openfst (assoc-ref inputs "openfst"))) | |
1103 | (substitute* "configure" | |
1104 | (("check_for_slow_expf;") "") | |
1105 | ;; This affects the RPATH and also serves as the installation | |
1106 | ;; directory. | |
1107 | (("KALDILIBDIR=`pwd`/lib") | |
1108 | (string-append "KALDILIBDIR=" out "/lib"))) | |
1109 | (mkdir-p out) ; must exist | |
1110 | (setenv "CONFIG_SHELL" (which "bash")) | |
1111 | (setenv "OPENFST_VER" ,(package-version openfst)) | |
1112 | (invoke "./configure" | |
1113 | "--use-cuda=no" | |
1114 | "--shared" | |
1115 | (string-append "--openblas-root=" openblas) | |
1116 | (string-append "--fst-root=" openfst))))) | |
1117 | (add-after 'build 'build-ext-and-gstreamer-plugin | |
1118 | (lambda _ | |
1119 | (invoke "make" "-C" "online" "depend") | |
1120 | (invoke "make" "-C" "online") | |
1121 | (invoke "make" "-C" "onlinebin" "depend") | |
1122 | (invoke "make" "-C" "onlinebin") | |
1123 | (invoke "make" "-C" "gst-plugin" "depend") | |
1124 | (invoke "make" "-C" "gst-plugin") | |
1125 | #t)) | |
1126 | ;; TODO: also install the executables. | |
1127 | (replace 'install | |
1128 | (lambda* (#:key outputs #:allow-other-keys) | |
1129 | (let* ((out (assoc-ref outputs "out")) | |
1fdd20c7 | 1130 | (inc (string-append out "/include")) |
b9445d0b RW |
1131 | (lib (string-append out "/lib"))) |
1132 | (mkdir-p lib) | |
1fdd20c7 RW |
1133 | ;; The build phase installed symlinks to the actual |
1134 | ;; libraries. Install the actual targets. | |
1135 | (for-each (lambda (file) | |
1136 | (let ((target (readlink file))) | |
1137 | (delete-file file) | |
1138 | (install-file target lib))) | |
1139 | (find-files lib "\\.so")) | |
1140 | ;; Install headers | |
1141 | (for-each (lambda (file) | |
1142 | (let ((target-dir (string-append inc "/" (dirname file)))) | |
1143 | (install-file file target-dir))) | |
1144 | (find-files "." "\\.h")) | |
1145 | (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" | |
1146 | (string-append lib "/gstreamer-1.0")) | |
b9445d0b RW |
1147 | #t)))))) |
1148 | (inputs | |
1149 | `(("alsa-lib" ,alsa-lib) | |
1150 | ("gfortran" ,gfortran "lib") | |
1151 | ("glib" ,glib) | |
1152 | ("gstreamer" ,gstreamer) | |
1153 | ("jack" ,jack-1) | |
1154 | ("openblas" ,openblas) | |
1155 | ("openfst" ,openfst) | |
1156 | ("portaudio" ,portaudio) | |
1157 | ("python" ,python))) | |
1158 | (native-inputs | |
1159 | `(("glib" ,glib "bin") ; glib-genmarshal | |
1160 | ("grep" ,grep) | |
1161 | ("sed" ,sed) | |
1162 | ("pkg-config" ,pkg-config) | |
1163 | ("which" ,which))) | |
1164 | (home-page "https://kaldi-asr.org/") | |
1165 | (synopsis "Speech recognition toolkit") | |
1166 | (description "Kaldi is an extensible toolkit for speech recognition | |
1167 | written in C++.") | |
1168 | (license license:asl2.0)))) | |
99260014 RW |
1169 | |
1170 | (define-public gst-kaldi-nnet2-online | |
b3cf5f86 RW |
1171 | (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad") |
1172 | (revision "2")) | |
99260014 RW |
1173 | (package |
1174 | (name "gst-kaldi-nnet2-online") | |
1175 | (version (git-version "0" revision commit)) | |
1176 | (source (origin | |
1177 | (method git-fetch) | |
1178 | (uri (git-reference | |
1179 | (url "https://github.com/alumae/gst-kaldi-nnet2-online.git") | |
1180 | (commit commit))) | |
1181 | (file-name (git-file-name name version)) | |
1182 | (sha256 | |
1183 | (base32 | |
b3cf5f86 | 1184 | "1i6ffwiavxx07ri0lxix6s8q0r31x7i4xxvhys5jxkixf5q34w8g")))) |
99260014 RW |
1185 | (build-system gnu-build-system) |
1186 | (arguments | |
1187 | `(#:tests? #f ; there are none | |
1188 | #:make-flags | |
1189 | (list (string-append "SHELL=" | |
1190 | (assoc-ref %build-inputs "bash") "/bin/bash") | |
1191 | (string-append "KALDI_ROOT=" | |
1192 | (assoc-ref %build-inputs "kaldi-src")) | |
1193 | (string-append "KALDILIBDIR=" | |
1194 | (assoc-ref %build-inputs "kaldi") "/lib") | |
1195 | "KALDI_FLAVOR=dynamic") | |
1196 | #:phases | |
1197 | (modify-phases %standard-phases | |
1198 | (add-after 'unpack 'chdir | |
1199 | (lambda _ (chdir "src") #t)) | |
1200 | (replace 'configure | |
1201 | (lambda* (#:key inputs #:allow-other-keys) | |
1202 | (let ((glib (assoc-ref inputs "glib"))) | |
ad60a348 | 1203 | (setenv "CXXFLAGS" "-fPIC") |
99260014 RW |
1204 | (setenv "CPLUS_INCLUDE_PATH" |
1205 | (string-append glib "/include/glib-2.0:" | |
1206 | glib "/lib/glib-2.0/include:" | |
1207 | (assoc-ref inputs "gstreamer") | |
ad60a348 | 1208 | "/include/gstreamer-1.0"))) |
99260014 RW |
1209 | (substitute* "Makefile" |
1210 | (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") | |
ad60a348 MB |
1211 | (("\\$\\(error Cannot find") "#")) |
1212 | #t)) | |
99260014 RW |
1213 | (add-before 'build 'build-depend |
1214 | (lambda* (#:key make-flags #:allow-other-keys) | |
1215 | (apply invoke "make" "depend" make-flags))) | |
1216 | (replace 'install | |
1217 | (lambda* (#:key outputs #:allow-other-keys) | |
1218 | (let* ((out (assoc-ref outputs "out")) | |
1219 | (lib (string-append out "/lib/gstreamer-1.0"))) | |
1220 | (install-file "libgstkaldinnet2onlinedecoder.so" lib) | |
1221 | #t)))))) | |
1222 | (inputs | |
1223 | `(("glib" ,glib) | |
1224 | ("gstreamer" ,gstreamer) | |
1225 | ("jansson" ,jansson) | |
1226 | ("openfst" ,openfst) | |
1227 | ("kaldi" ,kaldi))) | |
1228 | (native-inputs | |
1229 | `(("bash" ,bash) | |
1230 | ("glib:bin" ,glib "bin") ; glib-genmarshal | |
1231 | ("kaldi-src" ,(package-source kaldi)) | |
1232 | ("pkg-config" ,pkg-config))) | |
1233 | (home-page "https://kaldi-asr.org/") | |
1234 | (synopsis "Gstreamer plugin for decoding speech") | |
1235 | (description "This package provides a GStreamer plugin that wraps | |
1236 | Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN | |
1237 | acoustic models. The iVectors are adapted to the current audio stream | |
1238 | automatically.") | |
1239 | (license license:asl2.0)))) | |
10451f6b RW |
1240 | |
1241 | (define-public kaldi-gstreamer-server | |
1228c2ab RW |
1242 | ;; This is the tip of the py3 branch |
1243 | (let ((commit "f68cab490be7eb0da2af1475fbc16655f50a60cb") | |
1244 | (revision "2")) | |
10451f6b RW |
1245 | (package |
1246 | (name "kaldi-gstreamer-server") | |
1247 | (version (git-version "0" revision commit)) | |
1248 | (source (origin | |
1249 | (method git-fetch) | |
1250 | (uri (git-reference | |
1251 | (url "https://github.com/alumae/kaldi-gstreamer-server.git") | |
1252 | (commit commit))) | |
1253 | (file-name (git-file-name name version)) | |
1254 | (sha256 | |
1255 | (base32 | |
1228c2ab | 1256 | "17lh1368vkg8ngrcbn2phvigzlmalrqg6djx2gg61qq1a0nj87dm")))) |
10451f6b RW |
1257 | (build-system gnu-build-system) |
1258 | (arguments | |
1259 | `(#:tests? #f ; there are no tests that can be run automatically | |
1260 | #:modules ((guix build utils) | |
1261 | (guix build gnu-build-system) | |
1262 | (srfi srfi-26)) | |
1263 | #:phases | |
1264 | (modify-phases %standard-phases | |
1265 | (delete 'configure) | |
1266 | (replace 'build | |
1267 | (lambda* (#:key outputs #:allow-other-keys) | |
1268 | ;; Disable hash randomization to ensure the generated .pycs | |
1269 | ;; are reproducible. | |
1270 | (setenv "PYTHONHASHSEED" "0") | |
1271 | (with-directory-excursion "kaldigstserver" | |
1228c2ab RW |
1272 | ;; This is a Python 2 file |
1273 | (delete-file "decoder_test.py") | |
1274 | (delete-file "test-buffer.py") | |
1275 | ||
10451f6b RW |
1276 | (for-each (lambda (file) |
1277 | (apply invoke | |
1278 | `("python" | |
1279 | "-m" "compileall" | |
1280 | "-f" ; force rebuild | |
1281 | ,file))) | |
1282 | (find-files "." "\\.py$"))) | |
1283 | #t)) | |
1284 | (replace 'install | |
1285 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1286 | (let* ((out (assoc-ref outputs "out")) | |
1287 | (bin (string-append out "/bin")) | |
1288 | (share (string-append out "/share/kaldi-gstreamer-server/"))) | |
1289 | ;; Install Python files | |
1290 | (with-directory-excursion "kaldigstserver" | |
1291 | (for-each (cut install-file <> share) | |
1292 | (find-files "." ".*"))) | |
1293 | ||
1294 | ;; Install sample configuration files | |
1295 | (for-each (cut install-file <> share) | |
1296 | (find-files "." "\\.yaml")) | |
1297 | ||
1298 | ;; Install executables | |
1299 | (mkdir-p bin) | |
1300 | (let* ((server (string-append bin "/kaldi-gst-server")) | |
1301 | (client (string-append bin "/kaldi-gst-client")) | |
1302 | (worker (string-append bin "/kaldi-gst-worker")) | |
1303 | (PYTHONPATH (getenv "PYTHONPATH")) | |
1304 | (GST_PLUGIN_PATH (string-append | |
1305 | (assoc-ref inputs "gst-kaldi-nnet2-online") | |
1306 | "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) | |
1307 | (wrap (lambda (wrapper what) | |
1308 | (with-output-to-file wrapper | |
1309 | (lambda _ | |
1310 | (format #t | |
1311 | "#!~a | |
1312 | export PYTHONPATH=~a | |
1313 | export GST_PLUGIN_PATH=~a | |
1314 | exec ~a ~a/~a \"$@\"~%" | |
1315 | (which "bash") PYTHONPATH GST_PLUGIN_PATH | |
1316 | (which "python") share what))) | |
1317 | (chmod wrapper #o555)))) | |
1318 | (for-each wrap | |
1319 | (list server client worker) | |
1320 | (list "master_server.py" | |
1321 | "client.py" | |
1322 | "worker.py"))) | |
1323 | #t)))))) | |
1324 | (inputs | |
1325 | `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online) | |
1228c2ab RW |
1326 | ("python" ,python-wrapper) |
1327 | ("python-pygobject" ,python-pygobject) | |
1328 | ("python-pyyaml" ,python-pyyaml) | |
1329 | ("python-tornado" ,python-tornado))) | |
10451f6b RW |
1330 | (home-page "https://github.com/alumae/kaldi-gstreamer-server") |
1331 | (synopsis "Real-time full-duplex speech recognition server") | |
1332 | (description "This is a real-time full-duplex speech recognition server, | |
1333 | based on the Kaldi toolkit and the GStreamer framework and implemented in | |
1334 | Python.") | |
1335 | (license license:bsd-2)))) | |
0dfeb285 | 1336 | |
4fa16c9a RW |
1337 | ;; Note that Tensorflow includes a "third_party" directory, which seems to not |
1338 | ;; only contain modified subsets of upstream library source code, but also | |
1339 | ;; adapter headers provided by Google (such as the fft.h header, which is not | |
1340 | ;; part of the upstream project code). The Tensorflow code includes headers | |
1341 | ;; from the "third_party" directory. It does not look like we can replace | |
1342 | ;; these headers with unmodified upstream files, so we keep them. | |
1343 | (define-public tensorflow | |
1344 | (package | |
1345 | (name "tensorflow") | |
1346 | (version "1.9.0") | |
1347 | (source | |
1348 | (origin | |
1349 | (method git-fetch) | |
1350 | (uri (git-reference | |
1351 | (url "https://github.com/tensorflow/tensorflow.git") | |
1352 | (commit (string-append "v" version)))) | |
1353 | (file-name (string-append "tensorflow-" version "-checkout")) | |
1354 | (sha256 | |
1355 | (base32 | |
1356 | "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")))) | |
1357 | (build-system cmake-build-system) | |
1358 | (arguments | |
1359 | `(#:tests? #f ; no "check" target | |
1360 | #:build-type "Release" | |
1361 | #:configure-flags | |
1362 | (let ((protobuf (assoc-ref %build-inputs "protobuf")) | |
1363 | (protobuf:native (assoc-ref %build-inputs "protobuf:native")) | |
1364 | (jsoncpp (assoc-ref %build-inputs "jsoncpp")) | |
1365 | (snappy (assoc-ref %build-inputs "snappy")) | |
1366 | (sqlite (assoc-ref %build-inputs "sqlite"))) | |
1367 | (list | |
1368 | ;; Use protobuf from Guix | |
1369 | (string-append "-Dprotobuf_STATIC_LIBRARIES=" | |
1370 | protobuf "/lib/libprotobuf.so") | |
1371 | (string-append "-DPROTOBUF_PROTOC_EXECUTABLE=" | |
1372 | protobuf:native "/bin/protoc") | |
1373 | ||
1374 | ;; Use snappy from Guix | |
1375 | (string-append "-Dsnappy_STATIC_LIBRARIES=" | |
1376 | snappy "/lib/libsnappy.so") | |
1377 | ;; Yes, this is not actually the include directory but a prefix... | |
1378 | (string-append "-Dsnappy_INCLUDE_DIR=" snappy) | |
1379 | ||
1380 | ;; Use jsoncpp from Guix | |
1381 | (string-append "-Djsoncpp_STATIC_LIBRARIES=" | |
1382 | jsoncpp "/lib/libjsoncpp.so") | |
1383 | ;; Yes, this is not actually the include directory but a prefix... | |
1384 | (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp) | |
1385 | ||
1386 | ;; Use sqlite from Guix | |
1387 | (string-append "-Dsqlite_STATIC_LIBRARIES=" | |
1388 | sqlite "/lib/libsqlite.a") | |
1389 | ||
1390 | ;; Use system libraries wherever possible. Currently, this | |
1391 | ;; only affects zlib. | |
1392 | "-Dsystemlib_ALL=ON" | |
1393 | "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON" | |
1394 | "-Dtensorflow_BUILD_SHARED_LIB=ON" | |
1395 | "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF" | |
1396 | "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF" | |
1397 | "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF")) | |
1398 | #:make-flags | |
1399 | (list "CC=gcc") | |
1400 | #:modules ((ice-9 ftw) | |
1401 | (guix build utils) | |
1402 | (guix build cmake-build-system)) | |
1403 | #:phases | |
1404 | (modify-phases %standard-phases | |
1405 | (add-after 'unpack 'set-source-file-times-to-1980 | |
1406 | ;; At the end of the tf_python_build_pip_package target, a ZIP | |
1407 | ;; archive should be generated via bdist_wheel, but it fails with | |
1408 | ;; "ZIP does not support timestamps before 1980". Luckily, | |
1409 | ;; SOURCE_DATE_EPOCH is respected, which we set to some time in | |
1410 | ;; 1980. | |
1411 | (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t)) | |
1412 | ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913 | |
1413 | (add-after 'unpack 'python3.7-compatibility | |
1414 | (lambda _ | |
1415 | (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc" | |
1416 | "tensorflow/python/lib/core/ndarray_tensor.cc" | |
1417 | "tensorflow/python/lib/core/py_func.cc") | |
1418 | (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8")) | |
1419 | (substitute* "tensorflow/c/eager/c_api.h" | |
1420 | (("unsigned char async") | |
1421 | "unsigned char is_async")) | |
1422 | ||
1423 | ;; Remove dependency on tensorboard, a complicated but probably | |
1424 | ;; optional package. | |
1425 | (substitute* "tensorflow/tools/pip_package/setup.py" | |
1426 | ((".*'tensorboard >.*") "")) | |
1427 | #t)) | |
1428 | (add-after 'python3.7-compatibility 'chdir | |
1429 | (lambda _ (chdir "tensorflow/contrib/cmake") #t)) | |
1430 | (add-after 'chdir 'disable-downloads | |
1431 | (lambda* (#:key inputs #:allow-other-keys) | |
1432 | (substitute* (find-files "external" "\\.cmake$") | |
1433 | (("GIT_REPOSITORY.*") "") | |
1434 | (("GIT_TAG.*") "") | |
1435 | (("PREFIX ") | |
1436 | "DOWNLOAD_COMMAND \"\"\nPREFIX ")) | |
1437 | ||
1438 | ;; Use packages from Guix | |
1439 | (let ((grpc (assoc-ref inputs "grpc"))) | |
1440 | (substitute* "CMakeLists.txt" | |
1441 | ;; Sqlite | |
1442 | (("include\\(sqlite\\)") "") | |
1443 | (("\\$\\{sqlite_STATIC_LIBRARIES\\}") | |
1444 | (string-append (assoc-ref inputs "sqlite") | |
1445 | "/lib/libsqlite3.so")) | |
1446 | (("sqlite_copy_headers_to_destination") "") | |
1447 | ||
1448 | ;; PNG | |
1449 | (("include\\(png\\)") "") | |
1450 | (("\\$\\{png_STATIC_LIBRARIES\\}") | |
1451 | (string-append (assoc-ref inputs "libpng") | |
1452 | "/lib/libpng16.so")) | |
1453 | (("png_copy_headers_to_destination") "") | |
1454 | ||
1455 | ;; JPEG | |
1456 | (("include\\(jpeg\\)") "") | |
1457 | (("\\$\\{jpeg_STATIC_LIBRARIES\\}") | |
1458 | (string-append (assoc-ref inputs "libjpeg") | |
1459 | "/lib/libjpeg.so")) | |
1460 | (("jpeg_copy_headers_to_destination") "") | |
1461 | ||
1462 | ;; GIF | |
1463 | (("include\\(gif\\)") "") | |
1464 | (("\\$\\{gif_STATIC_LIBRARIES\\}") | |
1465 | (string-append (assoc-ref inputs "giflib") | |
1466 | "/lib/libgif.so")) | |
1467 | (("gif_copy_headers_to_destination") "") | |
1468 | ||
1469 | ;; lmdb | |
1470 | (("include\\(lmdb\\)") "") | |
1471 | (("\\$\\{lmdb_STATIC_LIBRARIES\\}") | |
1472 | (string-append (assoc-ref inputs "lmdb") | |
1473 | "/lib/liblmdb.so")) | |
1474 | (("lmdb_copy_headers_to_destination") "") | |
1475 | ||
1476 | ;; Protobuf | |
1477 | (("include\\(protobuf\\)") "") | |
1478 | (("protobuf_copy_headers_to_destination") "") | |
1479 | (("^ +protobuf") "") | |
1480 | ||
1481 | ;; gRPC | |
1482 | (("include\\(grpc\\)") | |
1483 | "find_package(grpc REQUIRED NAMES gRPC)") | |
1484 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "") | |
1485 | ||
1486 | ;; Eigen | |
1487 | (("include\\(eigen\\)") | |
1488 | (string-append "find_package(eigen REQUIRED NAMES Eigen3) | |
1489 | set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " | |
1490 | (assoc-ref inputs "eigen") "/include/eigen3)")) | |
1491 | (("^ +eigen") "") | |
1492 | ||
1493 | ;; snappy | |
1494 | (("include\\(snappy\\)") | |
1495 | "add_definitions(-DTF_USE_SNAPPY)") | |
1496 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "") | |
1497 | ||
1498 | ;; jsoncpp | |
1499 | (("include\\(jsoncpp\\)") "") | |
1500 | (("^ +jsoncpp") "")) | |
1501 | ||
1502 | (substitute* "tf_core_framework.cmake" | |
1503 | ((" grpc") "") | |
1504 | (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin") | |
1505 | (which "grpc_cpp_plugin")) | |
1506 | ;; Link with gRPC libraries | |
1507 | (("add_library\\(tf_protos_cc.*" m) | |
1508 | (string-append m | |
1509 | (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \ | |
1510 | ~a/lib/libgrpc++_unsecure.a \ | |
1511 | ~a/lib/libgrpc_unsecure.a \ | |
1512 | ~a/lib/libaddress_sorting.a \ | |
1513 | ~a/lib/libgpr.a \ | |
1514 | ~a//lib/libcares.so | |
1515 | )\n" | |
1516 | grpc grpc grpc grpc | |
1517 | (assoc-ref inputs "c-ares")))))) | |
1518 | (substitute* "tf_tools.cmake" | |
1519 | (("add_dependencies\\(\\$\\{proto_text.*") "")) | |
1520 | ;; Remove dependency on bundled grpc | |
1521 | (substitute* "tf_core_distributed_runtime.cmake" | |
1522 | (("tf_core_cpu grpc") "tf_core_cpu")) | |
1523 | ||
1524 | ;; This directory is a dependency of many targets. | |
1525 | (mkdir-p "protobuf") | |
1526 | #t)) | |
1527 | (add-after 'configure 'unpack-third-party-sources | |
1528 | (lambda* (#:key inputs #:allow-other-keys) | |
1529 | ;; This is needed to configure bundled packages properly. | |
1530 | (setenv "CONFIG_SHELL" (which "bash")) | |
1531 | (for-each | |
1532 | (lambda (name) | |
1533 | (let* ((what (assoc-ref inputs (string-append name "-src"))) | |
1534 | (name* (string-map (lambda (c) | |
1535 | (if (char=? c #\-) | |
1536 | #\_ c)) name)) | |
1537 | (where (string-append "../build/" name* "/src/" name*))) | |
1538 | (cond | |
1539 | ((string-suffix? ".zip" what) | |
1540 | (mkdir-p where) | |
1541 | (with-directory-excursion where | |
1542 | (invoke "unzip" what))) | |
1543 | ((string-suffix? ".tar.gz" what) | |
1544 | (mkdir-p where) | |
1545 | (invoke "tar" "xf" what | |
1546 | "-C" where "--strip-components=1")) | |
1547 | (else | |
1548 | (let ((parent (dirname where))) | |
1549 | (mkdir-p parent) | |
1550 | (with-directory-excursion parent | |
1551 | (when (file-exists? name*) | |
1552 | (delete-file-recursively name*)) | |
1553 | (copy-recursively what name*) | |
1554 | (map make-file-writable | |
1555 | (find-files name* ".*")))))))) | |
1556 | (list "boringssl" | |
1557 | "cub" | |
1558 | "double-conversion" | |
1559 | "farmhash" | |
1560 | "fft2d" | |
1561 | "highwayhash" | |
1562 | "nsync" | |
1563 | "re2")) | |
1564 | ||
1565 | (rename-file "../build/cub/src/cub/cub-1.8.0/" | |
1566 | "../build/cub/src/cub/cub/") | |
1567 | #t)) | |
1568 | (add-after 'unpack 'fix-python-build | |
1569 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1570 | (mkdir-p "protobuf-src") | |
1571 | (invoke "tar" "xf" (assoc-ref inputs "protobuf:src") | |
1572 | "-C" "protobuf-src" "--strip-components=1") | |
1573 | (mkdir-p "eigen-src") | |
1574 | (invoke "tar" "xf" (assoc-ref inputs "eigen:src") | |
1575 | "-C" "eigen-src" "--strip-components=1") | |
1576 | ||
1577 | (substitute* "tensorflow/contrib/cmake/tf_python.cmake" | |
1578 | ;; Ensure that all Python dependencies can be found at build time. | |
1579 | (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m) | |
1580 | (string-append m ":" (getenv "PYTHONPATH"))) | |
1581 | ;; Take protobuf source files from our source package. | |
1582 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google") | |
1583 | (string-append (getcwd) "/protobuf-src/src/google"))) | |
1584 | ||
1585 | (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake" | |
1586 | "tensorflow/contrib/cmake/tf_python.cmake") | |
1587 | ;; Take Eigen source files from our source package. | |
1588 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/") | |
1589 | (string-append (getcwd) "/eigen-src/")) | |
1590 | ;; Take Eigen headers from our own package. | |
1591 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive") | |
1592 | (string-append (assoc-ref inputs "eigen") "/include/eigen3"))) | |
1593 | ||
1594 | ;; Correct the RUNPATH of ops libraries generated for Python. | |
1595 | ;; TODO: this doesn't work :( | |
1596 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1597 | ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build") | |
1598 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1599 | ;; error: depends on 'libpywrap_tensorflow_internal.so', which | |
1600 | ;; cannot be found in RUNPATH ... | |
1601 | (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake" | |
1602 | (("set_target_properties.*") | |
1603 | (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \ | |
1604 | COMPILE_FLAGS ${target_compile_flags} \ | |
1605 | INSTALL_RPATH_USE_LINK_PATH TRUE \ | |
1606 | INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))) | |
1607 | #t)) | |
1608 | (add-after 'build 'build-pip-package | |
1609 | (lambda* (#:key outputs #:allow-other-keys) | |
1610 | (setenv "LDFLAGS" | |
1611 | (string-append "-Wl,-rpath=" | |
1612 | (assoc-ref outputs "out") "/lib")) | |
1613 | (invoke "make" "tf_python_build_pip_package") | |
1614 | #t)) | |
1615 | (add-after 'build-pip-package 'install-python | |
1616 | (lambda* (#:key outputs #:allow-other-keys) | |
1617 | (let ((out (assoc-ref outputs "out")) | |
1618 | (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$")))) | |
1619 | (invoke "python" "-m" "pip" "install" wheel | |
1620 | (string-append "--prefix=" out)) | |
1621 | ||
1622 | ;; XXX: broken RUNPATH, see fix-python-build phase. | |
1623 | (delete-file | |
1624 | (string-append | |
1625 | out "/lib/python3.7/site-packages/tensorflow/contrib/" | |
1626 | "seq2seq/python/ops/lib_beam_search_ops.so")) | |
1627 | #t)))))) | |
1628 | (native-inputs | |
1629 | `(("pkg-config" ,pkg-config) | |
7373eb83 MB |
1630 | ("protobuf:native" ,protobuf-3.6) ; protoc |
1631 | ("protobuf:src" ,(package-source protobuf-3.6)) | |
4fa16c9a | 1632 | ("eigen:src" ,(package-source eigen-for-tensorflow)) |
0fdec2a3 MB |
1633 | ;; install_pip_packages.sh wants setuptools 39.1.0 specifically. |
1634 | ("python-setuptools" ,python-setuptools-for-tensorflow) | |
1635 | ||
4fa16c9a RW |
1636 | ;; The commit hashes and URLs for third-party source code are taken |
1637 | ;; from "tensorflow/workspace.bzl". | |
1638 | ("boringssl-src" | |
1639 | ,(let ((commit "ee7aa02") | |
1640 | (revision "1")) | |
1641 | (origin | |
1642 | (method git-fetch) | |
1643 | (uri (git-reference | |
1644 | (url "https://boringssl.googlesource.com/boringssl") | |
1645 | (commit commit))) | |
1646 | (file-name (string-append "boringssl-0-" revision | |
1647 | (string-take commit 7) | |
1648 | "-checkout")) | |
1649 | (sha256 | |
1650 | (base32 | |
1651 | "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw"))))) | |
1652 | ("cub-src" | |
1653 | ,(let ((version "1.8.0")) | |
1654 | (origin | |
1655 | (method url-fetch) | |
1656 | (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/" | |
1657 | "cub/archive/" version ".zip")) | |
1658 | (file-name (string-append "cub-" version ".zip")) | |
1659 | (sha256 | |
1660 | (base32 | |
1661 | "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb"))))) | |
1662 | ("double-conversion-src" | |
1663 | ,(let ((commit "5664746") | |
1664 | (revision "1")) | |
1665 | (origin | |
1666 | (method git-fetch) | |
1667 | (uri (git-reference | |
1668 | (url "https://github.com/google/double-conversion.git") | |
1669 | (commit commit))) | |
1670 | (file-name | |
1671 | (git-file-name "double-conversion" | |
1672 | (string-append "0-" revision "." | |
1673 | (string-take commit 7)))) | |
1674 | (sha256 | |
1675 | (base32 | |
1676 | "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1"))))) | |
1677 | ("farmhash-src" | |
1678 | ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")) | |
1679 | (origin | |
1680 | (method url-fetch) | |
1681 | (uri (string-append | |
1682 | "https://mirror.bazel.build/github.com/google/farmhash/archive/" | |
1683 | commit ".tar.gz")) | |
1684 | (file-name (string-append "farmhash-0-" (string-take commit 7) | |
1685 | ".tar.gz")) | |
1686 | (sha256 | |
1687 | (base32 | |
1688 | "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35"))))) | |
1689 | ;; The license notice on the home page at | |
1690 | ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says: | |
1691 | ;; Copyright Takuya OOURA, 1996-2001 | |
1692 | ;; | |
1693 | ;; You may use, copy, modify and distribute this code for any purpose | |
1694 | ;; (include commercial use) and without fee. Please refer to this | |
1695 | ;; package when you modify this code. | |
1696 | ;; | |
1697 | ;; We take the identical tarball from the Bazel mirror, because the URL | |
1698 | ;; at the home page is not versioned and might change. | |
1699 | ("fft2d-src" | |
1700 | ,(origin | |
1701 | (method url-fetch) | |
1702 | (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz") | |
1703 | (file-name "fft2d.tar.gz") | |
1704 | (sha256 | |
1705 | (base32 | |
1706 | "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj")))) | |
1707 | ("highwayhash-src" | |
1708 | ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee") | |
1709 | (revision "1")) | |
1710 | (origin | |
1711 | (method git-fetch) | |
1712 | (uri (git-reference | |
1713 | (url "https://github.com/google/highwayhash.git") | |
1714 | (commit commit))) | |
1715 | (file-name (string-append "highwayhash-0-" revision | |
1716 | (string-take commit 7) | |
1717 | "-checkout")) | |
1718 | (sha256 | |
1719 | (base32 | |
1720 | "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6"))))) | |
1721 | ("nsync-src" | |
1722 | ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777") | |
1723 | (revision "1")) | |
1724 | (origin | |
1725 | (method url-fetch) | |
1726 | (uri (string-append "https://mirror.bazel.build/" | |
1727 | "github.com/google/nsync/archive/" | |
1728 | version ".tar.gz")) | |
1729 | (file-name (string-append "nsync-0." revision | |
1730 | "-" (string-take version 7) | |
1731 | ".tar.gz")) | |
1732 | (sha256 | |
1733 | (base32 | |
1734 | "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132"))))) | |
1735 | ("re2-src" | |
1736 | ,(let ((commit "e7efc48") | |
1737 | (revision "1")) | |
1738 | (origin | |
1739 | (method git-fetch) | |
1740 | (uri (git-reference | |
1741 | (url "https://github.com/google/re2") | |
1742 | (commit commit))) | |
1743 | (file-name (string-append "re2-0-" revision | |
1744 | (string-take commit 7) | |
1745 | "-checkout")) | |
1746 | (sha256 | |
1747 | (base32 | |
1748 | "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign"))))) | |
1749 | ("googletest" ,googletest) | |
1750 | ("swig" ,swig) | |
1751 | ("unzip" ,unzip))) | |
1752 | (propagated-inputs | |
1753 | `(("python-absl-py" ,python-absl-py) | |
1754 | ("python-astor" ,python-astor) | |
1755 | ("python-gast" ,python-gast) | |
1756 | ("python-grpcio" ,python-grpcio) | |
1757 | ("python-numpy" ,python-numpy) | |
7373eb83 | 1758 | ("python-protobuf" ,python-protobuf-3.6) |
4fa16c9a RW |
1759 | ("python-six" ,python-six) |
1760 | ("python-termcolo" ,python-termcolor) | |
1761 | ("python-wheel" ,python-wheel))) | |
1762 | (inputs | |
3b458d54 | 1763 | `(("c-ares" ,c-ares) |
4fa16c9a RW |
1764 | ("eigen" ,eigen-for-tensorflow) |
1765 | ("gemmlowp" ,gemmlowp-for-tensorflow) | |
1766 | ("lmdb" ,lmdb) | |
1767 | ("libjpeg" ,libjpeg) | |
1768 | ("libpng" ,libpng) | |
1769 | ("giflib" ,giflib) | |
80a8583a | 1770 | ("grpc" ,grpc-1.16.1 "static") |
447fafe3 | 1771 | ("grpc:bin" ,grpc-1.16.1) |
4fa16c9a RW |
1772 | ("jsoncpp" ,jsoncpp-for-tensorflow) |
1773 | ("snappy" ,snappy) | |
1774 | ("sqlite" ,sqlite) | |
7373eb83 | 1775 | ("protobuf" ,protobuf-3.6) |
4fa16c9a RW |
1776 | ("python" ,python-wrapper) |
1777 | ("zlib" ,zlib))) | |
1778 | (home-page "https://tensorflow.org") | |
1779 | (synopsis "Machine learning framework") | |
1780 | (description | |
1781 | "TensorFlow is a flexible platform for building and training machine | |
1782 | learning models. It provides a library for high performance numerical | |
1783 | computation and includes high level Python APIs, including both a sequential | |
1784 | API for beginners that allows users to build models quickly by plugging | |
1785 | together building blocks and a subclassing API with an imperative style for | |
1786 | advanced research.") | |
1787 | (license license:asl2.0))) | |
d60b064d NG |
1788 | |
1789 | (define-public python-iml | |
1790 | (package | |
1791 | (name "python-iml") | |
1792 | (version "0.6.2") | |
1793 | (source | |
1794 | (origin | |
1795 | (method url-fetch) | |
1796 | (uri (pypi-uri "iml" version)) | |
1797 | (sha256 | |
1798 | (base32 | |
1799 | "1k8szlpm19rcwcxdny9qdm3gmaqq8akb4xlvrzyz8c2d679aak6l")))) | |
1800 | (build-system python-build-system) | |
1801 | (propagated-inputs | |
1802 | `(("ipython" ,python-ipython) | |
1803 | ("nose" ,python-nose) | |
1804 | ("numpy" ,python-numpy) | |
1805 | ("pandas" ,python-pandas) | |
1806 | ("scipy" ,python-scipy))) | |
1807 | (home-page "http://github.com/interpretable-ml/iml") | |
1808 | (synopsis "Interpretable Machine Learning (iML) package") | |
1809 | (description "Interpretable ML (iML) is a set of data type objects, | |
1810 | visualizations, and interfaces that can be used by any method designed to | |
1811 | explain the predictions of machine learning models (or really the output of | |
1812 | any function). It currently contains the interface and IO code from the Shap | |
1813 | project, and it will potentially also do the same for the Lime project.") | |
1814 | (license license:expat))) | |
d93ad191 RW |
1815 | |
1816 | (define-public python-keras-applications | |
1817 | (package | |
1818 | (name "python-keras-applications") | |
1819 | (version "1.0.8") | |
1820 | (source | |
1821 | (origin | |
1822 | (method url-fetch) | |
1823 | (uri (pypi-uri "Keras_Applications" version)) | |
1824 | (sha256 | |
1825 | (base32 | |
1826 | "1rcz31ca4axa6kzhjx4lwqxbg4wvlljkj8qj9a7p9sfd5fhzjyam")))) | |
1827 | (build-system python-build-system) | |
1828 | ;; The tests require Keras, but this package is needed to build Keras. | |
1829 | (arguments '(#:tests? #f)) | |
1830 | (propagated-inputs | |
1831 | `(("python-h5py" ,python-h5py) | |
1832 | ("python-numpy" ,python-numpy))) | |
1833 | (native-inputs | |
1834 | `(("python-pytest" ,python-pytest) | |
1835 | ("python-pytest-cov" ,python-pytest-cov) | |
1836 | ("python-pytest-pep8" ,python-pytest-pep8) | |
1837 | ("python-pytest-xdist" ,python-pytest-xdist))) | |
1838 | (home-page "https://github.com/keras-team/keras-applications") | |
1839 | (synopsis "Reference implementations of popular deep learning models") | |
1840 | (description | |
1841 | "This package provides reference implementations of popular deep learning | |
1842 | models for use with the Keras deep learning framework.") | |
1843 | (license license:expat))) | |
4abc5066 RW |
1844 | |
1845 | (define-public python-keras-preprocessing | |
1846 | (package | |
1847 | (name "python-keras-preprocessing") | |
1848 | (version "1.1.0") | |
1849 | (source | |
1850 | (origin | |
1851 | (method url-fetch) | |
1852 | (uri (pypi-uri "Keras_Preprocessing" version)) | |
1853 | (sha256 | |
1854 | (base32 | |
1855 | "1r98nm4k1svsqjyaqkfk23i31bl1kcfcyp7094yyj3c43phfp3as")))) | |
1856 | (build-system python-build-system) | |
1857 | (propagated-inputs | |
1858 | `(("python-numpy" ,python-numpy) | |
1859 | ("python-six" ,python-six))) | |
1860 | (native-inputs | |
1861 | `(("python-pandas" ,python-pandas) | |
1862 | ("python-pillow" ,python-pillow) | |
1863 | ("python-pytest" ,python-pytest) | |
1864 | ("python-pytest-cov" ,python-pytest-cov) | |
1865 | ("python-pytest-xdist" ,python-pytest-xdist) | |
1866 | ("tensorflow" ,tensorflow))) | |
1867 | (home-page "https://github.com/keras-team/keras-preprocessing/") | |
1868 | (synopsis "Data preprocessing and augmentation for deep learning models") | |
1869 | (description | |
1870 | "Keras Preprocessing is the data preprocessing and data augmentation | |
1871 | module of the Keras deep learning library. It provides utilities for working | |
1872 | with image data, text data, and sequence data.") | |
1873 | (license license:expat))) | |
f1765b57 RW |
1874 | |
1875 | (define-public python-keras | |
1876 | (package | |
1877 | (name "python-keras") | |
1878 | (version "2.2.4") | |
1879 | (source | |
1880 | (origin | |
1881 | (method url-fetch) | |
1882 | (uri (pypi-uri "Keras" version)) | |
b16e0827 | 1883 | (patches (search-patches "python-keras-integration-test.patch")) |
f1765b57 RW |
1884 | (sha256 |
1885 | (base32 | |
1886 | "1j8bsqzh49vjdxy6l1k4iwax5vpjzniynyd041xjavdzvfii1dlh")))) | |
1887 | (build-system python-build-system) | |
1888 | (arguments | |
1889 | `(#:phases | |
1890 | (modify-phases %standard-phases | |
1891 | (add-after 'unpack 'remove-tests-for-unavailable-features | |
1892 | (lambda _ | |
1893 | (delete-file "keras/backend/theano_backend.py") | |
1894 | (delete-file "keras/backend/cntk_backend.py") | |
1895 | (delete-file "tests/keras/backend/backend_test.py") | |
1896 | ||
1897 | ;; FIXME: This doesn't work because Tensorflow is missing the | |
1898 | ;; coder ops library. | |
1899 | (delete-file "tests/keras/test_callbacks.py") | |
1900 | #t)) | |
1901 | (replace 'check | |
1902 | (lambda _ | |
1903 | ;; These tests attempt to download data files from the internet. | |
1904 | (delete-file "tests/integration_tests/test_datasets.py") | |
1905 | (delete-file "tests/integration_tests/imagenet_utils_test.py") | |
1906 | ||
1907 | (setenv "PYTHONPATH" | |
1908 | (string-append (getcwd) "/build/lib:" | |
1909 | (getenv "PYTHONPATH"))) | |
1910 | (invoke "py.test" "-v" | |
1911 | "-p" "no:cacheprovider" | |
1912 | "--ignore" "keras/utils")))))) | |
1913 | (propagated-inputs | |
1914 | `(("python-h5py" ,python-h5py) | |
1915 | ("python-keras-applications" ,python-keras-applications) | |
1916 | ("python-keras-preprocessing" ,python-keras-preprocessing) | |
1917 | ("python-numpy" ,python-numpy) | |
1918 | ("python-pydot" ,python-pydot) | |
1919 | ("python-pyyaml" ,python-pyyaml) | |
1920 | ("python-scipy" ,python-scipy) | |
1921 | ("python-six" ,python-six) | |
1922 | ("tensorflow" ,tensorflow) | |
1923 | ("graphviz" ,graphviz))) | |
1924 | (native-inputs | |
1925 | `(("python-pandas" ,python-pandas) | |
1926 | ("python-pytest" ,python-pytest) | |
1927 | ("python-pytest-cov" ,python-pytest-cov) | |
1928 | ("python-pytest-pep8" ,python-pytest-pep8) | |
1929 | ("python-pytest-timeout" ,python-pytest-timeout) | |
1930 | ("python-pytest-xdist" ,python-pytest-xdist) | |
1931 | ("python-sphinx" ,python-sphinx) | |
1932 | ("python-requests" ,python-requests))) | |
1933 | (home-page "https://github.com/keras-team/keras") | |
1934 | (synopsis "High-level deep learning framework") | |
1935 | (description "Keras is a high-level neural networks API, written in Python | |
1936 | and capable of running on top of TensorFlow. It was developed with a focus on | |
1937 | enabling fast experimentation. Use Keras if you need a deep learning library | |
1938 | that: | |
1939 | ||
1940 | @itemize | |
1941 | @item Allows for easy and fast prototyping (through user friendliness, | |
1942 | modularity, and extensibility). | |
1943 | @item Supports both convolutional networks and recurrent networks, as well as | |
1944 | combinations of the two. | |
1945 | @item Runs seamlessly on CPU and GPU. | |
1946 | @end itemize\n") | |
1947 | (license license:expat))) | |
6e760872 GLV |
1948 | |
1949 | (define-public sbcl-cl-libsvm-format | |
1950 | (let ((commit "3300f84fd8d9f5beafc114f543f9d83417c742fb") | |
1951 | (revision "0")) | |
1952 | (package | |
1953 | (name "sbcl-cl-libsvm-format") | |
1954 | (version (git-version "0.1.0" revision commit)) | |
1955 | (source | |
1956 | (origin | |
1957 | (method git-fetch) | |
1958 | (uri (git-reference | |
1959 | (url "https://github.com/masatoi/cl-libsvm-format.git") | |
1960 | (commit commit))) | |
1961 | (file-name (git-file-name name version)) | |
1962 | (sha256 | |
1963 | (base32 | |
1964 | "0284aj84xszhkhlivaigf9qj855fxad3mzmv3zfr0qzb5k0nzwrg")))) | |
1965 | (build-system asdf-build-system/sbcl) | |
1966 | (native-inputs | |
1967 | `(("prove" ,sbcl-prove) | |
1968 | ("prove-asdf" ,sbcl-prove-asdf))) | |
1969 | (inputs | |
1970 | `(("alexandria" ,sbcl-alexandria))) | |
1971 | (synopsis "LibSVM data format reader for Common Lisp") | |
1972 | (description | |
1973 | "This Common Lisp library provides a fast reader for data in LibSVM | |
1974 | format.") | |
1975 | (home-page "https://github.com/masatoi/cl-libsvm-format") | |
1976 | (license license:expat)))) | |
1977 | ||
1978 | (define-public cl-libsvm-format | |
1979 | (sbcl-package->cl-source-package sbcl-cl-libsvm-format)) | |
1980 | ||
1981 | (define-public ecl-cl-libsvm-format | |
1982 | (sbcl-package->ecl-package sbcl-cl-libsvm-format)) | |
7a15aab8 GLV |
1983 | |
1984 | (define-public sbcl-cl-online-learning | |
1985 | (let ((commit "fc7a34f4f161cd1c7dd747d2ed8f698947781423") | |
1986 | (revision "0")) | |
1987 | (package | |
1988 | (name "sbcl-cl-online-learning") | |
1989 | (version (git-version "0.5" revision commit)) | |
1990 | (source | |
1991 | (origin | |
1992 | (method git-fetch) | |
1993 | (uri (git-reference | |
1994 | (url "https://github.com/masatoi/cl-online-learning.git") | |
1995 | (commit commit))) | |
1996 | (file-name (git-file-name name version)) | |
1997 | (sha256 | |
1998 | (base32 | |
1999 | "14x95rlg80ay5hv645ki57pqvy12v28hz4k1w0f6bsfi2rmpxchq")))) | |
2000 | (build-system asdf-build-system/sbcl) | |
2001 | (native-inputs | |
2002 | `(("prove" ,sbcl-prove) | |
2003 | ("prove-asdf" ,sbcl-prove-asdf))) | |
2004 | (inputs | |
2005 | `(("cl-libsvm-format" ,sbcl-cl-libsvm-format) | |
2006 | ("cl-store" ,sbcl-cl-store))) | |
2007 | (arguments | |
2008 | `(;; FIXME: Tests pass but then the check phase crashes | |
2009 | #:tests? #f)) | |
2010 | (synopsis "Online Machine Learning for Common Lisp") | |
2011 | (description | |
2012 | "This library contains a collection of machine learning algorithms for | |
2013 | online linear classification written in Common Lisp.") | |
2014 | (home-page "https://github.com/masatoi/cl-online-learning") | |
2015 | (license license:expat)))) | |
2016 | ||
2017 | (define-public cl-online-learning | |
2018 | (sbcl-package->cl-source-package sbcl-cl-online-learning)) | |
2019 | ||
2020 | (define-public ecl-cl-online-learning | |
2021 | (sbcl-package->ecl-package sbcl-cl-online-learning)) | |
5a65fede GLV |
2022 | |
2023 | (define-public sbcl-cl-random-forest | |
2024 | (let ((commit "85fbdd4596d40e824f70f1b7cf239cf544e49d51") | |
2025 | (revision "0")) | |
2026 | (package | |
2027 | (name "sbcl-cl-random-forest") | |
2028 | (version (git-version "0.1" revision commit)) | |
2029 | (source | |
2030 | (origin | |
2031 | (method git-fetch) | |
2032 | (uri (git-reference | |
2033 | (url "https://github.com/masatoi/cl-random-forest.git") | |
2034 | (commit commit))) | |
2035 | (file-name (git-file-name name version)) | |
2036 | (sha256 | |
2037 | (base32 | |
2038 | "097xv60i1ndz68sg9p4pc7c5gvyp9i1xgw966b4wwfq3x6hbz421")))) | |
2039 | (build-system asdf-build-system/sbcl) | |
2040 | (native-inputs | |
2041 | `(("prove" ,sbcl-prove) | |
2042 | ("prove-asdf" ,sbcl-prove-asdf) | |
2043 | ("trivial-garbage" ,sbcl-trivial-garbage))) | |
2044 | (inputs | |
2045 | `(("alexandria" ,sbcl-alexandria) | |
2046 | ("cl-libsvm-format" ,sbcl-cl-libsvm-format) | |
2047 | ("cl-online-learning" ,sbcl-cl-online-learning) | |
2048 | ("lparallel" ,sbcl-lparallel))) | |
2049 | (arguments | |
2050 | `(;; The tests download data from the Internet | |
2051 | #:tests? #f | |
2052 | #:phases | |
2053 | (modify-phases %standard-phases | |
2054 | (add-after 'unpack 'add-sb-cltl2-dependency | |
2055 | (lambda _ | |
2056 | ;; sb-cltl2 is required by lparallel when using sbcl, but it is | |
2057 | ;; not loaded automatically. | |
2058 | (substitute* "cl-random-forest.asd" | |
2059 | (("\\(in-package :cl-user\\)") | |
2060 | "(in-package :cl-user) #+sbcl (require :sb-cltl2)")) | |
2061 | #t))))) | |
2062 | (synopsis "Random Forest and Global Refinement for Common Lisp") | |
2063 | (description | |
2064 | "CL-random-forest is an implementation of Random Forest for multiclass | |
2065 | classification and univariate regression written in Common Lisp. It also | |
2066 | includes an implementation of Global Refinement of Random Forest.") | |
2067 | (home-page "https://github.com/masatoi/cl-random-forest") | |
2068 | (license license:expat)))) | |
2069 | ||
2070 | (define-public cl-random-forest | |
2071 | (sbcl-package->cl-source-package sbcl-cl-random-forest)) | |
2072 | ||
2073 | (define-public ecl-cl-random-forest | |
2074 | (sbcl-package->ecl-package sbcl-cl-random-forest)) | |
58b13287 GL |
2075 | |
2076 | (define-public gloo | |
2077 | (let ((version "0.0.0") ; no proper version tag | |
2078 | (commit "ca528e32fea9ca8f2b16053cff17160290fc84ce") | |
2079 | (revision "0")) | |
2080 | (package | |
2081 | (name "gloo") | |
2082 | (version (git-version version revision commit)) | |
2083 | (source | |
2084 | (origin | |
2085 | (method git-fetch) | |
2086 | (uri (git-reference | |
2087 | (url "https://github.com/facebookincubator/gloo.git") | |
2088 | (commit commit))) | |
2089 | (file-name (git-file-name name version)) | |
2090 | (sha256 | |
2091 | (base32 | |
2092 | "1q9f80zy75f6njrzrqkmhc0g3qxs4gskr7ns2jdqanxa2ww7a99w")))) | |
2093 | (build-system cmake-build-system) | |
2094 | (native-inputs | |
2095 | `(("googletest" ,googletest))) | |
2096 | (arguments | |
2097 | `(#:configure-flags '("-DBUILD_TEST=1") | |
2098 | #:phases | |
2099 | (modify-phases %standard-phases | |
2100 | (replace 'check | |
2101 | (lambda _ | |
2102 | (invoke "make" "gloo_test") | |
2103 | #t))))) | |
2104 | (synopsis "Collective communications library") | |
2105 | (description | |
2106 | "Gloo is a collective communications library. It comes with a | |
2107 | number of collective algorithms useful for machine learning applications. | |
2108 | These include a barrier, broadcast, and allreduce.") | |
2109 | (home-page "https://github.com/facebookincubator/gloo") | |
2110 | (license license:bsd-3)))) | |
5e42d197 BG |
2111 | |
2112 | (define-public python-umap-learn | |
2113 | (package | |
2114 | (name "python-umap-learn") | |
2115 | (version "0.3.10") | |
2116 | (source | |
2117 | (origin | |
2118 | (method url-fetch) | |
2119 | (uri (pypi-uri "umap-learn" version)) | |
2120 | (sha256 | |
2121 | (base32 | |
2122 | "02ada2yy6km6zgk2836kg1c97yrcpalvan34p8c57446finnpki1")))) | |
2123 | (build-system python-build-system) | |
2124 | (native-inputs | |
e2ca10a4 RJ |
2125 | `(("python-joblib" ,python-joblib) |
2126 | ("python-nose" ,python-nose))) | |
5e42d197 BG |
2127 | (propagated-inputs |
2128 | `(("python-numba" ,python-numba) | |
2129 | ("python-numpy" ,python-numpy) | |
2130 | ("python-scikit-learn" ,python-scikit-learn) | |
2131 | ("python-scipy" ,python-scipy))) | |
2132 | (home-page "https://github.com/lmcinnes/umap") | |
2133 | (synopsis | |
2134 | "Uniform Manifold Approximation and Projection") | |
2135 | (description | |
2136 | "Uniform Manifold Approximation and Projection is a dimension reduction | |
2137 | technique that can be used for visualisation similarly to t-SNE, but also for | |
2138 | general non-linear dimension reduction.") | |
2139 | (license license:bsd-3))) |