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
(def params | |
{:optimizer (adam/adam) | |
:batch-size 100 | |
:epoch-count 50 | |
:epoch-size 200000}) | |
(defn train | |
[] | |
(let [network (network/linear-network network-description) | |
[train-orig test-ds] (get-train-test-dataset) |
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
(def num-features (count (:data (first (create-dataset)))) | |
(def network-description | |
[(layers/input num-features 1 1 :id :data) ;width, height, channels | |
(layers/linear->relu 20) ; num-output | |
(layers/dropout 0.9) | |
(layers/linear->relu 10) | |
(layers/linear 2) | |
(layers/softmax :id :label)]) |
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
(defn f-beta | |
"F-beta score, default uses F1" | |
([precision recall] (f-beta precision recall 1)) | |
([precision recall beta] | |
(let [beta-squared (* beta beta)] | |
(* (+ 1 beta-squared) | |
(try ;; catch divide by 0 errors | |
(/ (* precision recall) | |
(+ (* beta-squared precision) recall)) | |
(catch ArithmeticException e |
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
(defn train | |
"Trains network for :epoch-count number of epochs" | |
[] | |
(let [network (network/linear-network network-description) | |
[train-orig test-ds] (get-train-test-dataset) | |
train-ds (experiment-util/infinite-class-balanced-dataset train-orig | |
:class-key :label | |
:epoch-size (:epoch-size params))] | |
(experiment-train/train-n network train-ds test-ds | |
:batch-size (:batch-size params) |
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
(defonce get-scaled-variances | |
(memoize | |
(fn [] | |
(let [{positives true negatives false} (group-by #(= (:label %) [0.0 1.0]) (create-dataset)) | |
pos-data (mat/matrix (map #(:data %) positives)) | |
variances (mat/matrix (map #(matstats/variance %) (mat/columns pos-data))) | |
scaled-vars (mat/mul (/ 5000 (mat/length variances)) variances)] | |
scaled-vars)))) | |
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
(defn f-beta | |
"F-beta score, default uses F1" | |
([precision recall] (f-beta precision recall 1)) | |
([precision recall beta] | |
(let [beta-squared (* beta beta)] | |
(* (+ 1 beta-squared) | |
(try ;; catch divide by 0 errors | |
(/ (* precision recall) | |
(+ (* beta-squared precision) recall)) | |
(catch ArithmeticException e |
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
(def params | |
{:test-ds-size 50000 ;; total = 284807, test-ds ~= 17.5% | |
:optimizer (adam/adam) ;; alternately, (adadelta/adadelta) | |
:batch-size 100 | |
:epoch-count 50 | |
:epoch-size 200000}) | |
(def network-description | |
[(layers/input (count (:data (first (create-dataset)))) 1 1 :id :data) ;width, height, channels, args | |
(layers/linear->relu 20) ; num-output & args |
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] |
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
$(document).on('ready page:change', function() { | |
// $(document).on('flip', '#flashcard', function() { | |
// axis: 'x', | |
// trigger: 'click', | |
// speed: 400 | |
// }) | |
$('#flashcard').flip({ | |
axis: 'x', | |
trigger: 'click', |