경사 부스팅 (선택적 단위)
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
회귀 문제에서는 예측과 라벨의 차이로 부호 있는 오차를 정의하는 것이 좋습니다. 하지만 다른 유형의 문제에서는 이 전략을 사용하면 결과가 좋지 않은 경우가 많습니다. 더 나은 전략은 다음과 같습니다.
- 신경망에 사용되는 손실 함수와 유사한 손실 함수를 정의합니다. 예를 들어 분류 문제의 엔트로피 (로그 손실이라고도 함)가 있습니다.
- 약한 모델을 학습하여 강한 모델 출력에 따른 손실의 경사를 예측합니다.
공식적으로, $y$가 라벨이고 $p$ 가 예측인 손실 함수 $L(y,p)$가 주어지면 $i$ 단계에서 약한 모델을 학습하는 데 사용되는 가상 응답 $z_i$ 는 다음과 같습니다.
$$ z_i = \frac {\partial L(y, F_i)} {\partial F_i} $$
각 항목의 의미는 다음과 같습니다.
위의 예는 회귀 문제입니다. 목표는 숫자 값을 예측하는 것입니다. 회귀의 경우 제곱 오차는 일반적인 손실 함수입니다.
$$ L(y,p) = (y - p)^2 $$
이 경우 그라데이션은 다음과 같습니다.
$$ z = \frac {\partial L(y, F_i)} {\partial F_i} = \frac {\partial(y-p)^2} {\partial p} = -2(y - p) = 2 \ \text{signed error} $$
즉, 기울기는 2의 배수를 곱한 예시의 부호 있는 오류입니다. 축소로 인해 상수 계수는 중요하지 않습니다. 이 등가 관계는 제곱 오류 손실이 있는 회귀 문제에만 적용됩니다. 다른 지도 학습 문제 (예: 분류, 순위 지정, 백분위수 손실이 있는 회귀)의 경우 기울기와 부호 있는 오류는 상응하지 않습니다.
뉴턴의 방법 단계를 사용한 리프 및 구조 최적화
뉴턴의 방법은 경사하강법과 같은 최적화 방법입니다. 그러나 최적화하는 데 함수의 기울기만 사용하는 경사 하강과 달리 뉴턴의 방법은 최적화하는 데 함수의 기울기 (1차 미분)와 2차 미분을 모두 사용합니다.
경사하강의 단계는 다음과 같습니다.
$$ x_{i+1} = x_i - \frac {df}{dx}(x_i) = x_i - f'(x_i) $$
다음과 같이 뉴턴의 방법을 사용합니다.
$$ x_{i+1} = x_i - \frac {\frac {df}{dx} (x_i)} {\frac {d^2f}{d^2x} (x_i)} = x_i - \frac{f'(x_i)}{f''(x_i)}$$
원하는 경우 다음 두 가지 방법으로 뉴턴의 방법을 기울기 부스팅된 트리의 학습에 통합할 수 있습니다.
- 트리가 학습되면 뉴턴의 단계가 각 리프에 적용되고 값을 재정의합니다. 트리 구조는 변경되지 않으며 리프 값만 변경됩니다.
- 트리가 성장하는 동안 조건은 뉴턴 수식의 구성요소가 포함된 점수에 따라 선택됩니다. 트리의 구조가 영향을 받습니다.
YDF에서:
- YDF는 항상 리프에 뉴턴 단계를 적용합니다 (옵션 1).
use_hessian_gain=True
를 사용하여 옵션 2를 사용 설정할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[[["\u003cp\u003eGradient boosting employs loss functions and trains weak models to predict the gradient of the loss, differing from simple signed error calculations.\u003c/p\u003e\n"],["\u003cp\u003eFor regression with squared error loss, the gradient is proportional to the signed error, but this doesn't hold for other problem types.\u003c/p\u003e\n"],["\u003cp\u003eNewton's method, incorporating both first and second derivatives, can enhance gradient boosted trees by optimizing leaf values and influencing tree structure.\u003c/p\u003e\n"],["\u003cp\u003eYDF, a specific implementation, always applies Newton's method to refine leaf values and optionally uses it for tree structure optimization.\u003c/p\u003e\n"]]],[],null,["# Gradient boosting (optional unit)\n\nIn regression problems, it makes sense to define the signed error as the\ndifference between the prediction and the label. However, in other types of\nproblems this strategy often leads to poor results. A better strategy used in\ngradient boosting is to:\n\n- Define a loss function similar to the loss functions used in neural networks. For example, the entropy (also known as log loss) for a classification problem.\n- Train the weak model to predict the *gradient of the loss according to the\n strong model output*.\n\nFormally, given a loss function $L(y,p)$ where $y$ is a label and $p$ a\nprediction, the pseudo response $z_i$ used to train the weak model\nat step $i$ is: \n$$ z_i = \\\\frac {\\\\partial L(y, F_i)} {\\\\partial F_i} $$\n\nwhere:\n\n- $F_i$ is the prediction of the strong model.\n\nThe preceding example was a regression problem: The objective is to predict a\nnumerical value. In the case of regression, squared error is a common loss\nfunction: \n$$ L(y,p) = (y - p)\\^2 $$\n\nIn this case, the gradient is: \n$$ z = \\\\frac {\\\\partial L(y, F_i)} {\\\\partial F_i} = \\\\frac {\\\\partial(y-p)\\^2} {\\\\partial p} = -2(y - p) = 2 \\\\ \\\\text{signed error} $$\n\nIn order words, the gradient is the signed error from our example with a factor\nof 2. Note that constant factors do not matter because of the shrinkage. Note\nthat this equivalence is only true for regression problems with squared error\nloss. For other supervised learning problems (for example, classification,\nranking, regression with percentile loss), there is no equivalence between the\ngradient and a signed error.\n\nLeaf and structure optimization with Newton's method step\n---------------------------------------------------------\n\nNewton's method is an optimization method like gradient descent. However, unlike\nthe gradient descent that only uses the gradient of the function to optimize,\nNewton's method uses both the gradient (first derivative) and the second\nderivative of the function for optimization.\n\nA step of gradient descent is as follows: \n$$ x_{i+1} = x_i - \\\\frac {df}{dx}(x_i) = x_i - f'(x_i) $$\n\nand Newton's method as as follows: \n$$ x_{i+1} = x_i - \\\\frac {\\\\frac {df}{dx} (x_i)} {\\\\frac {d\\^2f}{d\\^2x} (x_i)} = x_i - \\\\frac{f'(x_i)}{f''(x_i)}$$\n\nOptionally, Newton's method can be integrated to the training of gradient\nboosted trees in two ways:\n\n1. Once a tree is trained, a step of Newton is applied on each leaf and overrides its value. The tree structure is untouched; only the leaf values change.\n2. During the growth of a tree, conditions are selected according to a score that includes a component of the Newton formula. The structure of the tree is impacted.\n\nYDF Code\nIn YDF:\n\n- YDF always applies a Newton step on the leaf (option 1).\n- You can enable option 2 with `use_hessian_gain=True`."]]