January 2020
Beginner to intermediate
432 pages
11h 24m
English
Execute the following steps to run Bayesian hyperparameter optimization of a LightGBM model.
import pandas as pdfrom sklearn.model_selection import train_test_splitfrom hyperopt import hp, fmin, tpe, STATUS_OK, Trialsfrom sklearn.model_selection import (cross_val_score, StratifiedKFold)from lightgbm import LGBMClassifierfrom chapter_9_utils import performance_evaluation_report
N_FOLDS = 5MAX_EVALS = 200
df = pd.read_csv('credit_card_fraud.csv')X = df.copy()y = X.pop('Class')X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y)
def objective(params, n_folds = N_FOLDS, random_state=42): ...
Read now
Unlock full access