Skip to main content

Rede Neural Artifical Evolucionária

Project description

RNAE

Rede Neural Artificial Evolucionária

Instalation

$ pip install rnea

ou

$ python setup.py install

Utilização

from numpy.random import shuffle
from numpy import array

from pygenec import binarray2int

from rnae import RNAE
from rnae import IRIS as dados
from rnae import IRIS_NAME


#Normalização dos dados de entrada

entrada = dados[1:,0:-1].astype(float)
for k in range(entrada.shape[1]):
    entrada[:, k] = ((entrada[:, k] - entrada[:, k].min()) /
                    (entrada[:, k].max() - entrada[:, k].min())
                    )

#Resultado esperado, em inteiro.

saidas = dados[1:,-1]

saidas = array([list(map(int, list("{0:2b}".format(int(s)).replace(" ", "0")))) for s in  saidas])
itrain = array(list(range(saidas.shape[0])))
shuffle(itrain)
etrain = entrada[itrain,:]
esaid = saidas[itrain, :]

n = int(esaid.shape[0] * 0.90)

neurons = [4, 4, 2]

rna = RNAE(neurons)
rna.treinamento(etrain[0:n, :], esaid[0:n, :],
             tpop=500, gens=1000, bits=16, pmut=0.1, pcruz=0.6, epidemia=150)

rna.salvar_modelo("./modelos/rnae_iris.txt")
rna = RNAE.carregar_modelo("./modelos/rnae_iris.txt")
pred = rna.propagacao(etrain[n:,:])
expct = esaid[n:]
expct = binarray2int(expct).reshape((expct.shape[0], 1))

pred = binarray2int(pred).reshape((expct.shape[0], 1))
print("\n")
print([IRIS_NAME[i] for i in pred.flatten().astype(int)])
print("\n")
print([IRIS_NAME[i] for i in expct.flatten().astype(int)])
print("\n")

accu = 100 * sum(pred == expct) / expct.size
print("Acuracia {} %".format(accu))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rnae, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size rnae-1.0.1-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size rnae-1.0.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page