Created
August 14, 2011 22:10
-
-
Save croach/1145372 to your computer and use it in GitHub Desktop.
Scatter Plot w/ Normalized Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns hooray-data.core | |
(:gen-class) | |
(:use (incanter core stats charts io)) | |
(:use [incanter.processing :only (norm)])) | |
(def data (read-dataset | |
"https://raw.github.com/liebke/incanter/master/data/iris.dat" | |
:delim \space | |
:header true)) | |
(defn normalize | |
"Normalizes a set of data" | |
[data] | |
(let [start (apply min data) | |
stop (apply max data)] | |
(map #(norm % start stop) data))) | |
(def plot (scatter-plot | |
(normalize (sel data :cols 0)) | |
(normalize (sel data :cols 1)) | |
:x-label "Sepal Length" | |
:y-label "Sepal Width" | |
:group-by (sel data :cols 4))) | |
(defn -main [& args] | |
(view plot)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment