본문 바로가기

반응형

토픽 모델링

(5)
토픽 모델링으로 주제 찾기 (5) 7.4 토픽 트렌드로 시간에 따른 주제의 변화 알아내기 !pip install wget import os import wget import ssl data_dir = 'data' url = 'https://s3.ap-northeast-2.amazonaws.com/data10902/petition/petition_sampled.csv' ssl._create_default_https_context = ssl._create_unverified_context if not os.path.exists(data_dir): os.mkdir(data_dir) wget.download(url, data_dir) """ /usr/local/lib/python3.10/dist-packages/ipykernel/ipkernel..
토픽 모델링으로 주제 찾기 (4) 7.3 Gensim을 이용한 토픽 모델링 7.3.2 혼란도와 토픽 응집도를 이용한 최적값 선택 from gensim.models import CoherenceModel cm = CoherenceModel(model=model, corpus=corpus, coherence='u_mass') coherence = cm.get_coherence() print(coherence) """ /usr/local/lib/python3.10/dist-packages/ipykernel/ipkernel.py:283: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the re..
토픽 모델링으로 주제 찾기 (3) 7.3 Gensim을 이용한 토픽 모델링 7.3.1 Gensim 사용법과 시각화 Gensim: 토픽 모델링을 비롯해 의미적인 자연어 처리를 위한 다양한 라이브러리 !pip install --upgrade gensim import nltk nltk.download('stopwords') """ [nltk_data] Downloading package stopwords to /root/nltk_data... [nltk_data] Unzipping corpora/stopwords.zip. True """ # 필요한 library들을 import from nltk.corpus import stopwords from nltk.tokenize import RegexpTokenizer cachedStopWords =..
토픽 모델링으로 주제 찾기 (2) 7.2 사이킷런을 이용한 토픽 모델링 7.2.1 데이터 준비 from sklearn.datasets import fetch_20newsgroups categories = ['alt.atheism', 'talk.religion.misc', 'comp.graphics', 'sci.space', 'comp.sys.ibm.pc.hardware', 'sci.crypt'] #학습 데이터셋을 가져옴 newsgroups_train = fetch_20newsgroups(subset='train', categories=categories) print('#Train set size:', len(newsgroups_train.data)) print('#Selected categories:', newsgroups_train.t..
토픽 모델링으로 주제 찾기 (1) 7.1 토픽 모델링과 LDA의 이해 7.1.1 토픽 모델링이란? 텍스트 마이닝 기법 중에서 가장 많이 활용되는 기법 중 하나로, 다양한 문서 집합에 내재한 토픽, 주제를 파악할 때 사용하는 방법 구체적이고 명확하게 의미를 보여줄 수 있음 7.1.2 LDA 모형의 구조 LDA(Latent Dirichlet Allocation): 토픽 모델리에 가장 널리 쓰이는 기본적인 알고리즘 7.1.3 모형의 평가와 적절한 토픽 수의 결정 Perplexity: 혼란도, 혼잡도, 특정한 확률 모형이 실제로 관측되는 값을 얼마나 유사하게 예측해내는지를 평가할 때 사용, 값이 작을수록 좋음 토픽 응집도(coherence): 각 토픽에서 상위 비중을 차지하는 단어들이 의미적으로 유사한지를 나타내는 척도, 값이 클수록 좋음 토픽..

반응형