View source: R/wrap_lightgbm.R
| wrap_lightgbm | R Documentation |
Fits a 'lightgbm' model with a consistent interface. Supports binary classification, multiclass classification, and regression.
wrap_lightgbm(x, y, ...)
## S3 method for class 'wrap_lightgbm'
predict(object, newx, type = c("class", "prob"), ...)
## S3 method for class 'wrap_lightgbm'
print(x, ...)
x |
A matrix or data.frame of features. |
y |
A factor or character vector for classification, numeric for regression. |
... |
Additional arguments passed to [lightgbm::lgb.train()]. Pass 'params = list(objective = "binary")' for binary classification, 'params = list(objective = "multiclass", num_class = k)' for multiclass, or 'params = list(objective = "regression")' for regression. |
object |
A fitted 'wrap_lightgbm' object. |
newx |
A matrix or data.frame of new observations. |
type |
'"class"' (default) for class labels, '"prob"' for a probability matrix. Ignored for regression. |
An object of class 'wrap_lightgbm' with fields:
fit |
The fitted lgb.Booster model. |
levels |
Class levels (NULL for regression). |
task |
"classification" or "regression". |
objective |
The lightgbm objective string, stored at fit time. |
library(mlS3)
X <- iris[, 1:4]
y <- iris$Species
mod <- wrap_lightgbm(X, y,
params = list(objective = "multiclass", num_class = 3, verbose = -1),
nrounds = 50)
predict(mod, newx = X, type = "class")
predict(mod, newx = X, type = "prob")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.