O'Reilly logo

Clojure for Data Science by Henry Garner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Matrices

A matrix is a two-dimensional grid of numbers. The dimensions are expressed as the number of rows and columns in the matrix.

For example, A is a matrix with four rows and two columns:

Matrices

In mathematical notation, a matrix will usually be assigned to a variable with an upper-case letter to distinguish it from other variables in an equation.

We can construct a matrix from our dataset using Incanter's incanter.core/to-matrix function:

(defn ex-3-16 []
  (->> (swimmer-data)
       (i/$ ["Height, cm" "Weight"])
       (i/to-matrix)))

Incanter also defines the incanter.core/matrix function that will take a sequence of scalar values or a sequence of sequences and convert ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required