从如下链接中下载轴承数据集。
https://www.sciencedirect.com/science/article/pii/S2352340918314124
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
import statistics as stats
import pandas as pd
from sklearn.model_selection import train_test_split
A1 = sio.loadmat('./Data/H-A-1.mat')
channel1HA1 = HA1['Channel_1']
n = len(channel1HA1) # Número de muestrascanal1HA1 = channel1HA1.T[0]
f = 200000 # Hz #graba a 200000 por s
t = np.linspace(0, 10, n)
dt = t[1] - t[0]HA2 = sio.loadmat('./Data/H-A-2.mat')
channel1HA2 = HA2['Channel_1']
canal1HA2 = channel1HA2.T[0]HA3 = sio.loadmat('./Data/H-A-3.mat')
channel1HA3 = HA3['Channel_1']
canal1HA3 = channel1HA3.T[0]
HB1 = sio.loadmat('./Data/H-B-1.mat')
channel1HB1 = HB1['Channel_1']
canal1HB1 = channel1HB1.T[0]HB2 = sio.loadmat('./Data/H-B-2.mat')
channel1HB2 = HB2['Channel_1']
canal1HB2 = channel1HB2.T[0]HB3 = sio.loadmat('./Data/H-B-3.mat')
channel1HB3 = HB3['Channel_1']
canal1HB3 = channel1HB3.T[0]
HC1 = sio.loadmat('./Data/H-C-1.mat')
channel1HC1 = HC1['Channel_1']
canal1HC1 = channel1HC1.T[0]HC2 = sio.loadmat('./Data/H-C-2.mat')
channel1HC2 = HC2['Channel_1']
canal1HC2 = channel1HC2.T[0]HC3 = sio.loadmat('./Data/H-C-3.mat')
channel1HC3 = HC3['Channel_1']
canal1HC3 = channel1HC3.T[0]
HD1 = sio.loadmat('./Data/H-D-1.mat')
channel1HD1 = HD1['Channel_1']
canal1HD1 = channel1HD1.T[0]HD2 = sio.loadmat('./Data/H-D-2.mat')
channel1HD2 = HD2['Channel_1']
canal1HD2 = channel1HD2.T[0]HD3 = sio.loadmat('./Data/H-D-3.mat')
channel1HD3 = HD3['Channel_1']
canal1HD3 = channel1HD3.T[0]
sanos = pd.DataFrame({'Sano1': canal1HA1, 'Sano2': canal1HA2, 'Sano3': canal1HA3,'Sano4': canal1HB1, 'Sano5': canal1HB2, 'Sano6': canal1HB3,'Sano7': canal1HC1, 'Sano8': canal1HC2, 'Sano9': canal1HC3,'Sano10': canal1HD1, 'Sano11': canal1HD2, 'Sano12': canal1HD3})
sanos
IA1 = sio.loadmat('./Data/I-A-1.mat')
channel1IA1 = IA1['Channel_1']
canal1IA1 = channel1IA1.T[0]IA2 = sio.loadmat('./Data/I-A-2.mat')
channel1IA2 = IA2['Channel_1']
canal1IA2 = channel1IA2.T[0]IA3 = sio.loadmat('./Data/I-A-3.mat')
channel1IA3 = IA3['Channel_1']
canal1IA3 = channel1IA3.T[0]
IB1 = sio.loadmat('./Data/I-B-1.mat')
channel1IB1 = IB1['Channel_1']
canal1IB1 = channel1IB1.T[0]IB2 = sio.loadmat('./Data/I-B-2.mat')
channel1IB2 = IB2['Channel_1']
canal1IB2 = channel1IB2.T[0]IB3 = sio.loadmat('./Data/I-B-3.mat')
channel1IB3 = IB3['Channel_1']
canal1IB3 = channel1IB3.T[0]
IC1 = sio.loadmat('./Data/I-C-1.mat')
channel1IC1 = IC1['Channel_1']
canal1IC1 = channel1IC1.T[0]IC2 = sio.loadmat('./Data/I-C-2.mat')
channel1IC2 = IC2['Channel_1']
canal1IC2 = channel1IC2.T[0]IC3 = sio.loadmat('./Data/I-C-3.mat')
channel1IC3 = IC3['Channel_1']
canal1IC3 = channel1IC3.T[0]
ID1 = sio.loadmat('./Data/I-D-1.mat')
channel1ID1 = ID1['Channel_1']
canal1ID1 = channel1ID1.T[0]ID2 = sio.loadmat('./Data/I-D-2.mat')
channel1ID2 = ID2['Channel_1']
canal1ID2 = channel1ID2.T[0]ID3 = sio.loadmat('./Data/I-D-3.mat')
channel1ID3 = ID3['Channel_1']
canal1ID3 = channel1ID3.T[0]
inners = pd.DataFrame({'Inner1': canal1IA1, 'Inner2': canal1IA2, 'Inner3': canal1IA3,'Inner4': canal1IB1, 'Inner5': canal1IB2, 'Inner6': canal1IB3,'Inner7': canal1IC1, 'Inner8': canal1IC2, 'Inner9': canal1IC3,'Inner10': canal1ID1, 'Inner11': canal1ID2, 'Inner12': canal1ID3})
inners
OA1 = sio.loadmat('./Data/O-A-1.mat')
channel1OA1 = OA1['Channel_1']
canal1OA1 = channel1OA1.T[0]OA2 = sio.loadmat('./Data/O-A-2.mat')
channel1OA2 = OA2['Channel_1']
canal1OA2 = channel1OA2.T[0]OA3 = sio.loadmat('./Data/O-A-3.mat')
channel1OA3 = OA3['Channel_1']
canal1OA3 = channel1OA3.T[0]
OB1 = sio.loadmat('./Data/O-B-1.mat')
channel1OB1 = OB1['Channel_1']
canal1OB1 = channel1OB1.T[0]OB2 = sio.loadmat('./Data/O-B-2.mat')
channel1OB2 = OB2['Channel_1']
canal1OB2 = channel1OB2.T[0]OB3 = sio.loadmat('./Data/O-B-3.mat')
channel1OB3 = OB3['Channel_1']
canal1OB3 = channel1OB3.T[0]
OC1 = sio.loadmat('./Data/O-C-1.mat')
channel1OC1 = OC1['Channel_1']
canal1OC1 = channel1OC1.T[0]OC2 = sio.loadmat('./Data/O-C-2.mat')
channel1OC2 = OC2['Channel_1']
canal1OC2 = channel1OC2.T[0]OC3 = sio.loadmat('./Data/O-C-3.mat')
channel1OC3 = OC3['Channel_1']
canal1OC3 = channel1OC3.T[0]
OD1 = sio.loadmat('./Data/O-D-1.mat')
channel1OD1 = OD1['Channel_1']
canal1OD1 = channel1OD1.T[0]OD2 = sio.loadmat('./Data/O-D-2.mat')
channel1OD2 = OD2['Channel_1']
canal1OD2 = channel1OD2.T[0]OD3 = sio.loadmat('./Data/O-D-3.mat')
channel1OD3 = OD3['Channel_1']
canal1OD3 = channel1OD3.T[0]
outers = pd.DataFrame({'Outer1': canal1OA1, 'Outer2': canal1OA2, 'Outer3': canal1OA3,'Outer4': canal1OB1, 'Outer5': canal1OB2, 'Outer6': canal1OB3,'Outer7': canal1OC1, 'Outer8': canal1OC2, 'Outer9': canal1OC3,'Outer10': canal1OD1, 'Outer11': canal1OD2, 'Outer12': canal1OD3})
outers
signals = []
for i in range(1, 13):signal = sanos['Sano' + str(i)].valuessignals.append(signal)for i in range(1, 13):signal = inners['Inner' + str(i)].valuessignals.append(signal)for i in range(1, 13):signal = outers['Outer' + str(i)].valuessignals.append(signal)tipo = ['Sano'] * 12 + ['Inner'] * 12 + ['Outer'] * 12
X = signals
y = tipo
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, train_size = 0.75, random_state = 0, stratify = y)
sio.savemat('./ProcessedData/signals_train.mat', {'Signal': X_train, 'Tipo': y_train})
sio.savemat('./ProcessedData/signals_test.mat', {'Signal': X_test, 'Tipo': y_test})知乎学术咨询:
https://www.zhihu.com/consult/people/792359672131756032?isMe=1
工学博士,担任《Mechanical System and Signal Processing》《中国电机工程学报》《控制与决策》等期刊审稿专家,擅长领域:现代信号处理,机器学习,深度学习,数字孪生,时间序列分析,设备缺陷检测、设备异常检测、设备智能故障诊断与健康管理PHM等。