๐ฅ ์ค๋ฅ
ํ ํฝ ๋ชจ๋ธ๋ง ์์ ์ค์ต ์ค 'TfidfVectorizer' object has no attribute 'get_feature_names'๋ผ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
โ ํด๊ฒฐ๋ฐฉ๋ฒ
get_feature_names๋ฅผ get_feature_names_out()๋ก ๋ณ๊ฒฝํ๋ค.
๐ ์ฝ๋
# sklearn ๋ฒ์ ์ด์๋ก ๋ฉ์๋ ๋ณ๊ฒฝ
terms = vectorizer.get_feature_names_out()
# ๊ฐ 20๊ฐ ํ์ 1,000๊ฐ ์ด ์ค ๊ฐ์ฅ ๊ฐ์ด ํฐ 5๊ฐ๋ฅผ ์ฐพ์์ ๋จ์ด๋ก ์ถ๋ ฅ
def get_topics(components, feature_names, n=5):
for idx, topic in enumerate(components):
print("Topic %d:" % (idx+1), [(feature_names[i], topic[i].round(5)) for i in topic.argsort()[:-n - 1:-1]])
get_topics(svd_model.components_,terms)
๐ ์ฐธ๊ณ .
https://noanomal.tistory.com/461
AttributeError: 'TfidfVectorizer' object has no attribute 'get_feature_names'
AttributeError: 'TfidfVectorizer' object has no attribute 'get_feature_names' get_feature_names()๋ sklearn 0.24 ๋ฒ์ ์ดํ์์ ์ฌ์ฉํ๋ ๋ฉ์๋ ์ ๋๋ค. 1.0 ๋ฒ์ ๋ถํฐ๋ get_feature_names_out()๋ก ๋ณ๊ฒฝ๋์์ต๋๋ค. get_feature_names
noanomal.tistory.com
728x90