Пример #1
0
from neural import dataset as db
from neural import graphic as gp

from sklearn.model_selection import KFold
from sklearn.model_selection import train_test_split as split
import numpy as np

REALIZATIONS = 20
N_SPLITS = 5
database = db.dataset()
x_data, y_data = database.regressionDatabase()
graph = gp.Graph()

# j = nn.test(x, activation="linear")

grid = sg.SearchGrid(type="regression")

RMSE, MSE, WEIGTHS = [], [], []

for i in range(REALIZATIONS):

    x_train, x_test, y_train, y_test = split(x_data, y_data, test_size=0.2)
    nn = network.mlp(inputs=x_train,
                     outputs=y_train,
                     outLayer=1,
                     hiddenLayer=4,
                     eta=0.01)
    nn.trainer(1000, activation="linear")

    print(" > -----------------------------------------------")
    print(" > Realizações: ", i + 1)
Пример #2
0
from neural import cross_validation as cv
from neural import dataset as db
from neural import search_grid as sg

import numpy as np
from sklearn.model_selection import KFold
from sklearn.model_selection import train_test_split as split

N_SPLITS = 5
REALIZATIONS = 20

# import dataset
database = db.dataset()
x_data, y_data = database.dermatology()
# search grid
grid = sg.SearchGrid()

print("## Problema: DERMATOLOGY ")
print("## Treinamento: KFold - K:", N_SPLITS)
for epoch in grid.getEpochs():
    for eta in grid.getEtas():
        for neuron in grid.getNeurons():

            x_train, x_test, y_train, y_test = split(x_data,
                                                     y_data,
                                                     test_size=0.2)

            TAXAS_FINAL = []

            print("---------------------------------------------------")
            print(" > Epoch", epoch, "Eta:", eta, "Neurons:", neuron)