利用BP网络输电线路故障诊断(Python代码,压缩包带有数据集和代码,解压缩可直接运行)

1.数据集介绍 

将故障区分为具体的不同类型:单相短路故障、两相接地短路故障、两相相间故障、三相相间短路故障。这里随意举出每种类别的两个样本进行展示。

G C B A Ia Ib Ic Va Vb Vc
1 0 0 1 -151.2918124 -9.677451563 85.80016226 0.400749853 -0.132934945 -0.267814907
1 0 0 1 -336.1861826 -76.28326195 18.32889658 0.312731934 -0.123633156 -0.189098779
1 0 1 1 -343.4870147 104.5627513 3.794285309 0.272042501 0.011317575 -0.283360076
1 0 1 1 -339.1254001 105.4293167 -0.267241225 0.27782054 0.021756839 -0.299577378
0 1 1 0 19.38615173 -785.553797 768.7279081 -0.210406869 -0.0020112 0.212418069
0 1 1 0 18.47841651 -783.8619173 767.9410527 -0.217651204 -0.00260451 0.220255714
0 1 1 1 506.5917463 374.8825788 -879.344997 0.042029705 -0.025636401 -0.016393305
0 1 1 1 495.1384715 387.4159615 -880.4253096 0.042107683 -0.025103056 -0.017004627

2.模型:BP网络,每类故障有1000个样本

3.效果(平均识别准确率为95.304%)

混淆矩阵

利用BP网络输电线路故障诊断(Python代码,压缩包带有数据集和代码,解压缩可直接运行)_第1张图片 F1-score

利用BP网络输电线路故障诊断(Python代码,压缩包带有数据集和代码,解压缩可直接运行)_第2张图片

误差曲线

利用BP网络输电线路故障诊断(Python代码,压缩包带有数据集和代码,解压缩可直接运行)_第3张图片

4.代码

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import warnings

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix

sns.set_style('darkgrid')
plt.rcParams['figure.figsize'] = (13, 9)
plt.rcParams['font.size'] = 20
warnings.filterwarnings('ignore')
plt.rcParams['font.family'] = 'SimHei'  # 设置字体为黑体

multi_data = pd.read_csv('./Data1.csv').iloc[0:4362, :]
lines = [
    ('Ia', 'Va'),
    ('Ib', 'Vb'),
    ('Ic', 'Vc')
]
#可以关注:https://mbd.pub/o/bread/ZJuXmZhv
print(f'Number of Samples: {multi_data.shape[0]}')
multi_data['faultType'] = multi_data['G'].astype(str) + multi_data['C'].astype(str) + multi_data['B'].astype(str) + \
                           multi_data['A'].astype(str)
multi_data.head()

你可能感兴趣的:(可创新代码,网络,算法)