I am trying to train a classification Model to classify Images, but my images here are Numpy arrays of 1's and 0's as shown in the Image,
For now, I have tried,
x1_data=[]
def create_array(columns=5,rows=5,randomness=.3):
board = np.zeros([rows,columns],dtype='int64')
for i in range(rows):
for j in range(columns):
if np.random.random() <= randomness:
board[i,j] = 1
return board
for i in range(5):
x1_data.append(create_array())
which gives me 5 arrays `
array([[[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[1, 0, 0, 0, 0],
[0, 0, 0, 0, 1],
[0, 0, 0, 0, 1]],
[[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 1, 0],
[0, 1, 0, 0, 0]],
[[1, 0, 0, 1, 0],
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 0]],
[[0, 0, 0, 0, 0],
[1, 0, 0, 1, 1],
[0, 0, 1, 1, 1],
[0, 0, 0, 0, 0],
[0, 0, 1, 0, 1]],
[[0, 0, 0, 0, 1],
[0, 0, 0, 0, 0],
[0, 0, 0, 1, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 1]],
[[1, 0, 0, 1, 1],
[0, 0, 1, 1, 0],
[0, 0, 1, 0, 0],
[1, 0, 0, 0, 0],
[1, 1, 0, 0, 0]]]
For class A, similarly I generated 5 arrays for class B and then stacked them as a single X array.
My output y is:
y = np.random.choice([0, 1], size=(10,), p=[1./3, 2./3])
array([0, 1, 1, 1, 1, 0, 0, 0, 0, 0])
How do I preprocess this Data to train on an MLP in sklearn I am getting this error
clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1)
clf.fit(g, h)
#Error
Found array with dim 3. Estimator expected <= 2.