Skip to content

Commit

Permalink
version para entregar ob5
Browse files Browse the repository at this point in the history
  • Loading branch information
camilomarino committed Dec 3, 2020
1 parent a596e10 commit a5ff3e9
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
Binary file added ob5/TAO_ob5.pdf
Binary file not shown.
Binary file added ob5/code.zip
Binary file not shown.
43 changes: 28 additions & 15 deletions ob5/ej2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@
def vect2img(x):
return np.transpose((x[:-1].reshape(3, 256,256)), (2,1,0))


plt.figure()
plt.imshow(vect2img(gatos[:, 0]))
ks = [20, 23]
for k in ks:
plt.figure()
plt.axis(False)
plt.title(t:=f'Conejo. Indice {k}')
plt.imshow(vect2img(gatos[:, k]))
plt.savefig(t+'.png')

ks = [21,26]
for k in ks:
plt.figure()
plt.axis(False)
plt.title(t:=f'Gato. Indice {k}')
plt.imshow(vect2img(conejos[:, k]))
plt.savefig(t+'.png')
#%%

plt.figure()
Expand Down Expand Up @@ -75,16 +87,16 @@ def F(x, y, a, n):
label = lambda x: 'gato' if x<0.5 else 'conejo'

print('GATOS')
for k in range(0,10):
for k in range(0,20):
gato = gatos[:, k:k+1]
v = a.T@gato
print(v, label(v))
print(k, v, label(v))

print('\n\nCONEJOS')
for k in range(0,10):
for k in range(0,20):
conejo = conejos[:, k:k+1]
v = a.T@conejo
print(v, label(v))
print(k, v, label(v))
#%%
# Test
label = lambda x: 'gato' if x<0.5 else 'conejo'
Expand All @@ -93,19 +105,20 @@ def F(x, y, a, n):
for k in range(20,30):
gato = gatos[:, k:k+1]
v = a.T@gato
print(v, label(v))
print(k, v, label(v))

print('\n\nCONEJOS')
for k in range(20,30):
conejo = conejos[:, k:k+1]
v = a.T@conejo
print(v, label(v))
print(k, v, label(v))

#%%
plt.figure(figsize=(7,7))
plt.rcParams['font.size'] = 18
plt.figure(figsize=(11,7))
for k in range(20):
plt.scatter(gatos[:,k]@a, k, c='g', label='gatos')
plt.scatter(conejos[:,k]@a, k, c='r', label='gatos')
plt.scatter(gatos[:,k]@a, k, c='g', label='gatos', s=70, marker='o')
plt.scatter(conejos[:,k]@a, k, c='r', label='gatos', s=70, marker='x')
plt.axvline(0.5)
plt.legend(['linea divisoria', 'gatos', 'conejos'])
plt.title('Ejemplos de train')
Expand All @@ -115,10 +128,10 @@ def F(x, y, a, n):
plt.savefig('figures/ej2_train')

#%%
plt.figure(figsize=(7,7))
plt.figure(figsize=(11,7))
for k in range(20,30):
plt.scatter(gatos[:,k]@a, k, c='g', label='gatos', marker='o')
plt.scatter(conejos[:,k]@a, k, c='r', label='gatos', marker='x')
plt.scatter(gatos[:,k]@a, k, c='g', label='gatos', s=70, marker='o')
plt.scatter(conejos[:,k]@a, k, c='r', label='gatos', s=70, marker='x')
plt.axvline(0.5)
plt.legend(['linea divisoria', 'gatos', 'conejos'])
plt.title('Ejemplos de validación')
Expand Down
Binary file added ob5/figures/Conejo. Indice 20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ob5/figures/Conejo. Indice 23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ob5/figures/Gato. Indice 21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ob5/figures/Gato. Indice 26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed ob5/figures/ej2_test.png
Binary file not shown.

0 comments on commit a5ff3e9

Please sign in to comment.