+5 votes
in Programming Languages by (71.8k points)

I am trying to stack 3 sparse matrices vertically. But the following code is giving an error: TypeError: vstack() got multiple values for argument 'format'.

 X_te = sparse.vstack((X1[teidx], X0_tr[teidx]), X0_te, format='csr')  # merge the data

What's wrong with this code? 

1 Answer

+1 vote
by (348k points)
selected by
 
Best answer

You have the variable "X0_te" outside the parenthesis. That's why it's giving error.

Make the following change and it should fix the error.

From

X_te = sparse.vstack((X1[teidx], X0_tr[teidx]), X0_te, format='csr')  # merge the data

to

X_te = sparse.vstack((X1[teidx], X0_tr[teidx], X0_te), format='csr')  # merge the data


...