The InvalidArgumentError
occurred because Keras's predict method often requires dense arrays instead of sparse matrix format produced by TfidfVectorizer
. Converting X_test_tfid
to a dense NumPy array with .toarray()
resolves this. Please review the gist where we attempted to solve this issue using sample data.