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
| (get-job-status "pi") | |
| ;;{:startTime "2020-09-15T08:33:44Z", :active 1} | |
| ;;wait for a few seconds | |
| (get-job-status "pi") | |
| ;;{:conditions [{:type "Complete", :status "True", :lastProbeTime "2020-09-15T08:33:55Z", | |
| ;;:lastTransitionTime "2020-09-15T08:33:55Z"}], :startTime "2020-09-15T08:33:44Z", | |
| ;;:completionTime "2020-09-15T08:33:55Z", :succeeded 1} |
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
| ;;set the REST endpoint for K8S | |
| (core/set-api-context {:base-url "http://localhost:8080"}) | |
| ;;create a job with the given spec. | |
| ;;we'll use the default K8s namespace. | |
| (create-namespaced-job "default" pi-job-spec) |
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 pi-job-spec | |
| {:apiVersion "batch/v1" | |
| :kind "Job" | |
| :metadata {:name "pi"} | |
| :spec {:ttlSecondsAfterFinished 200 | |
| :template | |
| {:spec | |
| {:containers | |
| [{:name "pi" | |
| :imagePullPolicy "Always" |
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
| (:require | |
| [confuse.binary-class-metrics :refer :all] | |
| [confuse.multi-class-metrics :refer :all]) | |
| ;;list of predicted labels: they could be numbers or keywords | |
| (def pred [1 0 1 1 0]) | |
| ;;list of actual labels/ground truth | |
| (def ac [1 1 1 1 0]) | |
| ;;assume the positive class is 1 | |
| (true-positives ac pred 1) |
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 ;... | |
| (:require [tfevent-sink.event-io :as eio])) | |
| (let [file-path "/tmp/run/tfevents.log" | |
| ;;create a scalar event with a name and value | |
| ev (eio/make-event "loss/mean-squared-error" (double 0.09))] | |
| ;;create and initialize the event stream | |
| (eio/create-event-stream file-path) | |
| ;;append event to stream | |
| (eio/append-events file-path [ev]) |
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
| print(__doc__) | |
| # Author: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> | |
| # Jan Hendrik Metzen <jhm@informatik.uni-bremen.de> | |
| # License: BSD Style. | |
| %matplotlib inline | |
| import matplotlib.pyplot as plt | |
| from sklearn import datasets |
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
| ;adds 2 children to a leaf node | |
| (defn add-children [{x :self :as m}] | |
| (assoc m :cren [ {:self (inc x)} {:self (dec x)}])) | |
| (def xroot {:self 20 :cren [ | |
| {:self 10 } | |
| {:self 30 } | |
| ]}) | |
| ;the nodes 10 and 30 now have 2 children: 11,9 and 31,29 |
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
| ;this returns the value of :self nodes from the root to the leaf | |
| (defn gpath [n] | |
| "returns that path from the parent till the leaf" | |
| (conj (vec (map :self (zip/path n))) (-> n zip/node :self))) | |
| ;path from root to leaf. | |
| (is (= '([20 10 11] [20 10 12] [20 30 31] [20 30 32]) | |
| (map (comp gpath) (leafnodes (mzipper mroot))))) |
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
| ;the root of the tree. | |
| ;each node has a :self key, the value of which is its own value, and a vector | |
| ;that contains children. | |
| (def mroot {:self 20 :cren [ | |
| {:self 10 :cren [{:self 11} {:self 12}]} | |
| {:self 30 :cren [{:self 31} {:self 32}]} | |
| ]}) | |
| ;create a zipper from the mroot tree. | |
| (defn mzipper [root] |
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
| ;a sample zipper | |
| (def v2 (zip/vector-zip [[2 3] [4]])) | |
| (defn editfn [x] | |
| "returns a vector with 2 numbers" | |
| (let [a (* x 10)] | |
| [(inc a) (dec a)])) | |
| (defn inext [node-edit loc ] | |
| "Adds children if loc is a leaf, else returns the next node" |