我想用python來 頻繁項目挖掘(一種大數(shù)據(jù)挖掘算法)來數(shù)據(jù)挖掘一個文件中的數(shù)據(jù)。數(shù)據(jù)量很大,用網(wǎng)上查到的代碼編寫好了以后,運行結果為“ array = np.zeros((len(X), len(self.columns_)), dtype=bool)? MemoryError”我不知道該怎么解決這個問題。代碼是正確的,因為如果將數(shù)據(jù)量減小就可以運行出來了,但是數(shù)據(jù)量變成原來那樣就顯示內存錯誤我的代碼很簡單:import pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom mlxtend.preprocessing import TransactionEncoderfrom mlxtend.frequent_patterns import apriori, association_rulesstudent_list = []file_handler =open('D:\lab\lab1\kosarak.dat',mode='r')?contents = file_handler.readlines()for name in contents:? ? name = name.strip('\n')? ? list_1 = name.split(' ')? ? student_list.append(list_1)te = TransactionEncoder()?te_ary = te.fit(student_list).transform(student_list)?df = pd.DataFrame(te_ary, columns=te.columns_)?frequent_itemsets = apriori(df, min_support=0.1, use_colnames=True)?print (frequent_itemsets)
python提示“MemoryError”錯誤怎么辦?
suxiao
2019-12-08 05:04:53