XGBoost bindings for clojure.
(:require [tech.xgboost :as xgboost]
[tech.xgboost.dataset :as dataset]
[tech.xgboost.util :as util])
(let [f (partial * 2)
observe (fn []
(let [x (- (* 20 (rand)) 10)
y (f x)]
{:x x :y y}))
train-dataset (->> (repeatedly observe)
(take 1000))
test-dataset (for [x (range -9.9 10 0.1)] {:x x})
test-labels (map (comp f :x) test-dataset)
model (xgboost/train train-dataset [:x] :y :regression {})
test-output (xgboost/predict model test-dataset [:x])
mse (util/MSE test-output test-labels)]
(is (< mse 0.01)))
(let [f (partial * 2)
observe (fn []
(let [x (- (* 20 (rand)) 10)
y (f x)]
{:x x :y y}))
dataset (->> (repeatedly observe)
(take 1000))
feature-keys [:x]
label :y
train-fn #(xgboost/train % feature-keys label :regression {})
predict-fn #(xgboost/predict %1 %2 feature-keys)
mse (->> (dataset/dataset->k-fold-datasets dataset 10)
(dataset/average-prediction-error train-fn predict-fn
label util/MSE))]
(is (< mse 0.01)))
Copyright © 2018 Tech Ascent, LLC
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close