我有以下代码:
most_important = features_importance_chi(importance_score_tresh,
df_user.drop(columns = 'CHURN'),churn)
X = df_user.drop(columns = 'CHURN')
churn[churn==2] = 1
y = churn
# handle undersample problem
X,y = handle_undersampe(X,y)
# train the model
X=X.loc[:,X.columns.isin(most_important)].values
y=y.values
parameters = {
'application': 'binary',
'objective': 'binary',
'metric': 'auc',
'is_unbalance': 'true',
'boosting': 'gbdt',
'num_leaves': 31,
'feature_fraction': 0.5,
'bagging_fraction': 0.5,
'bagging_freq': 20,
'learning_rate': 0.05,
'verbose': 0
}
# split data
x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)
train_data = lightgbm.Dataset(x_train, label=y_train)
test_data = lightgbm.Dataset(x_test, label=y_test)
model = …Run Code Online (Sandbox Code Playgroud)