LightGBM算法详解(教你一文掌握LightGBM所有知识点)

阅读: 评论:0

2024年2月1日发(作者:)

LightGBM算法详解(教你一文掌握LightGBM所有知识点)

#数据预处理import numpy as np

import as plt

import pandas as pd

# Importing the dataset

dataset = _csv('...inputSocial_Network_')

X = [:, [2, 3]].values

y = [:, 4].values

# Splitting the dataset into the Training set and Test set

from _validation import train_test_split

x_train, x_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)

# Feature Scaling

from cessing import StandardScaler

sc = StandardScaler()

x_train = _transform(x_train)

x_test = orm(x_test)#模型构建和训练import lightgbm as lgb

d_train = t(x_train, label=y_train)

params = {}

params['learning_rate'] = 0.003

params['boosting_type'] = 'gbdt'

params['objective'] = 'binary'

params['metric'] = 'binary_logloss'

params['sub_feature'] = 0.5

params['num_leaves'] = 10

params['min_data'] = 50

params['max_depth'] = 10

clf = (params, d_train, 100)#模型预测#Prediction

y_pred=t(x_test)

#convert into binary values

for i in range(0,99):

if y_pred[i]>=.5: # setting threshold to .5

y_pred[i]=1

else:

y_pred[i]=0#准确率计算#Confusion matrix

from s import confusion_matrix

cm = confusion_matrix(y_test, y_pred)

#Accuracy

from s import accuracy_score

accuracy=accuracy_score(y_pred,y_test)结果:调参:

LightGBM算法详解(教你一文掌握LightGBM所有知识点)

本文发布于:2024-02-01 10:02:52,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170675297235859.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:模型   详解   知识点
留言与评论(共有 0 条评论)
   
验证码:
排行榜

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23