Documente Academic
Documente Profesional
Documente Cultură
Aprendizado de Máquina
Professor: Tiago Buarque
1. Importações e Constantes
In [1]: #bibliotecas
from IPython.display import Image
import numpy as np
import pandas as pd
import math
Out[203]:
1 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
In [207]: Image(folder+"imgs\\02.png")
Out[207]:
In [210]: Image(folder+"imgs\\07.png")
Out[210]:
In [211]: Image(folder+"imgs\\03.png")
Out[211]:
return _theta
2 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
theta_calculado = []
a = (2 * kernelGaussian(distanciaEuclidiana(x,y)))/math.sqrt(2 * math.pi)
for j in range(len(x)):
b = x[j]
c = y[j]
#derivada 1
d1_1 = 2 * c
d1_22 = -(math.pow(b,2) + 2 * b * c * math.pow(theta[j],2) - math.pow(c
, 2) * math.pow(theta[j], 4))
d1_2 = math.pow(math.e, d1_22)
d1_3 = theta[j] * (b - (c * math.pow(theta[j], 2)))
d1 = (d1_1 * d1_2 * d1_3) / math.pi
#derivada 2
d2_1 = 2 * a * c
#derivada 3
d3 = lambd * 2 * theta[j]
theta_calculado.append(d1 - d2 + d3)
return (np.array(theta_calculado))
In [214]: Image(folder+"imgs\\04.png")
Out[214]:
3 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
kernel = []
#for d in dataset:
# kernel.append(kernelDensity(dataset, d, band))
for i in range(len(dataset)-1):
j = i + 1
kernel.append(kernelGaussian(distanciaEuclidiana(dataset[i], dataset[j]
)))
#novos_thetas = []
#otimizador aqui
#for i in range(len(dataset)-1):
# j = i + 1
# novos_thetas.append(updateRule(dataset[i], dataset[j], theta[i], l
ambd)) #regra de atualizacao de theta
for i in range(len(dataset)-1):
j = i + 1
novos_thetas = updateRule(dataset[i], dataset[j], theta, lambd)
print(novos_thetas)
_theta = theta
theta = novos_thetas
alfa = theta ** 2
return alfa
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
Out[217]: False
4 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
Os gráficos a seguir indicam a qualidade da seleção de atributos feita pelo DPFS e seus concorrentes. Na linha horizontal
temos o número de features selecionadas e no eixo vertical temos a acurácia do classificador quando usamos apenas as
features selecionadas do dataset.
In [218]: Image(folder+"imgs\\05.png")
Out[218]:
Os gráficos seguintes mostram a saída gerada pelo algoritmo DPFS. Para cada dataset, temos as features no eixo
horizontal e o peso correspondente no eixo vertical. Features com pesos maiores tendem a serem mais representativas
para a distribuição do dados.
5 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
In [219]: Image(folder+"imgs\\06.png")
Out[219]:
Out[220]:
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 14.23 1.71 2.43 15.6 127 2.80 3.06 0.28 2.29 5.64 1.04 3.92 1065
1 1 13.20 1.78 2.14 11.2 100 2.65 2.76 0.26 1.28 4.38 1.05 3.40 1050
2 1 13.16 2.36 2.67 18.6 101 2.80 3.24 0.30 2.81 5.68 1.03 3.17 1185
3 1 14.37 1.95 2.50 16.8 113 3.85 3.49 0.24 2.18 7.80 0.86 3.45 1480
4 1 13.24 2.59 2.87 21.0 118 2.80 2.69 0.39 1.82 4.32 1.04 2.93 735
6 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
Bandwidth: 0.21533827903669653
Lambda: 1e-05
7 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
In [224]: algorithm(x, H, L)
8 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/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0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
9 of 10 12/07/2018 10:07
Replicação Artigo file:///C:/Users/EMANUEL/AppData/Local/Temp/Replicação Artigo-1...
Out[224]: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
Out[76]:
0 1 2 3 4 5 6 7 8 9 ... 22 23
0 842302 M 17.99 10.38 122.80 1001.0 0.11840 0.27760 0.3001 0.14710 ... 25.38 17.33 184.60
1 842517 M 20.57 17.77 132.90 1326.0 0.08474 0.07864 0.0869 0.07017 ... 24.99 23.41 158.80
2 84300903 M 19.69 21.25 130.00 1203.0 0.10960 0.15990 0.1974 0.12790 ... 23.57 25.53 152.50
3 84348301 M 11.42 20.38 77.58 386.1 0.14250 0.28390 0.2414 0.10520 ... 14.91 26.50 98.87
4 84358402 M 20.29 14.34 135.10 1297.0 0.10030 0.13280 0.1980 0.10430 ... 22.54 16.67 152.20
5 rows × 32 columns
In [77]: x = data.iloc[:,2:].values
y = data.iloc[:,0:1].values
Out[78]: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
10 of 10 12/07/2018 10:07