CatBoost Auto Class Weights is a parameter (auto_class_weights) that dynamically computes inverse class frequency weights from the training labels. When enabled, the algorithm assigns a higher penalty to misclassifying the rare class, effectively simulating cost-sensitive learning without requiring manual specification of the scale_pos_weight or class_weights parameters.
Glossary
CatBoost Auto Class Weights

What is CatBoost Auto Class Weights?
A built-in functionality in the CatBoost gradient boosting library that automatically calculates and applies balanced class weights during training to penalize errors on the minority class more heavily.
Unlike manual weight tuning, this method automatically adapts to the specific imbalance ratio in the dataset, simplifying the pipeline for fraud detection and anomaly scoring. It integrates directly with CatBoost's ordered boosting mechanism, ensuring that weight calculations remain consistent with the library's permutation-driven approach to reducing prediction shift.
Key Features of CatBoost Auto Class Weights
CatBoost's built-in mechanism for automatically balancing class weights during training, eliminating manual tuning while ensuring minority class errors are heavily penalized.
Automatic Weight Calculation
The auto_class_weights parameter dynamically computes balanced class weights directly from the training data distribution. When set to Balanced, it assigns weights inversely proportional to class frequencies, ensuring the rare fraud class receives higher penalty for misclassification. No manual calculation of scale factors is required, reducing the risk of human error in weight specification.
Integration with Ordered Boosting
CatBoost applies class weights within its ordered boosting framework, which combats overfitting by using per-object permutations. The weights influence the gradient calculation for each boosting iteration, ensuring that synthetic permutations do not leak target information while still prioritizing minority class learning. This preserves CatBoost's core advantage over standard gradient boosting implementations.
Multi-Class Imbalance Handling
Beyond binary fraud detection, auto_class_weights supports multi-class scenarios with options like SqrtBalanced and Balanced. The SqrtBalanced mode uses the square root of class frequencies, providing a moderated weighting scheme useful when extreme imbalance causes instability. This flexibility allows the same parameter to address varying degrees of class skew across different fraud typologies.
Synergy with Native Categorical Features
CatBoost's native handling of categorical features—using ordered target statistics—operates seamlessly with auto class weights. The weight values influence the target encoding calculations, preventing high-cardinality categorical features from leaking target information while still reflecting the importance of minority class instances in the encoding process.
Comparison to Manual Scale Pos Weight
Unlike XGBoost's scale_pos_weight, which requires manual calculation of the ratio between negative and positive instances, CatBoost's auto_class_weights eliminates this step entirely. It also avoids the common pitfall of applying a single global scale factor that may not account for local density variations in the feature space, providing a more nuanced initial weighting.
Impact on Evaluation Metrics
When auto_class_weights is enabled, the model's probability outputs remain well-calibrated for the weighted objective. This is critical for fraud detection, where probability calibration ensures that a predicted 10% fraud probability corresponds to an actual 10% empirical frequency. The weights bias the decision boundary without distorting the probabilistic interpretation needed for risk scoring.
Frequently Asked Questions
Explore the mechanics, configuration, and strategic application of CatBoost's built-in automatic class weighting functionality for handling severe class imbalance in financial fraud detection and other rare-event modeling tasks.
CatBoost Auto Class Weights is a built-in functionality in the CatBoost gradient boosting library that automatically calculates and applies balanced class weights during training to penalize errors on the minority class more heavily. When the auto_class_weights parameter is set to a valid option (such as Balanced or SqrtBalanced), the algorithm computes the weight for each class based on its inverse frequency in the training dataset. Specifically, for the Balanced mode, the weight for class $k$ is calculated as $w_k = \frac{n_{total}}{c \times n_k}$, where $n_{total}$ is the total number of objects, $c$ is the number of classes, and $n_k$ is the number of objects in class $k$. This weight is then integrated directly into the loss function and the gradient calculation for each boosting iteration, ensuring that misclassifying a rare fraudulent transaction incurs a proportionally higher penalty than misclassifying a common legitimate one. Unlike manual scale_pos_weight parameters in other frameworks, this automatic mechanism dynamically adjusts to the exact empirical distribution of the training labels without requiring the user to compute ratios manually.
CatBoost Auto Class Weights vs. Other Imbalance Handling Methods
A feature-level comparison of CatBoost's built-in auto_class_weights parameter against manual cost-sensitive learning, data-level resampling methods, and other gradient boosting library approaches for handling severe class imbalance in fraud detection.
| Feature | CatBoost Auto Class Weights | Manual Scale Pos Weight | SMOTE Resampling | Focal Loss |
|---|---|---|---|---|
Implementation Complexity | Single parameter | Requires manual calculation | Multi-step preprocessing | Custom loss function |
Automatic Weight Calculation | ||||
Preserves Original Data Distribution | ||||
Handles Multi-Class Imbalance | ||||
Training Overhead vs. Baseline | Minimal (< 5%) | None | Significant (30-50%) | Moderate (10-20%) |
Risk of Overfitting | Low | Low | High | Low |
Requires Post-Training Threshold Tuning | ||||
Interpretability Impact | None | None | Synthetic samples reduce explainability | None |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Explore the core techniques and metrics that complement CatBoost's automatic class weighting to build robust fraud detection models on highly skewed data.
Cost-Sensitive Learning
A learning paradigm that assigns different misclassification costs to different error types. In fraud, missing a fraudulent transaction (false negative) is far more costly than flagging a legitimate one (false positive). CatBoost's auto_class_weights implements this by penalizing errors on the minority class more heavily, effectively embedding a cost matrix directly into the loss function without manual specification.
SMOTEBoost
An ensemble method that integrates SMOTE into the AdaBoost algorithm. At each boosting iteration, new synthetic minority class examples are generated before training the weak learner. This contrasts with CatBoost's approach: SMOTEBoost modifies the data, while auto_class_weights modifies the objective function. Both increase emphasis on the rare class, but through fundamentally different mechanisms.
Precision-Recall AUC
The area under the Precision-Recall curve, a performance metric that focuses exclusively on the minority class. Unlike ROC AUC, which can be misleadingly high on imbalanced data, PR AUC penalizes models that produce many false positives. When tuning CatBoost with auto_class_weights, monitor PR AUC rather than accuracy to ensure the balanced training translates to real detection capability.
Threshold Moving
A post-training technique that adjusts the decision threshold away from the default 0.5 probability. After training with auto_class_weights, the model's output probabilities are already biased toward the minority class. Threshold moving provides a final calibration layer:
- Optimize for recall when false negatives are unacceptable
- Optimize for precision when investigator bandwidth is limited
- Use a validation set to find the threshold that maximizes F1-score
XGBoost Scale Pos Weight
A hyperparameter in the XGBoost library that controls the balance of positive and negative weights. Unlike CatBoost's auto_class_weights, which calculates the optimal weight automatically, scale_pos_weight requires manual specification:
- Typical value:
sum(negative_instances) / sum(positive_instances) - CatBoost's automatic approach reduces hyperparameter tuning overhead
- Both achieve the same goal: scaling the gradient for the minority class
Stratified K-Fold
A cross-validation technique that preserves the class distribution in each fold. When evaluating CatBoost models with auto_class_weights, stratified splitting is essential:
- Ensures each fold contains a proportional number of fraud cases
- Prevents folds with zero minority examples, which would make validation metrics undefined
- Use
StratifiedKFoldfrom scikit-learn withn_splits=5for robust performance estimation

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us