Skip to content

Instantly share code, notes, and snippets.

@Eleonore9
Created May 23, 2016 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eleonore9/534d7826eeb18c2a62e8455f0c07bc37 to your computer and use it in GitHub Desktop.
Save Eleonore9/534d7826eeb18c2a62e8455f0c07bc37 to your computer and use it in GitHub Desktop.
core.matrix clojure datasets

core.matrix datasets have 3 attributes than can be accessed by treating the dataset as a map.

Let's take this example dataset:

(def dataset-test
    (clojure.core.matrix.dataset/dataset [{:a 1 :b 11}
                                          {:a 2 :b 12}
                                          {:a 3 :b 13}]))
> dataset-test

| :a | :b |
|----+----|
|  1 | 11 |
|  2 | 12 |
|  3 | 13 |

You can use the keys function on a dataset:

> (keys dataset-test)

(:column-names :columns :shape)

You can access the column headers:

> (:column-names dataset-test)

[:a :b]

And the data content:

> (:columns dataset-test)

[[1 2 3] [11 12 13]]

The :shape returns the dimensions, so number of rows and number of columns:

> (:shape dataset-test)

[3 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment