import pandas as pd import lightgbm as lgb from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn import metrics canceData=load_breast_cancer() X=canceData.data y=canceData.target X_train,X_test,y_train,y_test=train_test_split(X,y,random_state=0,test_size=0.2) params = { 'boosting_type': 'gbdt', 'objective': 'binary', 'metric': 'auc', 'nthread':4, 'learning_rate':0.1, 'num_leaves':30, 'max_depth': 5, 'subsample': 0.8, 'colsample_bytree': 0.8, 'boost_from_average':'false', } #params_test1={'max_depth': range(3,8,1), 'num_leaves':range(5, 100, 5)} data_train = lgb.Dataset(X_train, y_train) #print X model=lgb.LGBMClassifier(boosting_type='gbdt',objective='binary', metrics='auc',learning_rate=0.01, n_estimators=1000, max_depth=4, num_leaves=10, max_bin=255,min_data_in_leaf=81,bagging_fraction=0.7, bagging_freq= 30, feature_fraction= 0.8,lambda_l1=0.1, lambda_l2=0,min_split_gain=0.1, ) model.fit(X_train,y_train) y_pre=model.predict(X_test) print("acc:",metrics.accuracy_score(y_test,y_pre)) print("auc:",metrics.roc_auc_score(y_test,y_pre))
发打发打发
最新推荐文章于 2022-05-05 10:12:10 发布