- 맨 하단 글 일부 발췌 - 🧐
"A baseline is a simple model that provides reasonable results on a task and does not require much expertise and time to build. Common baseline models include linear regression when predicting continuous values, logistic regression when classifying structured data, pretrained convolutional neural networks for vision related tasks, and recurrent neural networks and gradient boosted trees for sequence modeling (Ameisen 2018)"
→ 즉! 우리는 predictive model(예측 모델)을 만들기 전에 '가장 간단하면서도 직관적이면서 최소한의 성능'을 나타내는 기준이 되는 모델 필요
cf) 참고로 문제별로 기준모델은 (주로) 다음과 같이 설정한다.
→ 분류문제 - target의 최빈 class (분류로는 logistic regression model)
→ 회귀문제 - target의 평균값 (회귀로는 linear regression model)
→ 시계열회귀문제 - 이전 timestamp의 값
Q. 그렇다면 baseline model은 완벽하지도 않은데, 도대체 왜 굳이 처음에 만드는 걸까? 쓰임새가 있을까?
A.
'If baselines are not perfect, then what makes them useful? Let’s circle back to the apparel example. Common sense tells us to mail the top 100k loyal customers to maximize our expected return. Loyalty can be measured in terms of three features. If customers shop a lot, spend a lot, and have recently shopped with your store, then they are likely to be loyal (Ramakrishnan 2018). One way to combine these three pieces of information is binning, where we categorize each customer for each category and then simply rank them based on some scale. The top 100k customers are the ones you should mail. In fact, this model is a practical heuristic, called the Recency-Frequency-Monetary Heuristic, which is commonly used in database marketing and direct marketing. It is easy to create, easy to explain, easy to use, and effective.'
'A baseline takes only 10% of the time to develop, but will get us 90% of the way to achieve reasonably good results. Baselines help us put a more complex model into context in terms of accuracy.'
'Another advantage of a baseline is that it’s easy to deploy, it is faster to train as few parameters can quickly fit to your data, and it is often simple enough to allow easy problem detection. Whenever an error pops up, it is likely due to a bug, some defect of the dataset, or due to wrong assumptions. A baseline is quick to put into production as it does not require much infrastructure engineering, and it is also quick for inference because it has low latency'
→ baseline model은 쉽고 빠르게 만들 수 있고 사용하기도 쉽다. 즉 큰 노력을 들지 않아도 직관적으로 infer 가능하고 해당 기준모델에 근거하여 정확성에 의거 더 발전된 model을 만들 수 있다는 점에서 큰 의의가 있다고 할 수 있음 🙂
- 출처에서 가져온 그림인데 baseline model의 역할을 직관적으로 잘 그려놓았다. -
Q. baseline model 만들고 난 다음에는?
A.
'Having constructed a baseline, the next step is to see what the baseline fails to capture. This will guide our choice of a more complex model. That being said, we should also not neglect the fact that improving upon baselines can make already successful cases fail, as improvements are not strictly additive. This is especially true in the case of deep learning models where the lack of interpretability makes it harder to infer failure cases. Furthermore, baselines help us understand our data better. For example, for a classification task we can get an idea of what classes are hard to separate from each other by looking at the confusion matrix. If we have a lasso regression problem, we can look at the non-zero coefficients to guide feature selection(밑줄은 추후 포스팅으로 내용 이해하자). Furthermore, if the model neglects some features that our domain knowledge tells us are important, then that sends a warning signal as our data may not be a good representation of the population or it could just be that the model is not suitable.'
→ 즉 만들어진 baseline model을 통해 우리는 given data에 대해 더 이해를 할 수 있게 되었고 어떤 data를 baseline model이 잘못 캡처했는 지 알아낼 수 있다. (하지만 이를 기반으로 model을 만든다고 해서 성공 case라 무조건 보장할 수는 없음). 아무튼 baseline model을 기반으로 새로운 model들을 construct & implement하며 baseline 모델의 성능과 비교하며 모델의 정확성을 증가시킨다
예시>
* 단순선형회귀모델을 만든다고 가정해 보자
* 최애 dataset <seaborn iris dataset> 가져오기
Q) 독립변수 sepal_length에 따른 종속변수 petal_length의 선형관계를 알고 싶다. 해당선형관계를 알아보기 위한 단순선형회귀모델 구축 전, baseline model을 활용하고자 한다. 이 때 baseline model을 시각화해보자
A) 기준이 되는 baseline model을 종속변수의 평균으로 잡았고 accuracy metrics는 해당 baseline model과 종속변수 간의 MAE 수치로 잡았다.
x = iris['sepal_length']
y = iris['petal_length']
predict = iris['petal_length'].mean()
errors = predict - iris['petal_length']
mean_absolute_error = errors.abs().mean()
sns.lineplot(x=x, y=predict, color='red')
sns.scatterplot(x=x, y=y, color='orange');
print(mean_absolute_error) #→ MAE 결과는 1.5627466666666645
-- 출력 결과 --
→ 이제 baseline model①을 잡았고 이를 기반으로 단순선형회귀 모델을 구축②한 다음 MAE 수치를 비교③하여 더 좋아졌는 지 (즉, y값과의 정확성이 좋아졌는 지) 확인하면 된다!
(단순선형회귀모델 Simple Linear Regression Model은 추후 포스팅 참고)
Q. ** 단순한 모델 자체가 baseline으로 활용? 예시
▶여러 개의 feature set에서 연속적인 value값을 예측하는 데 baseline으로 선형회귀 Linear Regression이 많이 사용됨
▶정형화된 데이터나 자연어를 분류하는 데 로지스틱회귀 Logistic Regression이 사용됨
▶시간 data를 예측하거나 일반적인 구조화된 data 관련해서는 GBT(Gradient Boosted Trees) 모델이 사용됨 (Kaggle No.1!)
▶이미지 탐지, 분류, segmentation 문제들 관련해서는 VCG, U-net이 주로 사용됨 (곧 배울 예정)
Q. baseline을 통한 이해 → 추후 성능 향상!
▶로지스틱 회귀를 첫 모델로 삼아 baseline으로 accuracy를 측정하는 과정에서, 게임이 절반 이상 진행되었을 때 게임 정확성이 급격히 증가하는 것을 발견. 이후 모델을 고르는 데 있어서 큰 참고자료가 되었다.
▶vanilla U-Net architecture 구조를 모델로 삼아 image를 detection하는 데 있어서 문제가 있음을 발견하고 이를 보완해 더 좋은 모델을 만든 사례
※ 이렇게 기존 baseline model이 캡처하지 못했던 문제점을 발견하고 추후 성능을 향상하는 데 큰 발판이 될 수 있다.
* 출처1) https://blog.ml.cmu.edu/2020/08/31/3-baselines/
* 출처2) https://blog.insightdatascience.com/always-start-with-a-stupid-model-no-exceptions-3a22314b9aaa
'Machine Learning > Fundamentals' 카테고리의 다른 글
One-Hot encoding (0) | 2022.04.17 |
---|---|
Cross-Validation (concepts + w/code) (0) | 2022.04.17 |
Overfitting/Underfitting & Bias/Variance Tradeoff (0) | 2022.04.17 |
All About Evaluation Metrics(1/2) → MSE, MAE, RMSE, R^2 (0) | 2022.04.16 |
intro. Machine Learning (0) | 2022.04.15 |
댓글