본문 바로가기

kaggle14

[Kaggle] 통신사 이탈 고객 예측 #03(Classfication Model) 목차01. Decision Tree02. Logistic Regression03. Random Forest04. Gradient Boosting05. Naive-bayse06. k-NN07. 예측 성능 비교 01. Decision Tree Decision Tree 모델 학습# library settingfrom sklearn.tree import DecisionTreeClassifier, export_graphvizimport graphviz# X와 y 변수 선택X = df_encoded[feature_names]y = df_encoded[target_name]# Splitting the datasetX_train, X_test, y_train, y_test = train_test_split(X,.. 2024. 6. 27.
[Kaggle] 통신사 이탈 고객 예측 #02(EDA, 시각화) 목차01. Summary by class02. Histogram03. Heatmap04. Scatter plot 01. Summary by class 설명변수 및 목표변수 정의(추후 모델링할 때 편하게 사용하려고 정의해 뒀다)target_name = 'target'class_names=['No', 'Yes'] #(0 = no, 1=yes)feature_names=['account_length', 'international_plan', 'voice_mail_plan', 'number_vmail_messages', 'total_day_minutes', 'total_day_cal.. 2024. 6. 27.
[Kaggle] 통신사 이탈 고객 예측 #01(데이터 불러오기, 전처리) 목차01. Introduction02. 데이터 불러오기03. 데이터 전처리 01. Introduction 지도 학습(Machine Learning) 알고리즘을 사용하여 이탈 고객 예측 모델 개발 02. 데이터 불러오기 CSV 파일 읽어오기# library settingimport ioimport openpyxlimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport plotly.express as pxfrom matplotlib.colors import ListedColormapfrom sklearn.preprocessing import LabelEncoderfrom sklea.. 2024. 6. 27.
[Kaggle] 아마존 리뷰 분석 #03(TF-IDF, Topic-Modeling) 목차01. TF-IDF02. Topic Modeling 01. TF-IDF NLTK에서 불용어 다운로드하기# NLTK에서 영어 불용어 로드nltk.download('stopwords')stop_words = set(stopwords.words('english')) TF-IDF값 계산# TF-IDF 모델 초기화tfidf = TfidfVectorizer()# 리뷰 내용을 TF-IDF로 변환tfidf_matrix = tfidf.fit_transform(df['reviewText'])# 단어 리스트와 각 단어의 TF-IDF 값을 가져옴features = tfidf.get_feature_names_out()tfidf_scores = tfidf_matrix.sum(axis=0).A1# TF-IDF 값을 기준.. 2024. 6. 23.
[Kaggle] 아마존 리뷰 분석 #02(EDA, 감정분석) 목차01. 시각화02. 감정 분석03. 워드 클라우드 01. 시각화 리뷰 평점 시각화contraints로 pie chart 색상 구분5.0점대 평점 비율이 79.8%로 가장 높음# 리뷰 평점 확인constraints = ['#4682B4', '#FF6347', '#32CD32', '#FFD700', '#8A2BE2']def categorical_variable_summary(df, column_name): plt.figure(figsize=(10, 5)) # Countplot plt.subplot(1, 2, 1) df[column_name].value_counts().plot(kind='bar', color='skyblue') plt.title('Countplot') .. 2024. 6. 23.
[Kaggle] 아마존 리뷰 분석 #01(데이터 불러오기, 전처리) 목차01. Introduction02. 데이터 불러오기03. 데이터 전처리 01. Introduction 텍스트 마이닝 기법을 활용해서 고객 리뷰를 분석하고 이를 통해 고객이 만족하는 서비스 요인과 불만족하는 서비스 요익을 파악하고자 함 02. 데이터 불러오기 Kaggle에서 제공하는 'amazon reviews' 데이터 불러오기# library setting!pip install chart_studio!pip install TextBlob!pip install plotly!pip install WordCloud!pip install cufflinks!pip install SentimentIntensityAnalyzer!pip install vaderSentiment!pip install .. 2024. 6. 21.
[Kaggle] 회사 평점 예측 #04(예측 모델) 목차01. Data Scaling02. 모델학습 및 시각화03. 결과 해석 01. Data Scaling 데이터셋 분리 후 데이터 스케일링full data set주요 변수만 추출한 data set(설명변수 9개)review 세부요인 중 'Culture(기업문화)', 'Work/Life Balance(워라벨)' data setreview 세부요인 중 'Compensation/Benefits(급여/복지)', 'Job Security/Advancement(고용 안정/승진 기회)' data sethappiness 세부요인 data set# drop unnecessary datadf = df.drop(['description'], axis=1)df = df.drop(['happiness'], axis=1.. 2024. 6. 20.
[Kaggle] 회사 평점 예측 #03(감정 분석) 목차01. 감정 분석02. 시각화 01. 감정 분석 VADER 감정 분석기 사용하여 감정 점수 계산from nltk.sentiment.vader import SentimentIntensityAnalyzerimport nltk# NLTK에서 VADER Lexicon 다운로드nltk.download('vader_lexicon')# VADER 감정 분석기sid = SentimentIntensityAnalyzer()# 감정 점수 계산df_sentiment = df.copy()df_sentiment['sentiment_scores'] = df_sentiment['description'].astype(str).apply(lambda desc: sid.polarity_scores(desc))df_sentim.. 2024. 6. 19.
[Kaggle] 회사 평점 예측 #02(EDA) 목차01. Heatmap02. Bar Chart03. Scatter 01. Heatmap 설명변수 간 상관관계 확인1에 가까울수록 양의 상관관계-1에 가까울수록 음의 상관관계plt.figure()sns.heatmap(df[['rating', 'ceo_approval', 'employees', 'revenue', 'Management', 'Compensation/Benefits', 'Job Security/Advancement', 'Culture','Work/Life Balance' ]].. 2024. 6. 19.
[Kaggle] 회사 평점 예측 #01(데이터 불러오기, 전처리) 목차01. Introduction 02. 데이터 불러오기03. 데이터 전처리 01. Introduction 회사 리뷰 데이터 분석을 통해 구직자는 회사의 예측 평점을 파악하고, 기업에게는 평점에 영향을 미치는 중요 요인을 파악하여 기업 문화 및 복지 제도를 개선하는데 활용하고자 함 02. 데이터 불러오기 Kaggle에서 제공하는 'comopany review' 데이터 불러오기 # library settingimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport randomfrom sklearn.model_selection im.. 2024. 6. 15.
[Kaggle] 주택 가격 예측 EDA #3(결측치, 이상치 처리) 목차01. 결측치 데이터의 이론 및 시각화 탐색02. 이상치 데이터 판별 및 시각화 탐색 01. 결측치 데이터의 이론 및 시각화 탐색 결측 데이터의 종류임의적 결측 발생(MAR: Missing at Random) 누락된 데이터가 특정 변수와 관련되어 일어나지만, 그 변수의 값과는 관계가 없는 경우 ex)어떤 설문조사에서 누락된 자료가 특정 변수들에 국한되어 발견되었는데 알고 보니 일부 대상자가 설문지 3페이지에 반대쪽 면이 있는 것을 모르고 채우지 않았을 경우 MAR로 확인 가능 완전무작위 결측 발생(MCAR: Missing Completely at Random) 변수의 종류와 변수의 값과 상관없이 전체에 걸쳐 무작위적으로 발생 이러한 missing data는 분석에 영향을 주지 않음 비임의적 결.. 2024. 1. 2.
[Kaggle] 주택 가격 예측 EDA #2(시각화) 목차01. 날짜 데이터 처리(연도 관련)02. 이산형 데이터 그래프 시각화(박스플롯)03. 연속형 데이터 그래프 시각화(산점도)04. 범주형 데이터 그래프 시각화(박스플롯) 01. 날짜 데이터 처리(연도 관련)# 연도 데이터 탐색 year_fea = [fea for fea in numeric_features if 'Yr' in fea or 'Year' in fea] // Yr, Year관련 데이터 추출print(year_fea)# return : ['YearBuilt', 'YearRemodAdd', 'GarageYrBlt', 'YrSold']# 각 변수별 연도차이 확인 for fea in year_fea: data = train.copy() # 데이터 임시저장 data[fea].value_co.. 2023. 12. 29.
[Kaggle] 주택 가격 예측 EDA #1(Kaggle 데이터 불러오기, EDA) 목차01. Colab에서 캐글 데이터 불러오기 02. 구글 드라이브와 연동하여 데이터 저장03. 캐글 대회 및 데이터 확인 01. Colab에서 캐글 데이터 불러오기 # Kaggle KPI 설치!pip install kaggle# Kaggle Token 다운로드 from google.colab import filesuploaded = files.upload()for fn in uploaded.keys(): print('uploaded file "{name}" with length {length} bytes'.format( name=fn, length=len(uploaded[fn]))) # kaggle.json을 아래 폴더로 옮긴 뒤, file을 사용할 수 있도록 권한을 부여함 !mkd.. 2023. 12. 27.
[Kaggle] 기초문법 목차01. Matplotlib02. Seaborn03. Pandas03-1. Pandas(Merge)03-2. Pandas(Concat) 01. Matplotlib 파이썬의 배열의 2D플롯을 만들기 위한 라이브러리임(NumPy와 연계성이 큼) MATLAB 그래픽 명령어에 기원, 그러나 독립적머신러닝/딥러닝 모형 개발 시 성능 확인 차 자주 사용됨# 기본적인 시각화 문법import matplotlib.pyplot as pltplt.plot(x축 리스트, y축 리스트)plt.show()# 리스트import matplotlib.pyplot as pltx = [1, 2, 3, 4] // listy = [1, 2, 3, 4] // listplt.plot(x, y) // Matplotlib.plotplt.. 2023. 11. 14.
728x90