I would like to create a neural network that returns 1 (one) for a specific case and 0 (zero) for all the others.
The idea would be:
import numpy as np
import pandas as pd
from sklearn.preprocessing import MaxAbsScaler
from sklearn.neural_network import MLPClassifier
# transforma o dado (3000 valores) em um dataframe
traco = pd.read_fwf('2_traco48.txt', header=None)
# recorta o dado em janelas com 100 valores
for i in range(0,2901):
janela[i] = traco[i:i+100]
print janela[i]
# lista com todas as janelas
janelas [janela0, janela1, janela2, ... janela 2900, janela2901]
# saida desejada (caso hipotetico, a ultima saida sera 1 e as outras seriam 0)
saida = [0, 0, 0, 0, 0, ... 0, 0, 0, 1]
# treinando
ann = MLPClassifier(solver='lbfgs', hidden_layer_sizes=(10, 10), activation='logistic', alpha=1e-5,)
print(ann.fit(janelas, saida))
I have not yet done the parts of "trimming" the windows or specifying the list with the position of 1 and zeros, in addition to normalizing the data to be between 1 and -1.
Testing a simpler example, with just 4 "windows" with 100 input values each window, to see how it would be running, I came across a problem:
data0 = pd.read_fwf('data0.txt', index=False)
data1 = pd.read_fwf('data1.txt', index=False)
data2 = pd.read_fwf('data2.txt', index=False)
data3 = pd.read_fwf('data3.txt', index=False)
dado_treino = [data0, data1, data2, data3]
treino_superv = [0, 0, 0, 1]
print(ann.fit(dado_treino, treino_superv))
I've converted the 'data [i] .txt' files from 2D to 1D, but it's not working ...
ValueError: cannot copy sequence with size 99 to array axis with dimension 1
I believe the error lies in converting the data from 2D to 1D with the pandas, but it may be something on the network, or something conceptually wrong.