AI/데이터 분석 3

Bag of Words (BoW)란 ?

Bag of Words 란 단어들의 출현 빈도를 수치화한 표현 방법. def BoW(sentences): dict_bow = {} for sentence in sentences: split_sentence = sentence.split(" ") for word in split_sentence: if word not in dict_bow.keys(): dict_bow[word] = 1 else: dict_bow[word] = dict_bow[word] + 1 return dict_bow sentences = [ "빨간 사과 노란 바나나 초록 메론", "주황 오렌지 노란 바나나 빨간 자두" ] print(BoW(sentences)) #{'빨간': 2, '사과': 1, '노란': 2, '바나나': 2, '초록..

AI/데이터 분석 2024.02.24

왁물원 카페 크롤링 및 우왁굳즈 워드클라우드

아직 완벽하지 않지만 제목, 작성자, 링크, 내용 크롤링은 전부 가능하고 버튼 연동만 해주면 된다. 이런식으로 크롤링된다. def extract_word(text): hangul = re.compile('[^가-힣]') result = hangul.sub(' ', text) return result 특수문자 제거하기 spacing = Spacing() !pip install git+https://github.com/haven-jeon/PyKoSpacing.git 다운 받고 띄어쓰기되어 있지 않은 문자열들을 전부 해준다. 완벽하게 되진 않음.. okt = Okt() words = " ".join(df['content'].tolist()) words = okt.morphs(words,stem=True) re..

AI/데이터 분석 2022.12.21

[DACON] 따릉이 데이터 분석 EDA

환경 : Colab from google.colab import drive drive.mount('/content/drive') !sudo apt-get install -y fonts-nanum !sudo fc-cache -fv !rm ~/.cache/matplotlib -rf 구글 드라이브를 통해 파일을 업로드 할 것이다. 그리고 코랩에서의 그래프에서 한글이 깨지는 것을 방지하기 위해 위 폰트들을 설치한 후 런타임 재실행한다. import pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns import warnings warnings.filterwarnings(action='ignore') palett..

AI/데이터 분석 2022.11.29
728x90
반응형
LIST