This repository is supposed to contain all my GNU Guile or Scheme machine learning algorithm implementations.
zelphir.kaltstahl 459e0564a1 remove todo, usage of car is OK here | 4 年之前 | |
---|---|---|
old-racket-code | 5 年之前 | |
scripts | 5 年之前 | |
test | 4 年之前 | |
utils | 4 年之前 | |
.gitignore | 5 年之前 | |
LICENSE | 7 年之前 | |
README.org | 5 年之前 | |
columns.csv | 7 年之前 | |
data-point.scm | 5 年之前 | |
data_banknote_authentication.csv | 7 年之前 | |
dataset.scm | 4 年之前 | |
decision-tree.scm | 4 年之前 | |
metrics.scm | 4 年之前 | |
notes.org | 4 年之前 | |
prediction.scm | 5 年之前 | |
pruning.scm | 4 年之前 | |
split-quality-measure.scm | 5 年之前 | |
todo.org | 4 年之前 | |
tree.scm | 4 年之前 | |
utils.scm | 5 年之前 |
You can run the tests by running the script run-tests.bash
in the scripts/
directory as follows:
# from the root directory of this project:
bash scripts/run-tests.bash
This example is outdated and still for the older Racket code.
(define shuffled-dataset (shuffle dataset))
(define small-dataset
(data-range shuffled-dataset
0
;; take only a fifth of the data to make this example run faster
(exact-floor (/ (dataset-length shuffled-dataset)
5))))
;; be sure to collect all garbage, apparently this should be called thrice
(collect-garbage)
(collect-garbage)
(collect-garbage)
;; requires a ~time~ macro
(time
;; ~for/list~ -- a Racketism, needs to be rewritten
(for/list ([i (in-range 1)])
(mean
(evaluate-algorithm #:dataset (shuffle dataset)
#:n-folds 10
#:feature-column-indices (list 0 1 2 3)
#:label-column-index 4
#:max-depth 5
#:min-data-points 24
#:min-data-points-ratio 0.02
#:min-impurity-split (expt 10 -7)
#:stop-at-no-impurity-improvement #t
#:random-seed 0))))
;; be sure to collect all garbage, apparently this should be called thrice
(collect-garbage)
(collect-garbage)
(collect-garbage)
(time
;; ~for/list~ -- a Racketism, needs to be rewritten
(for/list ([i (in-range 1)])
;; run with the whole dataset as an example, no random seed
(define tree (fit #:train-data dataset
#:feature-column-indices (list 0 1 2 3)
#:label-column-index 4
#:max-depth 5
#:min-data-points 12
#:min-data-points-ratio 0.02
#:min-impurity-split (expt 10 -7)
#:stop-at-no-impurity-improvement #t))
'done))