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

minor editing of ml reference chapters and utils (wording, typos, sty… #114

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
33 changes: 15 additions & 18 deletions notebooks/noj_book/sklearn_reference.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
[noj-book.utils.render-tools-sklearn]
[scicloj.sklearn-clj.ml]))

;;## Sklearn model reference
;; ## Sklearn model reference

;;Below we find all sklearn models with their parameters and the original documentation.
;; Below we find all [sklearn](https://scikit-learn.org/stable/) models with their parameters and the original documentation.
;;
;;The parameters are given as Clojure keys in kebap-case. As the document texts are
;;imported from python they refer to the python spelling of the parameter.
;; The parameters are given as Clojure keys in kebab-case.
;; As the document texts are imported from Python, they refer to the
;; Python spelling of the parameter.
;;
;;But the translation between the two should be obvious.
;; But the translation between the two should be obvious.


;;Example: logistic regression
;;Example: [logistic regression](https://en.wikipedia.org/wiki/Logistic_regression)

(def ds (dst/tensor->dataset [[0 0 0] [1 1 1] [2 2 2]]))

;;Make pipe with sklearn model 'logistic-regression'
;; Make pipe with sklearn model 'logistic-regression'
(def pipe
(mm/pipeline
(ds-mm/set-inference-target 2)
Expand All @@ -35,29 +36,27 @@
:max-iter 100})))


;;Train model
;; Train model:
(def fitted-ctx
(pipe {:metamorph/data ds
:metamorph/mode :fit}))

;;Predict on new data
;; Predict on new data:
(->
(mm/transform-pipe
(dst/tensor->dataset [[3 4 5]])
pipe
fitted-ctx)
:metamorph/data)

;;Access model details via python interop (libpython-clj)
;; Access model details via Python interop
;; (using [libpython-clj](https://github.com/clj-python/libpython-clj)):
(-> fitted-ctx :model :model-data :model
(py.- coef_)
(->jvm))





;;All model attributes are as well in the context
;; All model attributes are also included in the context.

(def model-attributes
(-> fitted-ctx :model :model-data :attributes))
Expand All @@ -73,16 +72,14 @@





;;## :sklearn.classification models
;; ## `:sklearn.classification` models
^:kindly/hide-code
(render-key-info ":sklearn.classification" {:level "###"
:remove-s ":sklearn.classification"
:docu-doc-string-fn noj-book.utils.render-tools-sklearn/docu-doc-string})


;;## :sklearn.regression models
;; ## `:sklearn.regression` models
^:kindly/hide-code
(render-key-info ":sklearn.regression" {:level "###"
:remove-s ":sklearn.regression"})
Expand Down
7 changes: 3 additions & 4 deletions notebooks/noj_book/smile_classification.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


;; ## Smile classification models reference
;; In the following we have a list of all model keys of Smile classification models
;; including parameters.
;; In the following we have a list of all model keys of
;; [Smile](https://haifengl.github.io/) classification models, including parameters.
;; They can be used like this:

(comment
Expand All @@ -30,8 +30,7 @@
:param-1 0
:param-2 1}))



^:kindly/hide-code
(render-key-info :smile.classification)

;; # Compare decision surfaces of different classification models
Expand Down
7 changes: 4 additions & 3 deletions notebooks/noj_book/smile_others.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[scicloj.ml.smile.projections]
[noj-book.utils.render-tools :refer [render-key-info]]))

;; In the following we have a list of all model keys of Smile model-like
;; algorithms including parameters.
;; In the following we have a list of all model keys of
;; [Smile](https://haifengl.github.io/) model-like algorithms, including parameters.
;; They can be used in the same way as other models:
(comment
(ml/train df
Expand All @@ -22,7 +22,8 @@
:param-2 1}))

;; Some do not support `ml/predict` and are defined as `unsupervised` learners.
;; Clustering and PCA are in this group.
;; Clustering and [PCA](https://en.wikipedia.org/wiki/Principal_component_analysis)
;; are in this group.

;; ## Smile manifolds

Expand Down
4 changes: 2 additions & 2 deletions notebooks/noj_book/smile_regression.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
;; dependency to Noj.
;; [![Clojars Project](https://img.shields.io/clojars/v/org.scicloj/scicloj.ml.smile.svg)](https://clojars.org/org.scicloj/scicloj.ml.smile)

;; In the following we have a list of all model keys of Smile regression models
;; including parameters.
;; In the following we have a list of all model keys of
;; [Smile](https://haifengl.github.io/) regression models, including parameters.
;; They can be used like this:

(comment
Expand Down
Loading
Loading