Database Reference
In-Depth Information
Clustering with SOMs in Incanter
Self-organizing maps (SOMs) are a type of neural network that cluster and categorize the
data without supervision. An SOM starts from a random set of groupings and competitively
updates the values in the network to eventually match those in the distribution of the training
data. In this way, it learns the clusters in the data by looking at the attributes of the data.
Incanter has an easy-to-use implementation of SOMs. We'll use it here to look for clusters in
the Iris dataset.
Getting ready
First, we'll need to have these dependencies in our project.clj ile:
(defproject d-mining "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.6.0"]
[incanter "1.5.5"]])
We'll also need to have these libraries loaded into our script or REPL:
(require '[incanter.core :as i]
'[incanter.som :as som]
'incanter.datasets)
We'll use the Iris dataset for this recipe:
(def iris (incanter.datasets/get-dataset :iris))
How to do it…
Incanter includes the SOM algorithm in its core library. We'll use it from there:
1.
To cluster this dataset, we'll use the incanter.som/som-batch-train function
on a matrix of our data. This time, we'll use all measurement attributes, so the SOM
will map the four-dimensional attribute vectors onto two dimensions:
(def iris-clusters
(som/som-batch-train
(i/to-matrix
(i/sel iris
:cols [:Sepal.Length :Sepal.Width
:Petal.Length :Petal.Width]))))
 
Search WWH ::




Custom Search