| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
LightGBM
Description
A simple wrapper around the Microsoft LightGBM library. Documentation for the various library parameters (see LightGBM.Parameters) can be found here.
N.B. The lightgbm executable must be on the system PATH.
N.B. This is alpha-level software and should not be used in production since the API may still change substantially.
The basic usage of the library looks something like this:
{-# LANGUAGE TemplateHaskell #-}
[...]
import LightGBM ( toCSV
, readCsvFile
, HasHeader(..)
, trainNewModel)
import qualified LightGBM.Parameters as P
import Refined (refineTH)
let modelFile = "/path/to/model/output"
trainingData = readCsvFile (HasHeader False) "/path/to/training/data"
validationData = readCsvFile (HasHeader False) "/path/to/validation/data"
trainingParams = [ P.App P.Binary
, P.Metric [P.BinaryLogloss, P.AUC]
, P.TrainingMetric True
, P.LearningRate 0.1
, P.NumLeaves 63
, P.FeatureFraction $$(refineTH 0.8)
, P.BaggingFreq $$(refineTH 5)
, P.BaggingFraction $$(refineTH 0.8)
, P.MinDataInLeaf 50
, P.MinSumHessianInLeaf 5.0
, P.IsSparse True
]
modelOut <- trainNewModel trainingParams trainingData validationData
case modelOut of
Left err -> ... -- handle the errors
Right model -> do
let newData = readCsvFile (HasHeader False) "/path/to/inputs_for_prediction"
outputFile = "/path/to/prediction_outputs"
predOut <- predict model [] newData
case predOut of
Left err -> ... -- handle the errors
Right preds -> toCSV outputFile preds