Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add model reference docu #61

Merged
merged 12 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -31,6 +31,5 @@
"updateContentCommand": {"install python packages": "mkdir -p .venv && poetry install --sync" ,
"add link to python executable": "sudo ln -s /usr/bin/python3 /usr/local/bin/python"
},
"onCreateCommand": "clojure -A:model-integration-tests:test -P"

"postStartCommand": "clojure -Sthreads 1 -P ; clojure -X:deps prep"
}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ jobs:
uses: devcontainers/ci@v0.3
with:
push: never
runCmd: clj -T:build ci
runCmd: clj -Sthreads 1 -T:build ci

make-doc:

@@ -54,7 +54,7 @@ jobs:
with:

push: never
runCmd: clj -A:dev -X dev/render-all-notebooks
runCmd: clj -Sthreads 1 -A:dev -X dev/render-all-notebooks

- name: fix permisions
run: sudo chmod o+w docs/
9 changes: 6 additions & 3 deletions build.clj
Original file line number Diff line number Diff line change
@@ -63,20 +63,23 @@

(def opts {})



(defn models-integration-tests "Run integration tests." [opts]
(let [basis (b/create-basis {:aliases [:model-integration-tests]})
cmds (b/java-command
{:basis basis
:main 'clojure.main
:main-args ["-m" "cognitect.test-runner"
"-d" "model-integration-tests"]})]
(b/process cmds))
"-d" "model-integration-tests"]})
{:keys [exit]} (b/process cmds)]
(when-not (zero? exit) (throw (ex-info "Integration tests failed" {}))))
opts)


(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(generate-tests nil)
(models-integration-tests nil)
(generate-tests nil)
(test (assoc opts :aliases [:dev :test]))
(b/delete {:path "target"})
(let [opts (jar-opts opts)]
15 changes: 12 additions & 3 deletions clay.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{:remote-repo {:git-url "https://github.com/scicloj/noj"
:branch "main"}
:quarto {:format {:html {:toc true
:toc-depth 4
:theme [:cosmo "notebooks/custom.scss"]}}
:page-layout :full
:quarto {:format {:html
{:toc true
:toc-depth 4
:theme [:cosmo "notebooks/custom.scss"]
;:page-layout :full
:grid
{:sidebar-width "500px"
:body-width "2500px"
:margin-width "500px"}

}}
:fontsize "0.9em"
:code-block-background true
:include-in-header {:text "<link rel = \"icon\" href = \"data:,\" />"}}
25 changes: 20 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
aerial.hanami/aerial.hanami {:mvn/version "0.20.1"}
org.scicloj/tableplot {:mvn/version "1-alpha14.1"}
org.scicloj/metamorph.ml {:mvn/version "0.10.3"}
org.scicloj/scicloj.ml.smile {:mvn/version "7.4.2"}
org.scicloj/scicloj.ml.smile {:mvn/version "7.4.3"}
org.scicloj/sklearn-clj {:mvn/version "0.4.1"}
org.scicloj/scicloj.ml.xgboost {:mvn/version "6.2.0"}

@@ -26,8 +26,8 @@

same/ish {:mvn/version "0.1.6"}

org.babashka/sci {:mvn/version "0.9.44"}
org.mentat/emmy-viewers {:mvn/version "0.3.2"}}
org.babashka/sci {:mvn/version "0.9.44"}
org.mentat/emmy-viewers {:mvn/version "0.3.2"}}
:aliases
{:gen-tests {:extra-paths ["build"]}

@@ -40,7 +40,8 @@
:extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}
io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}
org.slf4j/slf4j-nop {:mvn/version "2.0.16"}
org.scicloj/clay {:mvn/version "2-beta21"}}}
org.scicloj/clay {:mvn/version "2-beta21"}
clj-http/clj-http {:mvn/version "3.13.0"}}}

:model-integration-tests
{:extra-paths ["model-integration-tests" "notebooks"]
@@ -59,4 +60,18 @@


:dev {:extra-paths ["notebooks"]
:extra-deps {org.scicloj/clay {:mvn/version "2-beta21"}}}}}
:extra-deps {org.scicloj/clay {:mvn/version "2-beta21"}
same/ish {:mvn/version "0.1.6"}
clj-http/clj-http {:mvn/version "3.13.0"}
org.bytedeco/arpack-ng {:mvn/version "3.7.0-1.5.4"}
org.bytedeco/openblas-platform {:mvn/version "0.3.10-1.5.4"}
org.bytedeco/arpack-ng-platform {:mvn/version "3.7.0-1.5.4"}
org.bytedeco/openblas {:mvn/version "0.3.10-1.5.4"}
org.bytedeco/javacpp {:mvn/version "1.5.4"}
com.oracle.labs.olcut/olcut-config-edn {:mvn/version "5.1.4"}
com.oracle.labs.olcut/olcut-config-json {:mvn/version "5.1.4"}}}

:outdated {;; Note that it is `:deps`, not `:extra-deps`
:deps {com.github.liquidz/antq {:mvn/version "RELEASE"}}
:main-opts ["-m" "antq.core"]}
}}
63 changes: 43 additions & 20 deletions model-integration-tests/model_integration_test.clj
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
(ns model-integration-test
(:require [scicloj.metamorph.core :as mm]
[scicloj.metamorph.ml :as ml]
[scicloj.metamorph.ml.loss :as loss]
[scicloj.metamorph.ml.toydata :as data]
[tech.v3.dataset.categorical :as ds-cat]
[tablecloth.api :as tc]
[clojure.string :as str]
[clojure.set :as set]
[clojure.test :refer [is deftest]]
[tech.v3.dataset :as ds]
[taoensso.nippy :as nippy]
[libpython-clj2.python :as py])
(:require
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.string :as str]
[clojure.test :refer [deftest is]]
[libpython-clj2.python :as py]
[scicloj.metamorph.core :as mm]
[scicloj.metamorph.ml :as ml]
[scicloj.metamorph.ml.loss :as loss]
[scicloj.metamorph.ml.toydata :as data]
[tablecloth.api :as tc]
[taoensso.nippy :as nippy]
[tech.v3.dataset :as ds]
[tech.v3.dataset.categorical :as ds-cat])
(:import
[java.util.logging Logger]
[org.slf4j.bridge SLF4JBridgeHandler]
(smile.base.mlp ActivationFunction Cost HiddenLayerBuilder LayerBuilder OutputFunction OutputLayerBuilder)))
(smile.base.mlp
ActivationFunction
Cost
HiddenLayerBuilder
OutputFunction
OutputLayerBuilder)))

(py/initialize!)
(py/run-simple-string "
@@ -71,7 +77,7 @@ warnings.simplefilter('ignore')")

:sklearn.classification/complement-nb 0.65
:sklearn.classification/ridge-classifier 0.30
:sklearn.classification/extra-tree-classifier 0.91
:sklearn.classification/extra-tree-classifier 0.90
:sklearn.classification/dummy-classifier 0.2

:metamorph.ml/dummy-classifier 0.2})
@@ -265,17 +271,14 @@ warnings.simplefilter('ignore')")
(ds/assoc-metadata [:species] :categorical-map nil))]
(run!
#(verify-fn % iris)

(-> model-specs
;;https://github.com/scicloj/scicloj.ml.tribuo/issues/6
(remove-model-type :scicloj.ml.tribuo/classification)
;;https://github.com/scicloj/scicloj.ml.smile/issues/19
(remove-model-type :smile.classification/mlp)
;;https://github.com/scicloj/scicloj.ml.xgboost/issues/1
(remove-model-type :xgboost/classification)
))
)
)
(remove-model-type :xgboost/classification)))))

(deftest verify-classification-iris-nil-catmap-float
(let [iris
@@ -316,3 +319,23 @@ warnings.simplefilter('ignore')")
)


(comment
;; inspect trainer
(import '[ com.oracle.labs.mlrg.olcut.config DescribeConfigurable
ConfigurationManager]
'[com.oracle.labs.mlrg.olcut.config.edn EdnConfigFactory]
'[com.oracle.labs.mlrg.olcut.config.json JsonConfigFactory])


(ConfigurationManager/addFileFormatFactory (EdnConfigFactory.))

(ConfigurationManager/addFileFormatFactory (JsonConfigFactory.))


(DescribeConfigurable/writeExampleConfig
(io/output-stream "/tmp/sdg.edn")
"edn"
org.tribuo.classification.sgd.linear.LinearSGDTrainer
(DescribeConfigurable/generateFieldInfo org.tribuo.classification.sgd.linear.LinearSGDTrainer)
)
)
11 changes: 10 additions & 1 deletion notebooks/chapters.edn
Original file line number Diff line number Diff line change
@@ -19,4 +19,13 @@
"fastmath_vector_word_embeddings"
"fastmath_matrix_intro"]}
{:part "Use Cases"
:chapters ["chicago_bike_times"]}]
:chapters ["chicago_bike_times"]}

{:part "Model references"
:chapters ["smile_classification"
"smile_regression"
"smile_others"
"xgboost"
"sklearn_reference"
"transformer_references"]}
]
Loading