I have a list of arrays that contain the same rows, but different columns. I printed out the shape of the array and checked that they have same rows.
print ("Type x_test : actual",type(x_dump),x_dump.shape, type(actual), actual.shape, pred.shape)
cmp = np.concatenate([x_test,actual,pred],axis = 1)
('Type x_test : actual', <type 'numpy.ndarray'>, (2420L, 4719L), <type 'numpy.ndarray'>, (2420L,), (2420L,))
This gives me an error:
ValueError: all the input arrays must have same number of dimensions
I tried to replicate this error using the below commands:
x.shape,x1.shape,x2.shape
Out[772]: ((3L, 1L), (3L, 4L), (3L, 1L))
np.concatenate([x,x1,x2],axis=1)
Out[764]:
array([[ 0, 0, 1, 2, 3, 0],
[ 1, 4, 5, 6, 7, 1],
[ 2, 8, 9, 10, 11, 2]])
I dont get any error here. Is anyone facing similar issue ?
EDIT 1: Right after writing this question, I figured out that the dimensions are different. @Gareth Rees: has explained beautifully the different between numpy array (R,1) and (R,) here.
Fixed using:
# Reshape and concatenate
actual = actual.reshape(len(actual),1)
pred = pred.reshape(len(pred),1)
EDIT 2: Marking to close this answer as a duplicate of Difference between numpy.array shape (R, 1) and (R,).