선형 회귀 모델을 평가하는 데 사용되는 모델 성능 메트릭은 결정 계수입니다. "R 제곱"으로 알려져 있으며, "R2" [ 1, 2 ] 로 표시됩니다.
R2는 기본적으로 독립 변수로부터 예측 가능한 응답 변수의 변동 비율입니다. 즉, R2 값이 클수록 더 많은 변동성이 모델에 의해 설명됩니다.
일반적으로 R2는 0부터 1까지 다양하지만 마이너스 값을 얻을 수 있는 경우가 있을 수 있습니다. 자세한 내용은 [1]을(를) 참조하십시오.
이 경우 R2점수 '0.75'를 달성한다.
123456#Computes the R2 score
R2=hgr.score( test_hdf, key='ID',
features=['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup', 'Latitude', 'Longitude'],
label='Target')
R2출력:
0.7535287346593224
참조
[1] 결정 계수
[2] 결정 계수(결정 계수)
최적의 매개변수 검색으로 HGBT 모델 개선
HGBT 모델을 개선하기 위해 선형 회귀 오브젝트의 최적 매개변수 값 검색이 시작됩니다. ParamSearchCV는 crossover validation(CV) [1]을(를) 사용하여 지정된 매개변수 값에 대해 완전 또는 임의 검색을 수행합니다.
참조
[1] SAP algorithm hana_ml.algorithms.pal 패키지: ParamSearchCV
123456789101112131415161718from hana_ml.algorithms.pal.model_selection import ParamSearchCV
hgbr=HybridGradientBoostingRegressor(n_estimators=50, subsample = 0.8, col_subsample_tree=0.7)
ps_hgr3=ParamSearchCV(estimator=hgbr, search_strategy='grid',
param_grid={ 'learning_rate': [0.05, 0.1, 0.025, 0.04, 0.01],
'max_depth': [4, 5, 6, 7, 8, 10],
'split_threshold': [0.1, 0.4, 0.7, 1],
'min_samples_leaf': [2,3,4,5,6],
'col_subsample_split': [0.2,0.4,0.6, 0.8] },
train_control={"fold_num": 10, "evaluation_metric": 'rmse'},
scoring='mae'
)
ps_hgr3.set_scoring_metric('mae')
ps_hgr3.set_resampling_method('cv')
ps_hgr3.fit(data=train_hdf, features=['MedInc', 'HouseAge', 'AveRooms', 'AveBedrms', 'Population', 'AveOccup', 'Latitude', 'Longitude'],
label='Target', key='ID')최적화된 매개 변수 검사
최적화된 매개변수 이름(왼쪽에 표시됨)과 HybridGradientBoostingRegressor 매개변수 이름(오른쪽에 표시됨) 간의 매핑은 다음과 같이 제공됩니다.
- MAX_DEPTH = max_depth
- ETA = learning_rate
- COL_SAMPLE_RATE_BYSPLIT = col_subsample_split
- NODE_SIZE = min_samples_leaf
- GAMMA = split_threshold
1ps_hgr3.estimator.selected_param_.collect()| PARAM_NAME | INT_VALUE | DOUBLE_VALUE | STRING_VALUE | |
|---|---|---|---|---|
| 0 | MAX_DEPTH | 10.0 | NaN | 없음 |
| 1 | ETA | NaN | 0.1 | 없음 |
| 2 | COL_SAMPLE_RATE_BYSPLIT | NaN | 0.6 | 없음 |
| 3 | NODE_SIZE | 6.0 | NaN | 없음 |
| 4 | GAMMA | NaN | 0.1 | 없음 |
12# Optimal parameter values selected
hgbt_params = dict(n_estimators = 50, subsample = 0.8, col_subsample_tree=0.7, split_method = 'exact', fold_num=10, resampling_method = 'cv', evaluation_metric = 'rmse', ref_metric=['mae'], max_depth=10, learning_rate=0.1, col_subsample_split=0.6, min_samples_leaf=6, split_threshold=0.1)