

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 調整 CatBoost 模型
<a name="catboost-tuning"></a>

*自動模型調校*，又稱為超參數調校，會透過在您的訓練和驗證資料集上，執行許多測試超參數範圍的任務，來尋找最佳版本的模型。模型調整著重於以下超參數：

**注意**  
學習損耗函式會根據分類任務的類型自動指派，該類型由標籤欄中的唯一整數數目決定。如需詳細資訊，請參閱[CatBoost 超參數](catboost-hyperparameters.md)。
+ 在模型訓練期間最佳化的學習損耗函式
+ 用於在驗證期間評估模型效能的評估量度
+ 自動調整模型時要使用的一組超參數和一系列值

自動模型調整會搜尋您選擇的超參數，以找到產生可最佳化所選評估指標之模型的值組合。

**注意**  
CatBoost 的自動模型調整功能僅可從 Amazon SageMaker SDK 使用，而不能從 SageMaker AI 主控台使用。

如需模型調校的詳細資訊，請參閱[使用 SageMaker AI 執行自動模型調校](automatic-model-tuning.md)。

## 由 CatBoost 演算法計算的評估指標
<a name="catboost-metrics"></a>

SageMaker AI CatBoost 演算法會計算下列量度，以用於模型驗證。評估指標會根據分類任務的類型自動指派，該類型由標籤欄中的唯一整數數目決定。


| 指標名稱 | Description | 最佳化方向 | 正則表達式 | 
| --- | --- | --- | --- | 
| RMSE | 均方根誤差 | 最小化 | "bestTest = ([0-9\\\\.]\+)" | 
| MAE | 平均值絕對誤差。 | 最小化 | "bestTest = ([0-9\\\\.]\+)" | 
| MedianAbsoluteError | 中值絕對誤差。 | 最小化 | "bestTest = ([0-9\\\\.]\+)" | 
| R2 | r2 分數 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| Logloss | 二進位交叉熵 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| Precision | precision | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| Recall | 取回 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| F1 | F1 分數 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| AUC | AUC 分數 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| MultiClass | 多類交叉熵 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| Accuracy | 正確性 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 
| BalancedAccuracy | 平衡準確度 | 最大化 | "bestTest = ([0-9\\\\.]\+)" | 

## 可調校的 CatBoost 超參數
<a name="catboost-tunable-hyperparameters"></a>

使用下列超參數調校 CatBoost 模型。對於最佳化 CatBoost 評估量度的影響最大的超參數為： `learning_rate`, `depth`, `l2_leaf_reg`, 和 `random_strength`。如需所有 CatBoost 超參數的清單，請參閱[CatBoost 超參數](catboost-hyperparameters.md)。


| 參數名稱 | 參數類型 | 建議範圍 | 
| --- | --- | --- | 
| learning\_rate | ContinuousParameterRanges | MinValue：0.001、MaxValue：0.01 | 
| depth | IntegerParameterRanges | MinValue：4、MaxValue：10 | 
| l2\_leaf\_reg | IntegerParameterRanges | MinValue：2、MaxValue：10 | 
| random\_strength | ContinuousParameterRanges | MinValue：0、MaxValue：10 | 