2025/01 5

종속,독립변수 넣고 머신러닝

import pandas as pdfrom sklearn.model_selection import train_test_split# 예시 데이터프레임 로드# transaction 데이터 로드transaction_data = pd.read_csv("transaction.csv")# 독립변수(X)와 종속변수(Y) 설정X = transaction_data[['shippment_fee']]  # 독립변수y = transaction_data['total_fee']       # 종속변수# 학습 데이터와 테스트 데이터 분리X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) 2. 트리 기반 모델 학습 (예: R..

카테고리 없음 2025.01.14

히트맵에 대해

# 히트맵 데이터 생성heatmap_data = click_stream_df.pivot_table(index='event_name', columns='event_time_month', aggfunc='size', fill_value=0)# 히트맵 그리기#label: 젤 오른쪽 막대기#plt.figure(figsize=(12, 8)) # 전체 그림 크기 조정sns.heatmap(heatmap_data, annot=True, fmt='d', cmap='coolwarm', cbar_kws={'label': 'Frequency'}, annot_kws={"size": 10}) # 글자 크기 조정plt.title("Event Frequency by Month and Event Name", fontsize=16)..

카테고리 없음 2025.01.12

x,y 둘다 value를 넣고 싶을때

질문 'product_raw 데이터가 있고 x축은 cloth y축은 season으로 그래프 만들고 싶으면 어떻게 해?' 1. 막대 그래프import seaborn as snsimport matplotlib.pyplot as plt# cloth별 season의 빈도수를 계산season_counts = product_raw.groupby(['cloth', 'season']).size().reset_index(name='counts')# 막대 그래프 그리기sns.barplot(data=season_counts, x='cloth', y='counts', hue='season')plt.xticks(rotation=45)plt.show()  2. 히트맵# cloth와 season 빈도수를 교차 테이블로 변환heat..

조별과제 2025.01.10