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))
发打发打发
最新推荐文章于 2024-07-03 09:35:47 发布
本文介绍了一种使用LightGBM模型进行乳腺癌预测的方法。通过加载乳腺癌数据集,将其划分为训练集和测试集,设置模型参数并训练模型,最后评估模型的准确率和AUC值。实验结果显示,该模型在乳腺癌预测任务中表现出良好的性能。
8631

被折叠的 条评论
为什么被折叠?



