|
@@ -65,7 +65,7 @@ class LightGBM(object):
|
|
|
df = df.dropna(subset=['label'])
|
|
|
labels = df['label']
|
|
|
temp = sorted(labels)
|
|
|
- yc = temp[int(len(temp) * self.yc)]
|
|
|
+ yc = temp[int(len(temp) * 0.7)]
|
|
|
labels = [0 if i < yc else 1 for i in labels]
|
|
|
features = df.drop("label", axis=1)
|
|
|
for key in self.float_columns:
|
|
@@ -91,8 +91,14 @@ class LightGBM(object):
|
|
|
}
|
|
|
|
|
|
# 定义 RandomizedSearchCV
|
|
|
- rsearch = RandomizedSearchCV(estimator=lgbm, param_distributions=param_dist, n_iter=100, cv=3,
|
|
|
- scoring='roc_auc', random_state=42, verbose=2)
|
|
|
+ rsearch = RandomizedSearchCV(
|
|
|
+ estimator=lgbm,
|
|
|
+ param_distributions=param_dist,
|
|
|
+ n_iter=100,
|
|
|
+ cv=3,
|
|
|
+ scoring='roc_auc',
|
|
|
+ random_state=42, verbose=2
|
|
|
+ )
|
|
|
|
|
|
# 开始搜索
|
|
|
rsearch.fit(X_train, y_train)
|
|
@@ -210,9 +216,6 @@ if __name__ == "__main__":
|
|
|
L = LightGBM(flag=f, dt=dt)
|
|
|
L.evaluate_model()
|
|
|
L.feature_importance()
|
|
|
- # L = LightGBM("train", "whole")
|
|
|
- # L.best_params()
|
|
|
- # study = optuna.create_study(direction='maximize')
|
|
|
- # study.optimize(L.bays_params, n_trials=100)
|
|
|
- # print('Number of finished trials:', len(study.trials))
|
|
|
- # print('Best trial:', study.best_trial.params)
|
|
|
+ elif i == 3:
|
|
|
+ L = LightGBM("train", "whole")
|
|
|
+ L.best_params()
|