Simple Regression
- Comparing Classification & Regression
| property | supervised classification | regression |
|---|
| output type | discrete (class labels) | continuous (number) |
| what are you trying to find? | decision boundary | best fit line |
| evaluation | accuracy | sum of squared error |
- Baseline Model
최소한의 성능을 가지면서 학습할 모델과 비교하기 위한 기준이 되는 모델
- 분류 문제
타겟의 최빈 클래스
- 회귀 문제
타겟의 평균값
- 시계열 회귀 문제
이전 time stamp의 값
- 예측 모델(Predictive Model) 활용
- 예측값
만들어진 모델이 추정하는 값
- 잔차(residual)
예측값과 관측값의 차(거리)
- 오차(error)
모집단에서의 예측값과 관측값의 차(거리)
- RSS(Residual Sum of Squares) (또는 SSE(Sum of Square Error))
잔차 제곱들의 합
회귀 모델의 비용 함수(Cost Function)
- 학습
비용함수를 최소화 하는 모델을 찾는 과정
- 회귀 직선
RSS를 최소화 하는 직선
Reference
Multiple Regression
- Training and testing
Training set으로 모델을 학습시키고, Test set으로 모델의 accuracy를 평가한다.
- 시계열 데이터의 경우에는 과거의 데이터를 바탕으로 미래를 예측하기 때문에 오래된 데이터를 Training set으로, 최근 데이터를 Test set으로 설정한다.
- 회귀 모델을 평가하는 평가지표(evaluation metrics)
- MSE(Mean Squared Error)
n1∑i=1n(yi−yi^)2
- MAE(Mean Absolute Error)
n1∑i=1n∣yi−yi^∣
- R-squared
How well a regression line predicts or estimates actual values
- |actual - mean|과 |estimated - mean|의 비교
∑i=1n(yi−yiˉ)2∑i=1n(yi^−yiˉ)2
- 예측값과 관측값이 같을수록 R2 값은 1에 가까워진다.
- Bias and variance
- Bias
The difference between actual values and prediction on training set
- Variance
The difference in fits between data sets
- Overfit
The Squiggly line fits the training set really well, but not the test set.
- High variance / Low bias


Reference
Ridge Regression
Reference
Logistic Regression
It can be used to classify samples.
- Data Sets
- Training set
Construct classifier
- Validation set
Pick algorithm + knob settings
- training set로 모델을 한번에 완전하게 학습시키기 어렵기 때문에 training set로 다르게 튜닝된 여러 모델들을 학습한 후 어떤 모델의 학습이 잘 되었는지 검증하고 선택하는 과정 필요
- Test set
Estimate future error rate
- 모델의 일반화 성능을 마지막에 한 번 올바르게 측정
- Split randomly to avoid bias
- Model selection
- 모델 선택 수행에서 하이퍼파라미터 튜닝의 효과를 확인하기 위해 validation set 필요
- K-fold 교차검증(k-fold cross-validation)
상대적으로 데이터 수가 적을 경우에 진행
- 분류(Classification) 문제
- 평가지표(evaluation metrics)
- Accuracy =(TP+TN)/Total
- Logistic Regression vs Linear Regression
- Logistic R predicts whether something is True or False, instead of predicting something continuous.
- Instead of fitting a line to the data, Logistic R fits an 'S' shpaed 'logistic function'.
- How the line is fit to the data
- With Linear R, we fit the line using 'least squares'.
- Logistic R uses something called 'maximum likelihood'.
- Logistic Regression Model
OneHotEncoder
카테고리 데이터 처리
SimpleImputer
결측치 처리
StandardScaler
특성들의 척도를 맞추기 위해 표준정규분포로 표준화 (평균=0, 표준편차=1)
reference