You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
print(result_1, result_2) #number of closest sentences
48
+
print(result_1, result_2) #Number of closest sentences
49
49
print(d)
50
50
51
51
```
@@ -58,9 +58,42 @@ Then, two closest sentences to the 0-numbered sentence were found as a result.
58
58
Full code is available here: [Processing_Sentences.py](https://github.com/sichkar-valentyn/Machine_Learning_in_Python/tree/master/Codes/Processing_Sentences.py)
59
59
60
60
### <aname="Approximation of functions via linear equations">Approximation of functions via linear equations</a>
61
+
Implementing the task for approximation of function with linear equations. Using first degree polynomial, second degree polynomial and third degree polynomial. Solving equations with matrix method via 'numpy.linalg.solve(a, b)' function.
Points for first degree polynomials are: **1, 15**
67
+
<br/>Points for second degree polynomials are: **1, 8, 15**
68
+
<br/>Points for third degree polynomials are: **1, 4, 10, 15**
69
+
70
+
<br/><br/>Part of the code is shown below with a lot of comments:
71
+
72
+
```py
73
+
import numpy as np
74
+
75
+
76
+
# Creating first degree polynomials in the points of 1 and 15
77
+
# It has to be in following form:
78
+
# w_0 + w_1 * x_1 = y_1
79
+
# w_0 + w_1 * x_2 = y_2
80
+
# Writing systems of equations into two-dimensional array 'a' and vector 'b'
81
+
a = np.array([[1, 1], [1, 15]])
82
+
b = np.array([f(1), f(15)]) # [3.25221687 0.63522142]
83
+
84
+
# Solving system of linear equations for first degree polynomial
85
+
w = np.linalg.solve(a, b) # [ 3.43914511 -0.18692825]
86
+
# Found equation for the first degree polynomial is as following:
87
+
# y = w[0] + w[1] * x
88
+
89
+
```
90
+
91
+
Results are plot in order to understand the quality of approximation in eche case. Figure is shown below
61
92
62
93

63
94
95
+
Full code is available here: [Function_approximation.py](https://github.com/sichkar-valentyn/Machine_Learning_in_Python/tree/master/Codes/Function_approximation.py)
0 commit comments