2  Exploratory Data Analysis

(ns assignment.eda
  (:require
    [clojure.math.combinatorics :as combo]
    [fastmath.stats :as stats]
    [scicloj.kindly.v4.kind :as kind]
    [scicloj.ml.dataset :as ds]))

Load data

(defonce boston
         (ds/dataset "data/boston.csv"
                     {:key-fn (fn [colname]
                                (-> colname
                                    (clojure.string/replace #"\.|\s" "-")
                                    clojure.string/lower-case
                                    keyword))}))
(ds/info boston)

data/boston.csv: descriptive-stats [14 11]:

:col-name :datatype :n-valid :n-missing :min :mean :max :standard-deviation :skew :first :last
:crim :float64 506 0 0.00632 3.61352356 88.9762 8.60154511 5.22314880 0.00632 0.04741
:zn :float64 506 0 0.00000 11.36363636 100.0000 23.32245299 2.22566632 18.00000 0.00000
:indus :float64 506 0 0.46000 11.13677866 27.7400 6.86035294 0.29502157 2.31000 11.93000
:chas :int16 506 0 0.00000 0.06916996 1.0000 0.25399404 3.40590417 0.00000 0.00000
:nox :float64 506 0 0.38500 0.55469506 0.8710 0.11587768 0.72930792 0.53800 0.57300
:rm :float64 506 0 3.56100 6.28463439 8.7800 0.70261714 0.40361213 6.57500 6.03000
:age :float64 506 0 2.90000 68.57490119 100.0000 28.14886141 -0.59896264 65.20000 80.80000
:dis :float64 506 0 1.12960 3.79504269 12.1265 2.10571013 1.01178058 4.09000 2.50500
:rad :int16 506 0 1.00000 9.54940711 24.0000 8.70725938 1.00481465 1.00000 1.00000
:tax :float64 506 0 187.00000 408.23715415 711.0000 168.53711605 0.66995594 296.00000 273.00000
:ptratio :float64 506 0 12.60000 18.45553360 22.0000 2.16494552 -0.80232493 15.30000 21.00000
:b :float64 506 0 0.32000 356.67403162 396.9000 91.29486438 -2.89037371 396.90000 396.90000
:lstat :float64 506 0 1.73000 12.65306324 37.9700 7.14106151 0.90646009 4.98000 7.88000
:medv :float64 506 0 5.00000 22.53280632 50.0000 9.19710409 1.10809841 24.00000 11.90000
(def response :medv)
(def regressors
  (ds/column-names boston (complement #{response})))

2.1 Raw

2.1.1 Histograms

^kind/vega
(let [data (ds/rows boston :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:mark     "bar"
            :encoding {:x {:field {:repeat "column"} :type "quantitative"}
                       :y {:aggregate "count"}}}})

2.1.2 Box plots

^kind/vega
(let [data (ds/rows boston :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:width    60 :mark "boxplot"
            :encoding {:y {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}}}})

2.1.2.1 Outliers

(let [columns (ds/column-names boston)]
  (->> (for [column columns]
         (vector column (count (stats/outliers (get boston column)))))
       (sort-by first)))
([:age 0]
 [:b 76]
 [:chas 35]
 [:crim 66]
 [:dis 5]
 [:indus 0]
 [:lstat 6]
 [:medv 37]
 [:nox 0]
 [:ptratio 15]
 [:rad 0]
 [:rm 30]
 [:tax 0]
 [:zn 68])

2.1.3 Pairs plot

^kind/vega
(let [data (ds/rows boston :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names
            :row    column-names}
   :spec   {:height   100 :width 100
            :mark     "circle"
            :encoding {:x {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}
                       :y {:field {:repeat "row"} :type "quantitative" :scale {:zero false}}}}})
(let [combos (combo/combinations regressors 2)]
  (for [[x y] combos]
    (assoc {} [x y] (stats/correlation (get boston x) (get boston y)))))
({[:crim :zn] -0.20046921966254835}
 {[:crim :indus] 0.40658341140625986}
 {[:crim :chas] -0.0558915822222412}
 {[:crim :nox] 0.420971711392456}
 {[:crim :rm] -0.2192467028625141}
 {[:crim :age] 0.35273425090136357}
 {[:crim :dis] -0.3796700869510244}
 {[:crim :rad] 0.6255051452626016}
 {[:crim :tax] 0.5827643120325845}
 {[:crim :ptratio] 0.28994557927951986}
 {[:crim :b] -0.38506394199422395}
 {[:crim :lstat] 0.455621479447946}
 {[:zn :indus] -0.533828186304475}
 {[:zn :chas] -0.04269671929612136}
 {[:zn :nox] -0.5166037078279856}
 {[:zn :rm] 0.3119905873740921}
 {[:zn :age] -0.5695373420992128}
 {[:zn :dis] 0.6644082227621136}
 {[:zn :rad] -0.3119478260185376}
 {[:zn :tax] -0.31456332467760145}
 {[:zn :ptratio] -0.39167854793621854}
 {[:zn :b] 0.1755203173828281}
 {[:zn :lstat] -0.41299457452700544}
 {[:indus :chas] 0.06293802748966386}
 {[:indus :nox] 0.763651446920915}
 {[:indus :rm] -0.3916758526568436}
 {[:indus :age] 0.6447785113552554}
 {[:indus :dis] -0.7080269887427689}
 {[:indus :rad] 0.595129274603849}
 {[:indus :tax] 0.720760179951544}
 {[:indus :ptratio] 0.38324755642888625}
 {[:indus :b] -0.3569765351041923}
 {[:indus :lstat] 0.6037997164766225}
 {[:chas :nox] 0.09120280684249404}
 {[:chas :rm] 0.09125122504345609}
 {[:chas :age] 0.08651777425454238}
 {[:chas :dis] -0.09917578017472707}
 {[:chas :rad] -0.007368240886077562}
 {[:chas :tax] -0.035586517585911116}
 {[:chas :ptratio] -0.12151517365806137}
 {[:chas :b] 0.048788484955166224}
 {[:chas :lstat] -0.05392929837569404}
 {[:nox :rm] -0.30218818784959306}
 {[:nox :age] 0.7314701037859584}
 {[:nox :dis] -0.7692301132258255}
 {[:nox :rad] 0.6114405634855762}
 {[:nox :tax] 0.6680232004030203}
 {[:nox :ptratio] 0.18893267711276662}
 {[:nox :b] -0.3800506377923997}
 {[:nox :lstat] 0.5908789208808451}
 {[:rm :age] -0.24026493104775154}
 {[:rm :dis] 0.20524621293005493}
 {[:rm :rad] -0.209846667766109}
 {[:rm :tax] -0.29204783262321915}
 {[:rm :ptratio] -0.3555014945590849}
 {[:rm :b] 0.12806863509254304}
 {[:rm :lstat] -0.6138082718663951}
 {[:age :dis] -0.7478805408686319}
 {[:age :rad] 0.4560224517516138}
 {[:age :tax] 0.5064555935507052}
 {[:age :ptratio] 0.2615150116719574}
 {[:age :b] -0.27353397663851303}
 {[:age :lstat] 0.6023385287262405}
 {[:dis :rad] -0.4945879296720756}
 {[:dis :tax] -0.5344315844084555}
 {[:dis :ptratio] -0.23247054240825632}
 {[:dis :b] 0.29151167313303966}
 {[:dis :lstat] -0.49699583086368515}
 {[:rad :tax] 0.9102281885331837}
 {[:rad :ptratio] 0.4647411785030557}
 {[:rad :b] -0.4444128155751258}
 {[:rad :lstat] 0.4886763349750665}
 {[:tax :ptratio] 0.46085303506566544}
 {[:tax :b] -0.44180800672281295}
 {[:tax :lstat] 0.5439934120015688}
 {[:ptratio :b] -0.1773833023052315}
 {[:ptratio :lstat] 0.37404431671467575}
 {[:b :lstat] -0.36608690169159663})
(for [[x y] (mapv (fn [r] [response r]) regressors)]
  (assoc {} [x y] (stats/correlation (get boston x) (get boston y))))
({[:medv :crim] -0.3883046085868113}
 {[:medv :zn] 0.36044534245054505}
 {[:medv :indus] -0.4837251600283735}
 {[:medv :chas] 0.17526017719029746}
 {[:medv :nox] -0.42732077237328153}
 {[:medv :rm] 0.6953599470715387}
 {[:medv :age] -0.376954565004596}
 {[:medv :dis] 0.2499287340859039}
 {[:medv :rad] -0.38162623063977785}
 {[:medv :tax] -0.4685359335677658}
 {[:medv :ptratio] -0.507786685537561}
 {[:medv :b] 0.3334608196570662}
 {[:medv :lstat] -0.7376627261740145})

2.2 Standardized

(defn standardize-column [dataset]
  (reduce (fn [acc key]
            (assoc acc key (stats/standardize (get dataset key))))
          {}
          (keys dataset)))
(def boston-std
  (-> (standardize-column boston)
      ds/dataset
      (ds/add-columns {:chas (:chas boston)})
                       ;:zn   (:zn boston)})
      (ds/reorder-columns regressors response)))
(ds/info boston-std)

_unnamed: descriptive-stats [14 11]:

:col-name :datatype :n-valid :n-missing :min :mean :max :standard-deviation :skew :first :last
:crim :float64 506 0 -0.41936693 3.02020157E-16 9.92410961 1.00000000 5.22314880 -0.41936693 -0.41458988
:zn :float64 506 0 -0.48724019 -9.08364293E-16 3.80047346 1.00000000 2.22566632 0.28454827 -0.48724019
:indus :float64 506 0 -1.55630166 1.02410395E-15 2.42017014 1.00000000 0.29502157 -1.28663623 0.11562398
:chas :int16 506 0 0.00000000 6.91699605E-02 1.00000000 0.25399404 3.40590417 0.00000000 0.00000000
:nox :float64 506 0 -1.46443272 7.47535542E-16 2.72964520 1.00000000 0.72930792 -0.14407485 0.15796779
:rm :float64 506 0 -3.87641323 -1.01587601E-16 3.55152964 1.00000000 0.40361213 0.41326292 -0.36240845
:age :float64 506 0 -2.33312816 -1.64010220E-16 1.11638970 1.00000000 -0.59896264 -0.11989477 0.43430172
:dis :float64 506 0 -1.26581653 -1.07950539E-16 3.95660220 1.00000000 1.01178058 0.14007498 -0.61264021
:rad :float64 506 0 -0.98187119 -5.98335610E-16 1.65960290 1.00000000 1.00481465 -0.98187119 -0.98187119
:tax :float64 506 0 -1.31269099 -2.01727085E-15 1.79641644 1.00000000 0.66995594 -0.66594918 -0.80241764
:ptratio :float64 506 0 -2.70470251 1.21992886E-15 1.63720813 1.00000000 -0.80232493 -1.45755797 1.17530274
:b :float64 506 0 -3.90333053 5.07279769E-16 0.44061589 1.00000000 -2.89037371 0.44061589 0.44061589
:lstat :float64 506 0 -1.52961338 -6.86758511E-17 3.54526238 1.00000000 0.90646009 -1.07449897 -0.66839688
:medv :float64 506 0 -1.90633988 -1.44372876E-16 2.98650460 1.00000000 1.10809841 0.15952779 -1.15610373

2.2.1 Histogram

^kind/vega
(let [data (ds/rows boston-std :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:mark     "bar"
            :encoding {:x {:field {:repeat "column"} :type "quantitative"}
                       :y {:aggregate "count"}}}})

2.2.2 Box plots

^kind/vega
(let [data (ds/rows boston-std :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:width    60 :mark "boxplot"
            :encoding {:y {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}}}})

2.2.2.1 Outliers

(let [columns (ds/column-names boston-std)]
  (->> (for [column columns]
         (vector column (count (stats/outliers (get boston-std column)))))
       (sort-by first)))
([:age 0]
 [:b 76]
 [:chas 35]
 [:crim 66]
 [:dis 5]
 [:indus 0]
 [:lstat 6]
 [:medv 37]
 [:nox 0]
 [:ptratio 15]
 [:rad 0]
 [:rm 30]
 [:tax 0]
 [:zn 68])

2.2.3 Pairs plot

^kind/vega
(let [data (ds/rows boston-std :as-maps)
      column-names (ds/column-names boston-std)]
  {:data   {:values data}
   :repeat {:column column-names
            :row    column-names}
   :spec   {:height   100 :width 100
            :mark     "circle"
            :encoding {:x {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}
                       :y {:field {:repeat "row"} :type "quantitative" :scale {:zero false}}}}})
(let [combos (combo/combinations regressors 2)]
  (for [[x y] combos]
    (assoc {} [x y] (stats/correlation (get boston-std x) (get boston-std y)))))
({[:crim :zn] -0.20046921966254683}
 {[:crim :indus] 0.40658341140626064}
 {[:crim :chas] -0.055891582222241186}
 {[:crim :nox] 0.4209717113924561}
 {[:crim :rm] -0.21924670286251396}
 {[:crim :age] 0.35273425090136373}
 {[:crim :dis] -0.3796700869510246}
 {[:crim :rad] 0.6255051452626031}
 {[:crim :tax] 0.5827643120325842}
 {[:crim :ptratio] 0.28994557927951975}
 {[:crim :b] -0.3850639419942241}
 {[:crim :lstat] 0.4556214794479463}
 {[:zn :indus] -0.5338281863044668}
 {[:zn :chas] -0.04269671929612131}
 {[:zn :nox] -0.516603707827982}
 {[:zn :rm] 0.31199058737408947}
 {[:zn :age] -0.5695373420992095}
 {[:zn :dis] 0.6644082227621083}
 {[:zn :rad] -0.31194782601853516}
 {[:zn :tax] -0.3145633246775966}
 {[:zn :ptratio] -0.39167854793621293}
 {[:zn :b] 0.1755203173828273}
 {[:zn :lstat] -0.41299457452700256}
 {[:indus :chas] 0.0629380274896644}
 {[:indus :nox] 0.7636514469209154}
 {[:indus :rm] -0.3916758526568448}
 {[:indus :age] 0.6447785113552571}
 {[:indus :dis] -0.7080269887427696}
 {[:indus :rad] 0.5951292746038497}
 {[:indus :tax] 0.7207601799515443}
 {[:indus :ptratio] 0.3832475564288881}
 {[:indus :b] -0.35697653510419314}
 {[:indus :lstat] 0.6037997164766231}
 {[:chas :nox] 0.09120280684249471}
 {[:chas :rm] 0.09125122504345615}
 {[:chas :age] 0.0865177742545422}
 {[:chas :dis] -0.09917578017472727}
 {[:chas :rad] -0.007368240886077667}
 {[:chas :tax] -0.035586517585911255}
 {[:chas :ptratio] -0.12151517365806104}
 {[:chas :b] 0.048788484955166314}
 {[:chas :lstat] -0.05392929837569403}
 {[:nox :rm] -0.30218818784959417}
 {[:nox :age] 0.7314701037859582}
 {[:nox :dis] -0.7692301132258271}
 {[:nox :rad] 0.6114405634855784}
 {[:nox :tax] 0.6680232004030221}
 {[:nox :ptratio] 0.1889326771127674}
 {[:nox :b] -0.3800506377924003}
 {[:nox :lstat] 0.5908789208808459}
 {[:rm :age] -0.24026493104775165}
 {[:rm :dis] 0.205246212930055}
 {[:rm :rad] -0.20984666776610972}
 {[:rm :tax] -0.29204783262321976}
 {[:rm :ptratio] -0.35550149455908475}
 {[:rm :b] 0.12806863509254324}
 {[:rm :lstat] -0.6138082718663952}
 {[:age :dis] -0.7478805408686319}
 {[:age :rad] 0.4560224517516153}
 {[:age :tax] 0.506455593550705}
 {[:age :ptratio] 0.2615150116719573}
 {[:age :b] -0.273533976638513}
 {[:age :lstat] 0.60233852872624}
 {[:dis :rad] -0.4945879296720768}
 {[:dis :tax] -0.534431584408456}
 {[:dis :ptratio] -0.2324705424082561}
 {[:dis :b] 0.29151167313304}
 {[:dis :lstat] -0.4969958308636854}
 {[:rad :tax] 0.9102281885331902}
 {[:rad :ptratio] 0.46474117850305796}
 {[:rad :b] -0.44441281557512635}
 {[:rad :lstat] 0.488676334975068}
 {[:tax :ptratio] 0.4608530350656655}
 {[:tax :b] -0.44180800672281373}
 {[:tax :lstat] 0.5439934120015695}
 {[:ptratio :b] -0.17738330230523172}
 {[:ptratio :lstat] 0.37404431671467586}
 {[:b :lstat] -0.366086901691597})
(for [[x y] (mapv (fn [r] [response r]) regressors)]
  (assoc {} [x y] (stats/correlation (get boston-std x) (get boston-std y))))
({[:medv :crim] -0.38830460858681176}
 {[:medv :zn] 0.36044534245054255}
 {[:medv :indus] -0.48372516002837435}
 {[:medv :chas] 0.1752601771902975}
 {[:medv :nox] -0.4273207723732826}
 {[:medv :rm] 0.695359947071539}
 {[:medv :age] -0.3769545650045961}
 {[:medv :dis] 0.24992873408590385}
 {[:medv :rad] -0.3816262306397786}
 {[:medv :tax] -0.4685359335677664}
 {[:medv :ptratio] -0.5077866855375611}
 {[:medv :b] 0.3334608196570666}
 {[:medv :lstat] -0.7376627261740148})

2.3 Tukey’s Ladder Transformation

(defn box-cox-transform [data lambda]
  (map #(if (== lambda 0.0)
          (Math/log %)
          (/ (- (Math/pow (+ % 1) lambda) 1) lambda)) data))
(defn skewness-diff [data lambda]
  (let [transformed-data (box-cox-transform data lambda)]
    (Math/abs (stats/skewness transformed-data))))
(defn find-optimal-lambda [data start-lambda end-lambda step]
  (let [lambdas (range start-lambda (+ end-lambda step) step)
        skewnesses (map #(skewness-diff data %) lambdas)
        paired (map vector lambdas skewnesses)
        sorted (sort-by second paired)]
    (first (first sorted))))
(defn box-cox-optimal [data]
  (let [optimal-lambda (find-optimal-lambda data -2 5 0.5)]
    (box-cox-transform data optimal-lambda)))
(defn apply-find-optimal-lambda [dataset]
  (let [columns (keys dataset)]
    (map vector columns
         (map #(find-optimal-lambda (get dataset %) -2 5 0.5) columns))))
(apply-find-optimal-lambda boston)
([:crim -2]
 [:zn -2]
 [:indus 0.5]
 [:chas 3.0]
 [:nox -2]
 [:rm 0.5]
 [:age 2.5]
 [:dis -0.5]
 [:rad -0.5]
 [:tax -0.5]
 [:ptratio 5.0]
 [:b 5.0]
 [:lstat 0.0]
 [:medv 0.0])
(defn apply-box-cox-to-dataset [dataset]
  (reduce (fn [acc key]
            (assoc acc key (box-cox-optimal (get dataset key))))
          {}
          (keys dataset)))
(def boston-transformed
  (-> (apply-box-cox-to-dataset boston)
      ds/dataset
      (ds/add-columns {:chas (:chas boston)})
      (ds/reorder-columns regressors response)))
(ds/info boston-transformed)

_unnamed: descriptive-stats [14 11]:

:col-name :datatype :n-valid :n-missing :min :mean :max :standard-deviation :skew :first :last
:crim :float64 506 0 0.00626059 2.45927040E-01 4.99938239E-01 1.85043280E-01 0.27134793 6.26058731E-03 4.42396159E-02
:zn :float64 506 0 -0.00000000 1.32229892E-01 4.99950985E-01 2.20535691E-01 1.06917139 4.98614958E-01 -0.00000000E+00
:indus :float64 506 0 0.41660919 4.66021654E+00 8.72194012E+00 2.04863970E+00 -0.01752462 1.63868108E+00 5.19166184E+00
:chas :int16 506 0 0.00000000 6.91699605E-02 1.00000000E+00 2.53994041E-01 3.40590417 0.00000000E+00 0.00000000E+00
:nox :float64 506 0 0.23934236 2.89865233E-01 3.57169016E-01 2.94150209E-02 0.32351969 2.88623193E-01 2.97925013E-01
:rm :float64 506 0 2.27129957 3.39178041E+00 4.25459831E+00 2.59566289E-01 0.12229390 3.50454358E+00 3.30282943E+00
:age :float64 506 0 11.61493730 2.08551747E+04 4.10071125E+04 1.45869423E+04 -0.05103482 1.42624057E+04 2.42067271E+04
:dis :float64 506 0 0.62949389 1.02557343E+00 1.44797910E+00 1.94335417E-01 0.03813275 1.11351559E+00 9.31717819E-01
:rad :float64 506 0 0.58578644 1.23565978E+00 1.60000000E+00 2.60225327E-01 -0.14249984 5.85786438E-01 5.85786438E-01
:tax :float64 506 0 1.85413501 1.89512400E+00 1.92504683E+00 1.99889787E-02 0.09487930 1.88394823E+00 1.87917558E+00
:ptratio :float64 506 0 93051.54835200 6.21378353E+05 1.28726840E+06 2.80727081E+05 -0.15816450 2.30127034E+05 1.03072620E+06
:b :float64 506 0 0.60149285 1.57854194E+12 1.99480152E+12 6.06075831E+11 -1.67980129 1.99480152E+12 1.99480152E+12
:lstat :float64 506 0 0.54812141 2.37096517E+00 3.63679637E+00 6.00891347E-01 -0.32023236 1.60542989E+00 2.06432790E+00
:medv :float64 506 0 1.60943791 3.03451287E+00 3.91202301E+00 4.08756850E-01 -0.33032130 3.17805383E+00 2.47653840E+00

2.3.1 Histogram

^kind/vega
(let [data (ds/rows boston-transformed :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:mark     "bar"
            :encoding {:x {:field {:repeat "column"} :type "quantitative"}
                       :y {:aggregate "count"}}}})

2.3.2 Box plots

^kind/vega
(let [data (ds/rows boston-transformed :as-maps)
      column-names (ds/column-names boston)]
  {:data   {:values data}
   :repeat {:column column-names}
   :spec   {:width    60 :mark "boxplot"
            :encoding {:y {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}}}})

2.3.2.1 Outliers

(let [columns (ds/column-names boston-transformed)]
  (->> (for [column columns]
         (vector column (count (stats/outliers (get boston-transformed column)))))
       (sort-by first)))
([:age 0]
 [:b 67]
 [:chas 35]
 [:crim 0]
 [:dis 0]
 [:indus 0]
 [:lstat 1]
 [:medv 44]
 [:nox 0]
 [:ptratio 0]
 [:rad 0]
 [:rm 28]
 [:tax 0]
 [:zn 0])

2.3.3 Pairs plot

^kind/vega
(let [data (ds/rows boston-transformed :as-maps)
      column-names (ds/column-names boston-transformed)]
  {:data   {:values data}
   :repeat {:column column-names
            :row    column-names}
   :spec   {:height   100 :width 100
            :mark     "circle"
            :encoding {:x {:field {:repeat "column"} :type "quantitative" :scale {:zero false}}
                       :y {:field {:repeat "row"} :type "quantitative" :scale {:zero false}}}}})
(let [combos (combo/combinations regressors 2)]
  (for [[x y] combos]
    (assoc {} [x y] (stats/correlation (get boston-transformed x) (get boston-transformed y)))))
({[:crim :zn] -0.5105641892076437}
 {[:crim :indus] 0.743010910817299}
 {[:crim :chas] 0.054150835555214834}
 {[:crim :nox] 0.8311402996331614}
 {[:crim :rm] -0.27847992735918314}
 {[:crim :age] 0.7015918271916508}
 {[:crim :dis] -0.7305004961179902}
 {[:crim :rad] 0.7680728328007305}
 {[:crim :tax] 0.7701082778321043}
 {[:crim :ptratio] 0.40666144159896234}
 {[:crim :b] -0.5183504671015879}
 {[:crim :lstat] 0.5474925478406114}
 {[:zn :indus] -0.6143250343664309}
 {[:zn :chas] -0.04003189748024347}
 {[:zn :nox] -0.5715139911211056}
 {[:zn :rm] 0.3249455295461817}
 {[:zn :age] -0.5210712235434612}
 {[:zn :dis] 0.6029262254163189}
 {[:zn :rad] -0.3250417154737229}
 {[:zn :tax] -0.3870515381451609}
 {[:zn :ptratio] -0.454487267993871}
 {[:zn :b] 0.25407750560207026}
 {[:zn :lstat] -0.45395969602198}
 {[:indus :chas] 0.0727317125575729}
 {[:indus :nox] 0.7835652166514265}
 {[:indus :rm] -0.4142985855828567}
 {[:indus :age] 0.6868895231366665}
 {[:indus :dis] -0.7615905027618245}
 {[:indus :rad] 0.5611816622736608}
 {[:indus :tax] 0.6890466202424106}
 {[:indus :ptratio] 0.44794754412995064}
 {[:indus :b] -0.41036752656422326}
 {[:indus :lstat] 0.6148435777111986}
 {[:chas :nox] 0.0813852845913243}
 {[:chas :rm] 0.08812425037209316}
 {[:chas :age] 0.07389099185556593}
 {[:chas :dis] -0.083847583069467}
 {[:chas :rad] 0.01999743519584064}
 {[:chas :tax] -0.03744155234144554}
 {[:chas :ptratio] -0.1325775015352095}
 {[:chas :b] 0.022082956805703446}
 {[:chas :lstat] -0.07407404910541232}
 {[:nox :rm] -0.3109657505922806}
 {[:nox :age] 0.785651042751661}
 {[:nox :dis] -0.8657286666848344}
 {[:nox :rad] 0.5958863092468799}
 {[:nox :tax] 0.6557264196985978}
 {[:nox :ptratio] 0.31668153029955065}
 {[:nox :b] -0.4300725790944919}
 {[:nox :lstat] 0.5935070355404587}
 {[:rm :age] -0.26837603514989583}
 {[:rm :dis] 0.2733638209446309}
 {[:rm :rad] -0.1989838269215972}
 {[:rm :tax] -0.30265060889326995}
 {[:rm :ptratio] -0.34224901707289446}
 {[:rm :b] 0.18082155644479542}
 {[:rm :lstat] -0.6605489881945913}
 {[:age :dis] -0.8001790973387969}
 {[:age :rad] 0.45282353561713423}
 {[:age :tax] 0.528536979991229}
 {[:age :ptratio] 0.339347666914494}
 {[:age :b] -0.34243782793026345}
 {[:age :lstat] 0.6116797051194823}
 {[:dis :rad] -0.525617896233155}
 {[:dis :tax] -0.5899094698886381}
 {[:dis :ptratio] -0.30254593122872236}
 {[:dis :b] 0.3690696817468582}
 {[:dis :lstat] -0.5281889332623918}
 {[:rad :tax] 0.7641410271406073}
 {[:rad :ptratio] 0.3960447147457996}
 {[:rad :b] -0.38686192234971584}
 {[:rad :lstat] 0.4216291870618736}
 {[:tax :ptratio] 0.4565123256537465}
 {[:tax :b] -0.44131954028092674}
 {[:tax :lstat] 0.5034118402479983}
 {[:ptratio :b] -0.17420580494139318}
 {[:ptratio :lstat] 0.44631216633682336}
 {[:b :lstat] -0.35768866699304963})
(for [[x y] (mapv (fn [r] [response r]) regressors)]
  (assoc {} [x y] (stats/correlation (get boston-transformed x) (get boston-transformed y))))
({[:medv :crim] -0.4981925270028174}
 {[:medv :zn] 0.3913555887562702}
 {[:medv :indus] -0.5555513807589508}
 {[:medv :chas] 0.15841193932131697}
 {[:medv :nox] -0.5161113158028653}
 {[:medv :rm] 0.624388485108797}
 {[:medv :age] -0.4818999110098996}
 {[:medv :dis] 0.41369278110870245}
 {[:medv :rad] -0.40686632997350697}
 {[:medv :tax] -0.549153366152996}
 {[:medv :ptratio] -0.5177849500408633}
 {[:medv :b] 0.3745312472179234}
 {[:medv :lstat] -0.8229600313319908})
source: src/assignment/eda.clj