0

I used the following to make predictions from my keras model:

# fit the keras model on the dataset
ker_model.fit(xtrain, ytrain, epochs=200, verbose=0)    
predictions = ker_model.predict(xtest)
predictions = predictions.astype(int)
predictions.mean()
predictions

However, the problem is, is that my predictions are in a nested array list. Meaning it looks as followed:

array([[0],
       [0],
       [0],
       [1],
       [1]])

How can I either ensure that my prediction is not eventually ending up in such a nested list, or unlist the predictions?

What I want my output to look like is:

array([0, 0, 0, 1, 1])
Kylian
  • 319
  • 2
  • 14
  • Are you asking how to flatten a nested list? https://stackoverflow.com/questions/20112776/how-do-i-flatten-a-list-of-lists-nested-lists EDIT: From the code, it is not clear what `aout` is. – sarema Jan 07 '22 at 15:50

1 Answers1

1

you can use predictions =predictions.ravel() or predictions =predictions.squeeze()

Yundes11
  • 26
  • 2