Complete the code to import the LightGBM library.
import [1] as lgb
The LightGBM library is imported using import lightgbm as lgb.
Complete the code to create a LightGBM dataset from features X and labels y.
train_data = lgb.Dataset([1], label=y)The features are passed as the first argument to lgb.Dataset, so we use X.
Fix the error in the code to train a LightGBM model with 100 boosting rounds.
model = lgb.train(params, train_data, num_boost_round=[1])The num_boost_round parameter controls the number of boosting iterations. 100 is a common choice for training.
Fill both blanks to set LightGBM parameters for binary classification with learning rate 0.05.
params = {'objective': [1], 'learning_rate': [2]The objective for binary classification is 'binary', and the learning rate is set to 0.05.
Fill all three blanks to predict with the model and calculate accuracy score.
y_pred = model.predict([1]) y_pred_labels = (y_pred > [2]).astype(int) accuracy = sum(y_pred_labels == [3]) / len(y_pred_labels)
We predict on X_test, use 0.5 as threshold to get labels, and compare with true labels y_test to compute accuracy.