Last active
June 1, 2020 21:11
-
-
Save joycex99/fec2c0f9e6af8a8725e9152c277940e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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