Python 18

[RandomForest] Python, 랜덤포레스트 모델 튜닝

목차 1. 라이브러리 import numpy as np import pandas as pd import pickle as pkl from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split, PredefinedSplit, GridSearchCV from sklearn.metrics import f1_score, precision_score, recall_score, accuracy_score 2. 데이터 3. null값처리 air_data_subset = air_data.dropna(axis=0) 4. Encoding air_data_subset_dummies = pd.get_d..

[ensemble] Python, ensemble, voting, pickle, bootstraping, randomforest, hyperparameter tunes

목차 ensemble learning Aggregating their outputs to make a prediction 여러 개의 분류기를 생성하고 그 예측을 결합함으로써 보다 정확한 최종 예측을 도출하는 기법. 다양한 분류기의 예측 결과를 결합하는 것이 단일 분류기보다 신뢰성이 높은 예측값을 얻을 수 있다. 1. Voting 서로 다른 알고리즘을 가진 부류기를 결합 1) Hard Voting 다수결의 원칙을 따른다. 예측한 결과값 중 다수의 분류기가 결정한 예측값을 최종 voting결과값으로 선정한다. 2) Soft Voting 분류기들의 레이블 값 결정 확률을 모두 더하고 이를 평균해서, 확률이 가장 높은 레이블 값을 최종 보팅 결괏값으로 선정한다. 2. bagging= bootstrap aggre..

[Machine learning - Construct] Naive Bayes, 나이브베이즈, python, stratify

목차 Naive Bayes classifier A supervised classification technique that is based on Bayes' Theorem with an assumption of independence among predictors. 나이브 베이즈 알고리즘은 베이즈 정리에 기반한다. 베이즈 정리는 각각의 사건이 일어날 확률을 측정하는 것인데, 아래의 formula를 보자. c사건과 x사건이 있다. x가 발생한 이후에 c가 발생한다고 가정하자. P(c|x): x사건이 일어난 후 c사건이 일어날 확률이다. = 조건부 확률 P(c) : 사건 C가 일어날 확률 P(x) : 사건 x가 일어날 확률= 사건 c가 일어나기 전 사건 X가 일어날 확률 =사전확률= Predictor pri..

[Machine learning - plan, analze] Python, class imbalance, upsampling, downsampling

목차 Class imbalance When a dataset has a predictor variable that contains more instances of one outcome than another. majority class(많은 것) vs minority class(작은 것) class 안에서 majority와 minority의 balance가 맞지 않아도 된다. 문제가 생기는 경우는 majority class가 90% 이상을 차지 할 때 이다. 이 문제를 해결하기 위한 방법은 두 가지이다. 1) upsampling - dataset이 작을 때 유용하다. 2) downsampling - dataset이 매우 클 때 유리하다. 뽑는 방법은 랜덤 또는 수학 formula를 쓴다. Python1 ..

[Machine learning] supervised, unsupervised, reinforcement, deep learning, recommendation system, content-based, collaborative, variable types, python

목차 이제까지 linear regression, logistic regression에 대해 공부했다. 만약 어떤 데이터셋을 주고, 이것을 scatterplot으로 표현했다고 하자. 이러한 데이터셋은 앞서 배운 회귀모델로 처리할 수 있을까? 어렵다. 따라서 다양한 데이터에 적절히 적용할 수 있는 다양한 머신러닝 모델이 필요한 것이다. Machine Learning It involves using algorithms and statistical models to tach computer systems to analyze and discover pattern in data. 1. Main types of machine learning 머신러닝 타입은 크게 두 가지로 나뉜다 . 1) Supervised lear..