-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
49 lines (37 loc) · 1.29 KB
/
Copy pathutils.py
File metadata and controls
49 lines (37 loc) · 1.29 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
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 24 20:13:30 2019
@author: victor
"""
import numpy as np
from matplotlib import pyplot as plt
import os
from os.path import join
def euclidian(a, b):
"""
Calculate the euclidian distance between two points.
Args:
a: Point a
b: Point b
Returns:
Return the euclidian distance between the two points.
"""
x = np.asarray(a)
y = np.asarray(b)
return np.sqrt(np.sum(np.power(x - y, 2)))
def plot_plain_separator(model,
x,
grid_size=1000,
grid_range=(-5, 15),
save=None,
path=join('..', 'Artigo_1_RNA', 'Imagens')):
x_lab = np.linspace(grid_range[0], grid_range[1], num=grid_size)
y_lab = np.linspace(grid_range[0], grid_range[1], num=grid_size)
x1, x2 = np.meshgrid(x_lab, y_lab)
x_grid = np.transpose(np.vstack([x1.flatten(), x2.flatten()]))
z = model.predict(x_grid)
z = z.reshape([1000,1000])
plt.contour(x1, x2, z, levels=[0], colors=('cyan',), linewidths=(2.5,))
# plt.contour(x1, x2, z, linewidths=(2,))
if save:
plt.savefig(join(fr'{path}', fr'{save}.png'))