Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns fraud-detection.core
(:require [clojure.java.io :as io]
[clojure.string :as string]
[clojure.data.csv :as csv]
[clojure.core.matrix :as mat]
[clojure.core.matrix.stats :as matstats]
[cortex.nn.layers :as layers]
[cortex.nn.network :as network]
[cortex.nn.execute :as execute]
[cortex.optimize.adadelta :as adadelta]
[cortex.optimize.adam :as adam]
[cortex.metrics :as metrics]
[cortex.util :as util]
[cortex.experiment.util :as experiment-util]
[cortex.experiment.train :as experiment-train]))
(def orig-data-file "resources/creditcard.csv")
(def log-file "training.log")
(def network-file "trained-network.nippy")
;; Read input csv and create a vector of maps {:data [...] :label [..]},
;; where each map represents one training instance in the data
(defonce create-dataset
(memoize
(fn []
(let [credit-data (with-open [infile (io/reader orig-data-file)]
(rest (doall (csv/read-csv infile))))
data (mapv #(mapv read-string %) (map #(drop 1 %) (map drop-last credit-data))) ; drop label and time
labels (mapv #(util/idx->one-hot (read-string %) 2) (map last credit-data))
dataset (mapv (fn [d l] {:data d :label l}) data labels)]
dataset))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.