运行时异常。无法评估lambda。 Lambda工作者不能不开始

时间:2016-04-12 12:10:22

标签: python lambda sentiment-analysis graphlab

我是初次使用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工人无法启动

1 个答案:

答案 0 :(得分:0)

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

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