The params
mentioned in the error message refer to the Parameters that are passed to the train()
function. If you use the sklearn classes of the python API, some of the parameters are also available as keyword arguments in the classifier's __init__()
method.
Example:
import lightgbm as lgb
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
iris = datasets.load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data,
iris.target,
test_size=0.2)
lgb_train = lgb.Dataset(X_train, y_train)
# here are the parameters you need
params = {
'task': 'train',
'boosting_type': 'gbdt',
'objective': 'multiclass',
'num_class': 3,
'max_bin': 4 # <-- max_bin
}
gbm = lgb.train(params,
lgb_train,
num_boost_round=20)
y_pred = gbm.predict(X_test, num_iteration=gbm.best_iteration)
y_pred = np.argmax(y_pred, axis=1)
print("Accuracy: ", accuracy_score(y_test, y_pred))
For a detailed example i recommend taking a look at the python examples that come with LGBM.