Skip to content

Commit 1d430c0

Browse files
committed
updating example.
1 parent 215d0b1 commit 1d430c0

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

example/project.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:dependencies [[org.clojure/clojure "1.10.1-beta2"]
7-
[techascent/tech.ml "1.0-alpha3"]]
7+
[techascent/tech.ml "1.0-alpha4"]]
88

99
:profiles {:dev {:dependencies [[org.clojure/tools.logging "0.3.1"]
1010
[ch.qos.logback/logback-classic "1.1.3"]]}})

example/src/tech/ml/example/classify.clj

+18-12
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[tech.ml.dataset :as ml-dataset]
55
[tech.ml.loss :as loss]
66
[tech.libs.xgboost]
7+
[tech.v2.datatype :as dtype]
78
[tech.libs.smile.classification]
89
[tech.libs.svm]
9-
[clojure.core.matrix :as m]
1010
[taoensso.nippy :as nippy]
1111
[tech.io :as io]))
1212

@@ -27,17 +27,23 @@
2727
(ml-dataset/ds-concat train-ds test-ds)
2828
train-ds)]
2929
(->> base-systems
30-
(mapcat (fn [opts]
31-
(let [gs-options (ml/auto-gridsearch-options opts)]
32-
(println (format "Dataset: %s, Model: %s" name (:model-type opts)))
33-
(->> (ml/gridsearch (merge options gs-options
34-
{:k-fold (if (> (first (m/shape train-ds)) 200)
35-
5
36-
3)
37-
:gridsearch-depth 75})
38-
loss/classification-loss
39-
train-ds)
40-
(map (partial merge (dissoc base-dataset :test-ds :train-ds :options)))))))
30+
(mapcat
31+
(fn [opts]
32+
(let [gs-options (ml/auto-gridsearch-options opts)]
33+
(println (format "Dataset: %s, Model: %s"
34+
name (:model-type opts)))
35+
(->> (ml/gridsearch
36+
(merge options gs-options
37+
{:k-fold (if (> (first (dtype/shape train-ds))
38+
200)
39+
5
40+
3)
41+
:gridsearch-depth 75})
42+
loss/classification-loss
43+
train-ds)
44+
(map (partial merge (dissoc base-dataset
45+
:test-ds :train-ds
46+
:options)))))))
4147
(sort-by :average-loss)
4248
(take 15)))})))))
4349

example/src/tech/ml/example/svm_datasets.clj

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
[tech.ml.dataset.svm :as svm]
66
[tech.ml.dataset :as ds]
77
[tech.ml.dataset.pipeline :as dsp]
8+
[tech.ml.dataset.pipeline.pipeline-operators
9+
:refer [without-recording
10+
pipeline-train-context
11+
pipeline-inference-context]]
812
[tech.ml.dataset.column :as ds-col]
913
[tech.v2.datatype :as dtype]))
1014

@@ -36,11 +40,11 @@
3640
(time
3741
(let [{train-ds :dataset
3842
train-context :context}
39-
(dsp/pipeline-train-context
43+
(pipeline-train-context
4044
(-> (svm/parse-svm-file train-fname :label-map label-map)
4145
svm-pipeline))
4246
{test-ds :dataset} (when test-fname
43-
(dsp/pipeline-inference-context
47+
(pipeline-inference-context
4448
train-context
4549
(-> (svm/parse-svm-file test-fname :label-map label-map)
4650
svm-pipeline)))]

0 commit comments

Comments
 (0)