小编shi*_*mar的帖子

AttributeError:“NoneType”对象没有属性“lower”

我试图在标签数据上实现 CountVectorizer 但每次它都会抛出属性错误,尝试了所有方法但仍然无法理解为什么会出现此错误。这是我的代码,

vectorizer = CountVectorizer(tokenizer = lambda x: x.split(" "))

tag_dtm = vectorizer.fit_transform(tag_data['Tags'])
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

`AttributeError                            
Traceback (most recent call last)
<ipython-input-53-7a05ab3b6655> in <module>()

      7 # and learns the vocabulary; second, it transforms our training data
      8 # into feature vectors. The input to fit_transform should be a list of strings.                  
 ----> 9 tag_dtm = vectorizer.fit_transform(tag_data['Tags'])


3 frames


/usr/local/lib/python3.6/dist-packages/sklearn/feature_extraction/text.py in _preprocess(doc, accent_function, lower)
     
     66     """
      
     67     if lower:

     ---> 68         doc = doc.lower()
     
     69     if accent_function is not None:

     70 …
Run Code Online (Sandbox Code Playgroud)

python machine-learning python-3.x scikit-learn

2
推荐指数
1
解决办法
2585
查看次数