xgboost

    Dark Mode
Search:
Group by:

Types

XGDMatrixInfoKey = enum
  label = "label", weight = "weight", baseMargin = "base_margin",
  group = "group", qid = "qid", labelLowerBound = "label_lower_bound",
  labelUpperBound = "label_upper_bound", featureWeights = "feature_weights"
XGError = object of CatchableError
  returnCode*: int
XGDMatrix = ref object
  self: DMatrixHandle
XGDevice = ref object
XGBooster = ref object
  self: BoosterHandle

Procs

proc xgbVersion(): tuple[major: int, minor: int, patch: int] {...}{.raises: [],
    tags: [].}
Return the version of the XGBoost library being currently used.
proc xgbGetLastError(): string {...}{.raises: [], tags: [].}
get string message of the last error
proc xgbRegisterLogCallback(callback: proc (msg: string) {...}{.gcsafe.}) {...}{.
    raises: [Exception, XGError], tags: [RootEffect].}
register callback function for LOG(INFO) messages
proc xgbSetGlobalConfig(json: JsonNode) {...}{.raises: [XGError], tags: [].}
Set global configuration (collection of parameters that apply globally).
proc xgbGetGlobalConfig(): JsonNode {...}{.raises: [XGError, IOError, OSError,
    JsonParsingError, ValueError, Exception],
                                      tags: [ReadIOEffect, WriteIOEffect].}
Get current global configuration (collection of parameters that apply globally).
proc newXGDMatrix(fname: string; silent: int = 1): XGDMatrix {...}{.
    raises: [XGError], tags: [].}
load a data matrix
proc newXGDMatrix(data: seq[float32]; nRow, nCol: int;
                  missing: float32 = DEFAULT_MISSING): XGDMatrix {...}{.
    raises: [XGError, ValueError], tags: [].}
create matrix content from dense matrix.
proc newXGDMatrix(data: seq[float32]; nRow: int;
                  missing: float32 = DEFAULT_MISSING): XGDMatrix {...}{.
    raises: [XGError, ValueError], tags: [].}
create matrix content from dense matrix. nCol is automatically derived.
proc newXGDMatrix[N: static int](data: seq[array[N, float32]];
                                 missing: float32 = DEFAULT_MISSING): XGDMatrix

create matrix content from dense matrix.

This procedure internally covert seq[array[N, float32]] to seq[float32] and call other newXGDMatrix. If memory usage is a concern, directly use other newXGDMatrix.

proc nRow(m: XGDMatrix): int {...}{.raises: [XGError], tags: [].}
get number of rows.
proc nCol(m: XGDMatrix): int {...}{.raises: [XGError], tags: [].}
get number of columns
proc slice(handle: XGDMatrix; idx: seq[int]): XGDMatrix {...}{.raises: [XGError],
    tags: [].}
create a new dmatrix from sliced content of existing matrix
proc setInfo(handle: XGDMatrix; field: XGDMatrixInfoKey | string;
             arr: seq[float32])
set float vector to a content in info
proc setInfo(handle: XGDMatrix; field: XGDMatrixInfoKey | string;
             arr: seq[uint32])
set uint32 vector to a content in info
proc setInfo(handle: XGDMatrix; field: XGDMatrixInfoKey | string;
             arr: seq[string])
Set string encoded information of all features.
proc saveBinary(handle: XGDMatrix; fname: string; silent: int = 1) {...}{.
    raises: [XGError], tags: [].}
load a data matrix into binary file
proc getFloatInfo(handle: XGDMatrix; field: string): seq[float32] {...}{.
    raises: [XGError], tags: [].}
get float info vector from matrix.
proc getUIntInfo(handle: XGDMatrix; field: string): seq[uint32] {...}{.
    raises: [XGError], tags: [].}
get uint32 info vector from matrix
proc getStrFeatureInfo(handle: XGDMatrix; field: string): seq[string] {...}{.
    raises: [XGError], tags: [].}
Get string encoded information of all features.
proc finalize(b: XGBooster) {...}{.raises: [XGError], tags: [].}
proc newXGBooster(toCaches: seq[XGDMatrix] = @[]): XGBooster {...}{.
    raises: [XGError], tags: [].}
proc setParam(b: XGBooster; name, value: string) {...}{.raises: [XGError], tags: [].}
set parameters
proc setParam(b: XGBooster; pairs: openArray[(string, string)]) {...}{.
    raises: [XGError], tags: [].}
set parameters
proc update(b: XGBooster; iter: int; dtrain: XGDMatrix) {...}{.raises: [XGError],
    tags: [].}
update the model in one round using dtrain
proc eval(b: XGBooster; iter: int; dmats: openArray[(string, XGDMatrix)]): string {...}{.
    raises: [XGError], tags: [].}
get evaluation statistics for xgboost
proc train(params: openArray[(string, string)]; dtrain: XGDMatrix;
           num_boost_round: int = 10; evals: openArray[(string, XGDMatrix)] = []): XGBooster {...}{.
    raises: [XGError], tags: [].}
Train booster.
proc predict(b: XGBooster; m: XGDMatrix): seq[float32] {...}{.raises: [XGError],
    tags: [].}
Make prediction from DMatrix.
proc predict(b: XGBooster; v: seq[float32]; missing: float32 = DEFAULT_MISSING): float32 {...}{.
    raises: [XGError, ValueError], tags: [].}
Make prediction from single row.
proc predictSeq(b: XGBooster; m: XGDMatrix): seq[seq[float32]] {...}{.
    raises: [XGError], tags: [].}
Make prediction from DMatrix. Output seq[float32]. Useful for multi:softprob
proc predictSeq(b: XGBooster; v: seq[float32];
                missing: float32 = DEFAULT_MISSING): seq[float32] {...}{.
    raises: [XGError, ValueError], tags: [].}

Make prediction from single row. Output seq[float32]. Useful for multi:softprob

proc saveModel(b: XGBooster; fname: string) {...}{.raises: [XGError], tags: [].}
Save model into existing file.
proc loadModel(b: XGBooster; fname: string) {...}{.raises: [XGError], tags: [].}
Load model from existing file.
proc getAttr(b: XGBooster; key: string): Option[string] {...}{.raises: [XGError],
    tags: [].}
Get string attribute from Booster.
proc setAttr(b: XGBooster; key, value: string) {...}{.raises: [XGError], tags: [].}
Set or delete string attribute.
proc getAttrNames(b: XGBooster): seq[string] {...}{.raises: [XGError], tags: [].}
Get the names of all attribute from Booster.

Exports

XGDMatrixCreateFromFile, XGDMatrixCreateFromMat_omp, XGDeviceQuantileDMatrixCreateFromCallback, XGDMatrixGetFloatInfo, DMatrixHandle, XGBoosterPredict, XGBoosterDumpModel, XGBoosterGetStrFeatureInfo, XGBoosterLoadModelFromBuffer, XGBoosterSlice, XGBoosterSerializeToBuffer, DataHolderHandle, XGDMatrixCreateFromDataIter, XGDMatrixNumCol, DataIterHandle, XGBoosterCreate, XGBoosterBoostedRounds, XGDMatrixCallbackNext, XGDMatrixSetUIntInfo, XGDMatrixCreateFromDT, XGDMatrixGetUIntInfo, XGBoosterSetStrFeatureInfo, XGBoosterLoadModel, XGBoostBatchCSR, XGDMatrixSetStrFeatureInfo, XGDMatrixSaveBinary, XGDMatrixSetGroup, XGBoosterPredictFromCudaArray, XGBoosterSetAttr, XGDMatrixSetInfoFromInterface, XGBoosterDumpModelWithFeatures, DataIterResetCallback, bst_ulong, XGBoosterGetAttr, XGBRegisterLogCallback, XGDMatrixFree, XGBoosterGetNumFeature, XGDMatrixSliceDMatrix, XGBGetLastError, XGBoosterSaveModel, XGBoosterPredictFromDense, XGDMatrixCreateFromCSREx, XGBoosterDumpModelExWithFeatures, XGBoosterPredictFromDMatrix, XGDMatrixNumRow, XGBoosterSaveRabitCheckpoint, XGBoosterGetAttrNames, XGBoostVersion, XGBoosterUnserializeFromBuffer, XGBoosterEvalOneIter, XGBoosterBoostOneIter, XGDMatrixSetFloatInfo, XGDMatrixCreateFromMat, XGBoosterLoadRabitCheckpoint, BoosterHandle, XGDMatrixCreateFromCSR, XGBCallbackSetData, XGDeviceQuantileDMatrixSetDataCudaColumnar, XGDMatrixSliceDMatrixEx, XGProxyDMatrixCreate, XGBCallbackDataIterNext, XGBoosterPredictFromCSR, XGBoosterGetModelRaw, XGBSetGlobalConfig, XGDMatrixGetStrFeatureInfo, XGBoosterPredictFromCudaColumnar, XGDMatrixCreateFromCSCEx, XGDMatrixSetDenseInfo, XGDeviceQuantileDMatrixSetDataCudaArrayInterface, XGBoosterUpdateOneIter, XGBoosterSaveJsonConfig, XGBoosterFree, XGBoosterLoadJsonConfig, XGBoosterDumpModelEx, XGBoosterSetParam, libxgboost, XGBGetGlobalConfig