0

I customize the sentiment analysis code to my needs using a YouTube video from someone who posted this code to the public and ran into a serious problem. All advice on solving this issue does not help me, I do not know what to do, the get_fearutes_name method also does not work

import re
import time
from tqdm import tqdm
 
import numpy as np
import pandas as pd
 

import matplotlib.pyplot as plt
import plotly.graph_objects as go
from plotly.subplots import make_subplots

import nltk
from nltk.corpus import stopwords as nltk_stopwords
from pymystem3 import Mystem
from wordcloud import WordCloud

from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.model_selection import cross_validate
from sklearn.model_selection import train_test_split

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import *



app_counter = CountVectorizer(ngram_range=(1, 1))
app_count = app_counter.fit_transform(app_reviews_df['text_clear'])
app_count.toarray().sum(axis = 0)
app_count.get_feature_names_out().shape
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-67-5e08d135d61f> in <module>
----> 1 app_count.get_feature_names_out().shape

/usr/local/lib/python3.8/dist-packages/scipy/sparse/base.py in __getattr__(self, attr)
    685             return self.getnnz()
    686         else:
--> 687             raise AttributeError(attr + " not found")
    688 
    689     def transpose(self, axes=None, copy=False):

AttributeError: get_feature_names_out not found
sophros
  • 14,672
  • 11
  • 46
  • 75
  • Did you read [CountVectorizer' object has no attribute 'get_feature_names_out'](https://stackoverflow.com/questions/70640923/countvectorizer-object-has-no-attribute-get-feature-names-out)? – Stef Jan 21 '23 at 10:35
  • Also note, the line `app_count.toarray().sum(axis = 0)` is useless unless you store the result in a variable, or use it somehow. For instance, `s = app_count.toarray().sum(axis = 0)` would make sense. But just `app_count.toarray().sum(axis = 0)` without saving the result is useless: you're asking the computer to perform a calculation, but then you're throwing the result of that calculation out the window without even looking at it. – Stef Jan 21 '23 at 10:36
  • 1
    problem was in wrong used variable, needed to use app_counter and not app_count app_count.toarray().sum(axis = 0).shape there was, sorry all this placed in google collab reaserch, some things dont needed to put in variables – HOTPEPE Jan 21 '23 at 11:02
  • Does this answer your question? [How to extract feature names from sklearn pipeline transformers?](https://stackoverflow.com/questions/71830448/how-to-extract-feature-names-from-sklearn-pipeline-transformers) – sophros Jan 23 '23 at 10:00

0 Answers0