【发布时间】:2016-08-03 01:00:19
【问题描述】:
我是 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 工作人员无法启动
【问题讨论】:
-
这就是全部吗?感觉RuntimeError应该是有原因的
-
@rainz 这就是我得到的
-
我也在学习这门课程,我使用的是 GraphLab Create 1.8.5。我复制并粘贴了您的代码并使用了 amazon_baby.gl 数据,它工作得很好……您的版本是什么?可以
pip install -U graphlab-create吗?
标签: python lambda sentiment-analysis graphlab