1

我是graphlab和python的新手,试图完成一项任务,问题是对选定的单词进行情感分析,我应该为产品矩阵中的每个选定单词创建一个新列,条目是这样的单词出现的次数,所以我为单词“wordCount_select”创建了一个函数

import graphlab
products = graphlab.SFrame('amazon_baby.gl')
products['word_count'] = graphlab.text_analytics.count_words(products['review'])
selected_words = ['awesome', 'great', 'fantastic', 'amazing', 'love', 'horrible', 'bad', 'terrible', 'awful', 'wow', 'hate']

功能

def wordCount_select(wc,selectedWord):
    if selectedWord in wc:
        return wc[selectedWord]
    else:
        return 0    


for word in selected_words:
    products[word] = products['word_count'].apply(lambda wc: wordCount_select(wc, word))

但我收到这个错误

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-494af1bfc2ab> in <module>()
      7 
      8 for word in selected_words:
----> 9     products[word] = products['word_count'].apply(lambda wc: wordCount_select(wc, word))

C:\Users\elginelijahsoft\Anaconda2\envs\dato-env\lib\site-packages\graphlab\data_structures\sarray.pyc in apply(self, fn, dtype, skip_undefined, seed)
   1699 
   1700         with cython_context():
-> 1701             return SArray(_proxy=self.__proxy__.transform(fn, dtype, skip_undefined, seed))
   1702 
   1703 

C:\Users\elginelijahsoft\Anaconda2\envs\dato-env\lib\site-packages\graphlab\cython\context.pyc in __exit__(self, exc_type, exc_value, traceback)
     47             if not self.show_cython_trace:
     48                 # To hide cython trace, we re-raise from here
---> 49                 raise exc_type(exc_value)
     50             else:
     51                 # To show the full trace, we do nothing and let exception propagate

RuntimeError: Runtime Exception. Cannot evaluate lambda. Lambda workers cannot not start.

任何想法我做错了什么以及为什么 lambda 工作人员无法启动

4

1 回答 1

0

我在机器学习课程中也遇到了同样的问题。我有最新的 Graphlab

我怀疑这是一个内存问题(没有足够的内存来加载该数据集并应用 lambda 函数)。关闭大多数其他东西(浏览器......)后,该命令运行良好。

于 2016-12-02T04:19:24.777 回答