简体   繁体   中英

Unable to allocate 29.0 MiB for an array with shape (3, 1267618) and data type float64

from sklearn.naive_bayes import MultinomialNB 
nb = MultinomialNB(alpha = 10) 
nb.fit(X_train_dtm, y_train)

It shows memory error while running this code.

So, a MemoryError will occur when Python can't get a block of memory from the operating system. It seems unusual to be unable to allocate 29MB unless you're running this on a tiny computer.

One fix would be to use the partial_fit method over chunks of the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM