看板 Python 關於我們 聯絡資訊
大家好 我最近練習做 term-document-matrix 用到的 library是 : pandas sklearn 我的矩陣說起來並不會很大 大概 (55534, 3117) 數字再 0~503 之間(min,max) 不過我在做 相乘的時候 jupyter 都會卡很久就當掉了!!! 這行會卡很久 不知道問題會是出在哪裡呢? np.matmul(A,B) 底下是我的code 這個問題卡好久了QQ # ---------------- Code ----------------- # import import pandas as pd from sklearn.feature_extraction.text import CountVectorizer # 做 term-document-matrix vec = CountVectorizer() X = vec.fit_transform(contents_big_array) df = pd.DataFrame(X.toarray(), columns=vec.get_feature_names()) # 做矩陣 A = df.values.T B = df.values -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.45.101.55 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1531932953.A.86A.html
bibo9901: 55534x55534的float可能會超出記憶體了 07/19 00:58
TuCH: 你記憶體多少....看一下記憶體是不是爆炸了 07/19 01:15
55534*55534*64bit 好像差不多 22G了耶OAO 可以問一下這種大型矩陣大概要怎麼算嗎? 還是可以分開運算在結合起來? ※ 編輯: HenryLiKing (140.138.25.124), 07/19/2018 09:55:57
bibo9901: term-document frequency 一定是 sparse matrix啊 07/19 10:04
bibo9901: 直接拿X來乘不就好了嗎? 幹嘛轉array再轉dataframe? 07/19 10:06