본문 바로가기

IT 자격증/AICE Associate12

AICE Associate - 머신러닝 머신러닝1-1) 로지스틱 (회귀,분류) Logistic RegressionC=규제강도, max_iter = 반복횟수# importfrom sklearn.linear_model import LogisticRegression# 모델 생성lg = LogisticRegression(C=1.0, max_iter=1000)# 모델 학습lg.fit(X_train, y_train)# 모델 평가lg.score(X_test, y_test) 1-2) 의사결정 나무 (회귀.분류)# importfrom sklearn.tree import DecisionTreeClassifier # 분류# 모델 생성dt = DecisionTreeClassifier(max_depth=5, random_state=2023)#.. 2024. 6. 19.
AICE Associate - 데이터 전처리 1. 결측치 처리 1-1) 결측치 확인하기df.isnull().sum()df.info() #탐색적으로 결측치 유무 확인 가능 1-2) 데이터 확인하기 – 대체하려고 하는 값 확인용#중앙값 df[‘칼럼명’].median()#최빈값df[‘칼럼명’].mode()[0]#평균값df[‘칼럼명’].mean()#최소값df[‘칼럼명’].min()#최대값df[‘칼럼명’].max()#합df[‘칼럼명’].sum() 1-3) 결측치 채우기#(값채우기df.fillna(값)#칼럼별 다른 값 채우기df.fillna( {‘칼럼명1’: 값1, ‘칼럼명2’:값2} )#특정 칼럼의 값 채우기df[‘칼럼명’].fillna(대체할값, inplace = True)#평균으로 채우기df[‘칼럼명’].fillna( df[‘칼.. 2024. 6. 19.
AICE Associate - 데이터 시각화 라이브러리import matplotlib.pyplot as pltimport matplotlib.font_manager as fmplt.rc('font', family ='NanumGothicCoding') seaborn 활용해서 그리기import seaborn as sb#카운트플롯sb.countplot(data=df, x='컬럼명') #조인트플롯sb.jointplot(data=df, x=’컬럼1’, y=’컬럼2’)#바플롯sb.barplot(data=df, x='칼럼1', y='칼럼2')#히스토그램sb.histplot(data=df, x='칼럼1')sb.histplot(data=df, x='칼럼1', hue='칼럼2')#히스토그램을 곡선으로 그리기sb.kdeplot(data=df, x='칼럼1', hu.. 2024. 6. 19.
AICE Associate - 탐색적 데이터 분석 라이브러리 import sklearn as skimport pandas as pdimport numpy as npimport matplotlib.pyplot as plt !pip install seabornImport seaborn as sns 데이터로딩df = pd.read_csv(‘파일경로.파일명’)df = pd.read_json(‘파일경로/파일명’)df = pd.read_excel(‘파일경로/파일명’) 데이터 구성 확인#앞행 5개 확인df.head(5) #뒷행 5개 확인df.tail(5) #데이터 인덱스 확인df.index#데이터 프레임 칼럼이름 확인df.columns #데이터 값Values확인df.values#데이터 프레임 행, 열 개수 확인df.shape #데이터 칼럼정보, Null.. 2024. 6. 19.