Incanter 2.0 change log

Aleksandr Sorokoumov edited this page Aug 16, 2014 · 5 revisions

Incanter 2.0 change log

API changes

Generally, most of the API changes relates to the fact, that Incanter is now based on clojure.core.matrix and therefore uses its behaviour in relation to matrices and datasets.

Matrix

  • It is possible to change current matrix implementation using (set-current-implementation) function. Please use Protocol/Implementation summary of available implementation for more details.
  • vectorz is used as a default matrix implementation, which does not depend on native libraries.
  • incanter.core/matrix called on seq will produce vector object instead of row-matrix.

    Example (using clatrix implementation):

    Incanter 1.5:

    => (matrix [1 2 3]) ;; clatrix.core.Matrix
    A 3x1 matrix
    -------------
     1.00e+00
     2.00e+00
     3.00e+00

    Incanter 2.0:

    => (matrix [1 2 3]) ;; clatrix.core.Vector
    (1.0 2.0 3.0) 
  • Matrices are not treated as sequences anymore, so calling first, rest, map, reduce, filter, etc on matrices is not generally supported (although might still work on some implementations, e.g. clatrix).

  • vec? is introduced. It tests whether an argument is a clojure.core.matrix vector.

    Example:

    (vec? (matrix [1 2 3]))   ;; true
    (vec? (matrix [[1 2 3]])) ;; false
  • API of the following functions is changes: decomp-cholesky, decomp-svd, decomp-eigenvalue, decomp-lu, decomp-qr. New API is described here
  • with-meta is not guaranteed to work on all matrix implementations.

Dataset

  • clojure.core.matrix column-based implementation of dataset is used now.
  • incanter.core/dataset API is changed. Now it accepts column names and seq of rows, matrix, map of columns or seq of row maps as arguments.
  • Incrementing integers (.e.g 0, 1, 2, ...) are now used as default column names.

    Example:

    Incanter 1.5

    => (to-dataset [[1 2 3] [4 5 6]])
    
    | :col-0 | :col-1 | :col-2 |
    |--------+--------+--------|
    |      1 |      2 |      3 |
    |      4 |      5 |      6 |

    Incanter 2.0

    => (to-dataset [[1 2 3] [4 5 6]])
    
    | 0 | 1 | 2 |
    |---+---+---|
    | 1 | 2 | 3 |
    | 4 | 5 | 6 |
  • Dataset is also a matrix now. Matrix functions work on datasets, (matrix? ds) will return true.

    Example:

    user=> (mult (to-dataset [[1 2 3] [4 5 6]]) 3)
    [[3 6 9] [12 15 18]]
    user=> (mult (to-dataset [[1 2 3] [4 5 6]]) [9 9 9])
    [[9 18 27] [36 45 54]]
  • incanter.core/sel does not support automatic cast between strings and keywords anymore.
  • 2 arguments version of incanter.core/col-names removed. Please use clojure.core.matrix.dataset/select-columns instead.

Deprecated functions

Matrix

  • incanter.core/dim is deprecated. Please use clojure.core.matrix/shape instead.
  • incanter.core/identity-matrix is deprecated. Please use clojure.core.matrix/identity-matrix instead.
  • incanter.core/diag is deprecated. Please use clojure.core.matrix/main-diagonal for getting elements on main diagonal and clojure.core.matrix/diagonal-matrix for creating diagonal matrix.
  • incanter.core/trans is deprecated. Please use clojure.core.matrix/transpose instead.
  • incanter.core/inner-product in deprecated. Please use clojure.core.matrix/inner-product instead.
  • incanter.core/plus is deprecated. Please use clojure.core.matrix/add or clojure.core.matrix.operators/+ instead.
  • incanter.core/minus is deprecated. Please use clojure.core.matrix/sub or clojure.core.matrix.operators/- instead.
  • incanter.core/mult is deprecated. Please use clojure.core.matrix/emul or clojure.core.matrix.operators/ instead.
  • incanter.core/div is deprecated. Please use clojure.core.matrix/div or clojure.core.matrix.operators// instead.
  • incanter.core/mmult is deprecated. Please use clojure.core.matrix/mmul instead.
  • incanter.core/det is deprecated. Please use clojure.core.matrix/det instead.
  • incanter.core/trace is deprecated. Please use clojure.core.matrix/trace instead.
  • incanter.core/sum-of-squares is deprecated. Please use clojure.core.matrix/length-squared instead.
  • incanter.core/sum is deprecated. Please use clojure.core.matrix/esum instead.
  • incanter.core/vector-length is deprecated. Please use clojure.core.matrix/length instead.
  • incanter.core/inner-product is deprecated. Please use clojure.core.matrix/inner-product instead.
  • incanter.core/length is deprecated. Please use clojure.core.matrix/ecount instead.
  • incanter.core/rank is deprecated. Please use clojure.core.matrix.linear/rank instead.
  • incanter.core/matrix-map is deprecated. Please use clojure.core.matrix/emap instead.
  • incanter.core/solve is deprecated. Please use clojure.core.matrix/inverse for matrix inverse, clojure.core.matrix.linear/solve for solving system of linear equations and clojure.core.matrix.linear/least-squares for least-squares solution.
  • incanter.core/decomp-cholesky is deprecated. Please use clojure.core.matrix.linear/cholesky instead.
  • incanter.core/decomp-svd is deprecated. Please use clojure.core.matrix.linear/svd instead.
  • incanter.core/decomp-lu is deprecated. Please use clojure.core.matrix.linear/lu instead.
  • incanter.core/decomp-qr is deprecated. Please use clojure.core.matrix.linear/qr instead.

Dataset

  • incanter.core/col-names is deprecated. Please use clojure.core.matrix.dataset/column-names instead.
  • incanter.core/conj-rows is deprecated. Please use clojure.core.matrix.dataset/join-rows instead.
  • incanter.core/transform-col is deprecated. Please use clojure.core.matrix.dataset/update-column instead.
  • incanter.core/reorder-columns is deprecated. Please use clojure.core.matrix.dataset/select-columns instead.