0%

论文技巧

文献作图技巧

作图

radar figure
混淆矩阵(confusion matrix)
(Chord plot of misclassification)[https://github.com/shahinrostami/chord]

综述查询

web of science

机器学习评价指标

https://towardsdatascience.com/20-popular-machine-learning-metrics-part-1-classification-regression-evaluation-metrics-1ca3e282a2ce
https://medium.com/@MohammedS/performance-metrics-for-classification-problems-in-machine-learning-part-i-b085d432082b

FFT

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
from scipy.fftpack import fft,ifft
import matplotlib.pyplot as plt
import seaborn
from scipy import signal

sampling_rate = 500#采样频率
t = np.arange(0,30.0,1.0/sampling_rate)
f1 = 10 #Hz
f2 = 100 #Hz
f3 = 210 #Hz
y = np.sin(2 * np.pi * f1 * t)+4*np.sin(2 * np.pi * f2 * t)+np.sin(2 * np.pi * f3 * t)
plt.plot(t,y)
plt.show()

yy = y
yf = fft(y) # 快速傅里叶变换
fs = 500
T = 1.0/500
N = len(y)
t=np.array(range(N))/fs
xf = np.linspace(0.0,1.0/(2.0*T),N/2)
plt.plot(xf,2.0/N*np.abs(yf[:N//2]))
plt.show()

‘’’
低频数据
‘’’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# # 采样率 200Hz
# # 想要滤掉 0.1-90Hz
# fs = 200.0
# lowcut = 0.1
# highcut = 90.0
# fnq = fs * 0.5
# low = lowcut / fnq
# high = highcut / fnq
# print(E1_emg.shape)
# b, a = signal.butter(2, 0.01, btype='lowpass')
# tmpE1_emg = copy.deepcopy(E1_emg)
# for i in range(len(E1_emg.T)):
# tmpE1_emg[:,i] = signal.filtfilt(b, a, abs(E1_emg[:,i]))
# for i in range(8):
# plt.subplot(8, 1, i+1)
# plt.plot(E1_emg[:,i])
# plt.plot(tmpE1_emg[:,i])
# plt.show()
'''
小波功率图谱
'''
"""Plot the set of 1D demo signals available in `pywt.data.demo_signal`."""
# #!/usr/bin/env python
# # -*- coding: utf-8 -*-
#
# import pywt
#
#
# DB2_Dir = 'E:\\Datasets\\NinaPro\\DB5\\s2\\'
# # E1 = scio.loadmat(DB2_Dir+'S2_E1_A1.mat')
# E2 = scio.loadmat(DB2_Dir + 'S2_E2_A1.mat')
# E3 = scio.loadmat(DB2_Dir + 'S2_E3_A1.mat')
# # print(len(E1['stimulus']))
# print(len(E2['stimulus']))
#
# for i, label in enumerate(E2['stimulus']):
# if label != 0:
# E2['stimulus'][i] = label
# for i, label in enumerate(E3['stimulus']):
# if label != 0:
# E3['stimulus'][i] = label + 17
#
# all_data = np.vstack((E2['emg'], E3['emg'])) # 41种分类
# all_label = np.vstack((E2['stimulus'], E3['stimulus']))
# t = range(500)
# plt.figure(1)
# for i in range(16):
# plt.subplot(16, 2, i+1)
#
# wavename = "gaus3"
# totalscal = 1024
# fc = pywt.central_frequency(wavename) # 中心频率
# cparam = 2 * fc * totalscal
# scales = cparam / np.arange(totalscal, 1, -1)
# [cwtmatr, frequencies] = pywt.cwt(all_data[10000:10500,i], scales, wavename, 1.0 / 200) # 连续小波变换
# plt.contourf(t, frequencies, abs(cwtmatr), cmap="RdBu_r")
# plt.colorbar()
# for i in range(16):
# plt.subplot(16, 2, i + 17)
# plt.plot(all_data[10000:10500,i])
# plt.colorbar()
#
# plt.show()

拟合曲线到椭圆
https://www.cnpython.com/qa/81363

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'''
plot Engery figure
'''
DB2_Dir = 'E:\\Datasets\\NinaPro\\DB5\\s1\\'
E2 = scio.loadmat(DB2_Dir + 'S1_E2_A1.mat')
E3 = scio.loadmat(DB2_Dir + 'S1_E3_A1.mat')

for i, label in enumerate(E2['stimulus']):
if label != 0:
E2['stimulus'][i] = label
for i, label in enumerate(E3['stimulus']):
if label != 0:
E3['stimulus'][i] = label + 17

all_data = np.vstack((E2['emg'], E3['emg']))
all_label = np.vstack((E2['stimulus'], E3['stimulus']))
x = all_data[:,1]
x1 = x[81200:81250]
x2 = x[81400:81450]
y1 = np.diff(x1)/0.005
y1 = np.insert(y1,0,0)
y2 = np.diff(x2)/0.005
y2 = np.insert(y2,0,0)

plt.figure(1)
plt.plot(all_data[:,1])
plt.figure(2)
plt.plot(x1,y1)
plt.plot(x2,y2)
plt.show()

plt.scatter(x1, y1, c="blue", marker='o')
plt.scatter(x2, y2, c="red", marker='o')
plt.show()
# 重组合x1,y1 (x1,y1)
plot_list = []
for i, element in enumerate(x2):
plot_list.append((element,y2[i]))
print(plot_list)

a_points = np.array(plot_list)
x = a_points[:, 0]
y = a_points[:, 1]

ell = EllipseModel()
ell.estimate(a_points)

xc, yc, a, b, theta = ell.params

print("center = ", (xc, yc))
print("angle of rotation = ", theta)
print("axes = ", (a,b))

fig, axs = plt.subplots(2, 1, sharex=True, sharey=True)
# axs[0].plot(x,y)
axs[0].scatter(x, y, c="blue", marker='o')
axs[1].scatter(x, y, c="blue", marker='o')
# axs[1].plot(x, y)
axs[1].scatter(xc, yc, color='red', s=100)
axs[1].set_xlim(x.min(), x.max())
axs[1].set_ylim(y.min(), y.max())

ell_patch = Ellipse((xc, yc), 2*a, 2*b, theta*180/np.pi, edgecolor='red', facecolor='none')

axs[1].add_patch(ell_patch)
plt.show()

帕塞瓦尔定理Parseval’s theorem
https://zhuanlan.zhihu.com/p/99602919

ANOVA(箱线图)
https://www.reneshbedre.com/blog/anova.html
https://zhuanlan.zhihu.com/p/91031244

坚持原创技术分享,您的支持将鼓励我继续创作!