-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting file.py
More file actions
83 lines (60 loc) · 1.83 KB
/
Testing file.py
File metadata and controls
83 lines (60 loc) · 1.83 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import sys
from pathlib import Path
import statistics
import os
from PyQt5.QtWidgets import (QMainWindow, QComboBox, QPushButton,\
QAction, QLabel, QFileDialog, QTableWidgetItem,\
QLineEdit, QTableWidget, QCheckBox, QMessageBox,\
QApplication)
from PyQt5.QtGui import (QIcon)
from PyQt5.QtCore import QDate, QTime, QDateTime, Qt
from PyQt5 import QtCore
from PyQt5 import QtWidgets
import numpy as np
import matplotlib.pyplot as plt
import padasip as pa
# Import the os module
import csv
import numpy as np
import matplotlib.pylab as plt
import padasip as pa
# creation of data
N = 500
x = np.random.normal(0, 1, (N, 4)) # input matrix
v = np.random.normal(0, 0.1, N) # noise
d = 2*x[:,0] + 0.1*x[:,1] - 4*x[:,2] + 0.5*x[:,3] + v # target
print(type(d))
print(d.shape)
print(type(x))
print(x.shape)
print(x)
# identification
f = pa.filters.FilterGNGD(n=4, mu=0.1, w="random")
y, e, w = f.run(d, x)
with open("Slozena_funkce.csv", "r", encoding="utf-8") as hodnoty:
mat1 = (np.genfromtxt(hodnoty, delimiter=",", skip_header=0))
mat2 = np.reshape(mat1, (1000, 1))
mat3 = np.reshape(mat1, (1000, 1))
MAT2 = []
MAT3 = []
for i in range(0,995):
MAT2.append(mat2[i])
MAT3.append(mat3[i])
mat4 = np.concatenate((MAT2,MAT3))
input_mat = np.reshape(mat4, (995, 2))
mat5 = []
for i in range(5, 1000):
mat5.append(mat2[i])
desired_mat = np.concatenate(mat5)
f = pa.filters.FilterGNGD(n=2, mu=0.1, w="random")
y, e, w = f.run(desired_mat, input_mat)
print(input_mat)
print(desired_mat)
print(len(input_mat))
print(len(desired_mat))
print(type(input_mat))
print(type(desired_mat))
# new csv file creation
import numpy as np
arr = np.asarray([ [7,8,9,6,7,8], [5,8,9,4,6,4], [4,8,7,4,6,2], [7,8,9,6,7,8], [4,8,7,4,6,2] ])
arr.tofile('sample.csv', sep = ',')