I have a training set called data.txt
stored for my AI.
The AI should get 5 X
inputs each run and one solution/answer which is the array y
.
The array X
should look like following:
[[x1,x2,x3,x4,x5],[x1,x2....x5],....]
I tested it with 2 * 5 inputs and following came out:
[2.21600000e+05 2.02000000e+03 2.43738600e+06 1.09990343e+01
9.11552347e-01 2.21600000e+05 2.02000000e+03 2.43738600e+06
1.09990343e+01 9.11552347e-01 1.00000000e+01 1.00000000e+00
5.72000000e+02 5.72000000e+01 1.00000000e+01]
What I want is following:
[[221600,2020,2437386,10.999034296028881,0.9115523465703971],
[10,1,572,57.2,10.0]]
The answer array y
is fine. It is: [0.,0.]
The code:
import numpy
X=np.array([])
y=np.array([])
lineX=np.array([])
i=0
linenumber=0
with open('data.txt') as file:
for line in file:
dataline=line.rstrip()
dataline=float(dataline)
i+=1
linenumber+=1
if i != 6:
lineX=np.append(lineX,dataline)
else:
X=np.append(X,lineX,axis=0)
i=0
y=np.append(y,dataline)
print(X)
print(y)
And the file (the original has about 800 lines so I shortened it)
221600
2020
2437386
10.999034296028881
0.9115523465703971
0
10
1
572
57.2
10.0
0
The first five lines in the file are the inputs x1-x5 and the sixth line is y (the answers) and so on.
How can I get it working?