Challenge - 5 Problems
LightGBM Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding LightGBM's Leaf-wise Tree Growth
LightGBM grows trees using a leaf-wise strategy instead of a level-wise one. What is the main advantage of this leaf-wise growth compared to level-wise growth?
Attempts:
2 left
💡 Hint
Think about how growing the leaf with the largest loss reduction affects tree shape and performance.
✗ Incorrect
Leaf-wise growth chooses the leaf with the highest loss to split, allowing deeper trees where needed, which can improve accuracy and reduce training time compared to level-wise growth.
❓ Hyperparameter
intermediate2:00remaining
Choosing the Right LightGBM Hyperparameter for Overfitting Control
Which LightGBM hyperparameter primarily controls the maximum depth of the trees to prevent overfitting?
Attempts:
2 left
💡 Hint
This parameter limits how deep the tree can grow.
✗ Incorrect
max_depth sets the maximum depth of each tree, directly limiting complexity and helping prevent overfitting.
❓ Predict Output
advanced2:00remaining
Output of LightGBM Training with Early Stopping
What will be the output of the following Python code snippet using LightGBM?
ML Python
import lightgbm as lgb from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score X, y = load_breast_cancer(return_X_y=True) X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42) train_data = lgb.Dataset(X_train, label=y_train) val_data = lgb.Dataset(X_val, label=y_val, reference=train_data) params = {'objective': 'binary', 'metric': 'binary_logloss', 'verbose': -1} model = lgb.train(params, train_data, num_boost_round=100, valid_sets=[val_data], early_stopping_rounds=10, verbose_eval=False) preds = model.predict(X_val, num_iteration=model.best_iteration) preds_binary = (preds > 0.5).astype(int) acc = accuracy_score(y_val, preds_binary) print(f"Accuracy: {acc:.3f}")
Attempts:
2 left
💡 Hint
The breast cancer dataset is easy to classify with LightGBM, expect high accuracy.
✗ Incorrect
The code trains LightGBM with early stopping on a well-known dataset, resulting in high accuracy around 0.96.
❓ Metrics
advanced2:00remaining
Interpreting LightGBM's Binary Logloss Metric
During LightGBM training for a binary classification task, the binary_logloss metric decreases from 0.6 to 0.2. What does this change indicate about the model?
Attempts:
2 left
💡 Hint
Lower logloss means better probability estimates.
✗ Incorrect
Binary logloss measures how close predicted probabilities are to actual labels; a decrease means better predictions.
🔧 Debug
expert2:00remaining
Identifying the Cause of a LightGBM Training Error
You run the following LightGBM training code but get the error: "ValueError: Label must be 1-D array." What is the most likely cause?
ML Python
import lightgbm as lgb import numpy as np X = np.random.rand(100, 5) y = np.random.rand(100, 1) # shape is (100,1) train_data = lgb.Dataset(X, label=y) params = {'objective': 'regression'} model = lgb.train(params, train_data, num_boost_round=10)
Attempts:
2 left
💡 Hint
Check the shape of the label array passed to Dataset.
✗ Incorrect
LightGBM expects labels as a 1-D array. Passing a 2-D array causes this ValueError.