lambda-ml.ensemble

Ensemble learning methods.

Example usage:

(def data [[0 0 0] [0 1 1] [1 0 1] [1 1 0]])
(def tree
  (let [min-split 2
        min-leaf 1
        max-features 2]
    (make-classification-tree gini-impurity min-split min-leaf max-features)))
(def fit
  (let [rate 1.0]
    (-> (iterate #(add-bagging-estimator % tree decision-tree-fit decision-tree-predict)
                  (make-bagging-classifier rate))
        (nth 1001)
        (bagging-ensemble-fit data))))
(bagging-ensemble-predict fit (map butlast data))
;;=> (0 1 1 0)

add-bagging-estimator

(add-bagging-estimator ensemble model fit predict)

Adds a base estimator to an ensemble, where each estimator is defined by fit and predict functions used for training on then predicting from the provided model, respectively.

bagging-ensemble-fit

(bagging-ensemble-fit ensemble data)(bagging-ensemble-fit ensemble x y)

Fits an ensemble of estimators using bootstrap samples of the training data for each base estimators.

bagging-ensemble-predict

(bagging-ensemble-predict ensemble x)

Predicts the values of example data using a bagging ensemble.

make-bagging-classifier

(make-bagging-classifier rate)

Returns a classifier based on an ensemble of classifiers to be fit to random samples of training data, where rate is the percent of data used to create each bootstrap sample. Predictions are aggregated across classifiers by taking the mode of predicted values.

make-bagging-regressor

(make-bagging-regressor rate)

Returns a regressor based on an ensemble of regressors to be fit to random samples of training data, where rate is the percent of data used to create each bootstrap sample. Predictions are aggregated across regressors by taking the mean of predicted values.