1

Im trying to solve a machine learning problem with MLP. So I have this particular file with a lot of matrices each one with 21 rows and 43 columns,separated by ********, where first row is a simulation and the next 20 is the response(each column stand for an atribute, the names are written at the begging of the file but i deleted them because I dont think I need them). There is the code I've written so far (I know there s a better solution but I can't see it..) and I can't avoid this error.My logic was that: I separated the simulation and the response of the simulation in some arrays.

import numpy as np
f=open(r'C:\Users\Europa\Desktop\matrices.data')
atr=[line.rstrip('\n') for line in f]
natr=[s.replace('***************************','') for s in atr]
simulari=[]
for i in range(1,5678,22):
    simulari.append(natr[i])
matsimulari=[]
for i in range(2,5698,22):
    matsimulari.append(natr[i:(i+20)])
from sklearn import neural_network
#simulari2=[]
#matsimulari2=[]
#simulari2= ''.join(simulari)
#simulari3=[int(x) for x in simulari2]
#matsimulari2=','.join(map(str, matsimulari))
#matsimulari3=[str(v) for v in matsimulari2]
##print(matsimulari[1])

date_train=[simulari[1:100]]

etichete_train=[matsimulari[1:100]]

date_test=[simulari[101:250]]

clf = neural_network.MLPClassifier()

clf.fit(date_train, etichete_train)

predictii = clf.predict(date_test)
mrpickle
  • 11
  • 1

0 Answers0