uczenie_maszynowe_zadania/cw_3/Untitled.ipynb
2023-07-04 20:42:14 +02:00

71 KiB

import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv('fires_thefts.csv', names=['fires','thefts'])
print(data)
    fires  thefts
0     6.2      29
1     9.5      44
2    10.5      36
3     7.7      37
4     8.6      53
5    34.1      68
6    11.0      75
7     6.9      18
8     7.3      31
9    15.1      25
10   29.1      34
11    2.2      14
12    5.7      11
13    2.0      11
14    2.5      22
15    4.0      16
16    5.4      27
17    2.2       9
18    7.2      29
19   15.1      30
20   16.5      40
21   18.4      32
22   36.2      41
23   39.7     147
24   18.5      22
25   23.3      29
26   12.2      46
27    5.6      23
28   21.8       4
29   21.6      31
30    9.0      39
31    3.6      15
32    5.0      32
33   28.6      27
34   17.4      32
35   11.3      34
36    3.4      17
37   11.9      46
38   10.5      42
39   10.7      43
40   10.8      34
41    4.8      19
%matplotlib notebook
plt.scatter(data.fires,data.thefts)
plt.show()
def loss_function(m, b, points):
    total_loss = 0
    for i in range(len(points)):
        x = points.