데이터를 훈련 세트와 테스트 세트로 나누는 이유는 지금까지 본 적 없는 새로운 데이터에 모
델이 얼마나 잘 일반화되는지 측정하기 위해서입니다. 모델이 훈련 세트에 잘 맞는 것보다, 학
습 과정에 없던 데이터에 대해 예측을 얼마나 잘 하느냐가 중요합니다.
이번 장에서는 두 가지 관점에서 이 평가 방법을 확장해보겠습니다. 먼저 안정적인 일반화 성
능 측정 방법인 교차 검증을 소개하고,
score
메서드가 제공하는 정확도와
R
2
값 이외에 분류
와 회귀 성능을 측정하는 다른 방법을 알아보겠습니다.
또한 가장 좋은 일반화 성능을 얻기 위해서 지도 학습 모델의 매개변수를 조정하는 데 유용한
그리드 서치에 관해서도 이야기하겠습니다.
5.1
교차 검증
교차 검증
cross
-
validation
은 일반화 성능을 재기 위해 훈련 세트와 테스트 세트로 한 번 나누는 것보
다 더 안정적이고 뛰어난 통계적 평가 방법입니다. 교차 검증에서는 데이터를 여러 번 반복해
서 나누고 여러 모델을 학습합니다. 가장 널리 사용되는 교차 검증 방법은
k
-겹 교차 검증
k
-
fold
cross
-
validation
으로
k
는 특정 숫자인데 보통
5
또는
10
을 사용합니다.
5
-겹 교차 검증을 하려면
데이터를 먼저
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.