Why do I keep getting the "AttributeError: lower not found" error when using a Vectorizer command?

31 views Asked by At

I'm trying to set up a text classification model, that can split text into two categories. I've checked the shape of my arrays, and they're of the (n, ) format. But when I run my vectorizer command, I seem to run into this error. Any advice would be appreciated :)

x,y = dfclean\['text'\],dfclean\['class'\]

x.shape

> output = (19998,)
* * *

vectorizer = TfidfVectorizer(min_df=50,max_features=5000)

x =  vectorizer.fit(x)
> AttributeError: lower not found
1

There are 1 answers

3
Lila On

The Attribute error of type lower is probably occurring because you are trying to fit the vectorizer on your text data directly. I suggest to try to use the fit_transform method instead of the fit method. Such as:

x_tfidf = vectorizer.fit_transform(x)