Self-Organizing-Map Neural Network Library.
Self-Organizing-Map Neural Network Library.
(som-batch-train data
&
{:keys [alpha beta cycles] :or {alpha 0.5 beta 3 cycles 10}})
Performs BL-SOM (batch-learning self organizing map) learning on the given data, returning a hashmap containing resulting BL-SOM values.
Arguments: data -- data matrix
Options: :cycles -- number of cycles of learning :alpha -- initial value of alpha learning parameter :beta -- initial value of beta learning parameter
Returns: A hashmap containing the following fields:
:fit -- array of fitness values for each cycle of SOM learning :weights -- hashmap of weight vectors, keyed by lattice indices :sets -- hashmap mapping data elements to lattice nodes (key lattice index) (value list of row indices from data) :dims -- dimensions of SOM lattice :data-means -- column means of input data matrix
Examples:
(use '(incanter core som stats charts datasets)) (def data (to-matrix (sel (get-dataset :iris) :cols ["Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width"])))
(def som (som-batch-train data :cycles 10 :alpha 0.5 :beta 3))
;; plot the fitness for each cycle of training (view (xy-plot (range (count (:fit som))) (:fit som))) ;; view indices of data items in each cell (:sets som) ;; view the species in each cell (doseq [rws (vals (:sets som))] (println (sel (get-dataset :iris) :cols "Species" :rows rws) \newline))
;; plot the means of the data vectors in each cell/cluster (def cell-means (map #(map mean (trans (sel data :rows ((:sets som) %)))) (keys (:sets som)))) (def x (range (ncol data))) (doto (xy-plot x (first cell-means)) view (add-lines x (nth cell-means 1)) (add-lines x (nth cell-means 2)))
References:
Performs BL-SOM (batch-learning self organizing map) learning on the given data, returning a hashmap containing resulting BL-SOM values. Arguments: data -- data matrix Options: :cycles -- number of cycles of learning :alpha -- initial value of alpha learning parameter :beta -- initial value of beta learning parameter Returns: A hashmap containing the following fields: :fit -- array of fitness values for each cycle of SOM learning :weights -- hashmap of weight vectors, keyed by lattice indices :sets -- hashmap mapping data elements to lattice nodes (key lattice index) (value list of row indices from data) :dims -- dimensions of SOM lattice :data-means -- column means of input data matrix Examples: (use '(incanter core som stats charts datasets)) (def data (to-matrix (sel (get-dataset :iris) :cols ["Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width"]))) (def som (som-batch-train data :cycles 10 :alpha 0.5 :beta 3)) ;; plot the fitness for each cycle of training (view (xy-plot (range (count (:fit som))) (:fit som))) ;; view indices of data items in each cell (:sets som) ;; view the species in each cell (doseq [rws (vals (:sets som))] (println (sel (get-dataset :iris) :cols "Species" :rows rws) \newline)) ;; plot the means of the data vectors in each cell/cluster (def cell-means (map #(map mean (trans (sel data :rows ((:sets som) %)))) (keys (:sets som)))) (def x (range (ncol data))) (doto (xy-plot x (first cell-means)) view (add-lines x (nth cell-means 1)) (add-lines x (nth cell-means 2))) References: http://en.wikipedia.org/wiki/Self-organizing_map
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close