发打发打发

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))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值