2024年2月1日发(作者:)
#数据预处理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)结果:调参:
本文发布于:2024-02-01 10:02:52,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170675297235859.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |