catboost
Skill15 starsChanged 43 days agoMITView on GitHub
Expert CatBoost assistance covering gradient boosting on decision trees, native categorical feature handling, and GPU acceleration. Use when training fast, accurate tabular models without manual one-hot encoding.
In this repository350 other files it gives its agents.
- airflowSkill
- claudeSkill
- comfyuiSkill
- cursor-aiSkill
- dalleSkill
- daskSkill
- dbtSkill
- deepseekSkill
- fastaiSkill
- geminiSkill
- github-copilotSkill
- huggingfaceSkill
- jaxSkill
- jupyterSkill
- kerasSkill
- langchainSkill
- lightgbmSkill
- llamaindexSkill
- llamaSkill
- matplotlibSkill
- midjourneySkill
- mistralSkill
- mlflowSkill
- nltkSkill
- numpySkill
- ollamaSkill
- openai-gptSkill
- opencvSkill
- pandasSkill
- perplexitySkill
- plotlySkill
- polarsSkill
- pytorchSkill
- raySkill
- scikit-learnSkill
- seabornSkill
- spacySkill
- sparkSkill
- stable-diffusionSkill
- tensorflowSkill
- vaexSkill
- weights-biasesSkill
- whisperSkill
- xgboostSkill
- api-gatewaySkill
- clean-architectureSkill
- cqrsSkill
- domain-driven-designSkill
- event-drivenSkill
- event-sourcingSkill
- graphqlSkill
- grpcSkill
- hexagonalSkill
- microservicesSkill
- modular-monolithSkill
- monolithSkill
- rest-apiSkill
- sagaSkill
- serverlessSkill
- service-meshSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 138
Use early_stopping_rounds with a dedicated validation set to prevent overfitting.
- Very specific: line 145
Use too large depth (> 10) unless explicitly regularized.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CatBoost
CatBoost (Yandex) is arguably the easiest boosting library to use because it handles Categorical Features automatically and perfectly without tuning.
When to Use
- Tabular Data with Categorical Features: Automatic target encoding and categorical combination without manual one-hot encoding.
- Low-Latency Inference: Fast model scoring on CPU and GPU with minimal memory overhead.
- Ranking & Classification Tasks: E-commerce recommendation, fraud detection, and click-through-rate (CTR) prediction.
- Robustness Against Overfitting: Symmetric (oblivious) decision trees providing stable predictions on small-to-medium datasets.
Quick Start
from catboost import CatBoostClassifier, Pool
from sklearn.model_selection import train_test_split
import pandas as pd
# Native categorical feature support
df = pd.DataFrame({
'city': ['London', 'Paris', 'Tokyo', 'London', 'Paris'],
'age': [25, 40, 30, 22, 55],
'target': [1, 0, 1, 1, 0]
})
X = df[['city', 'age']]
y = df['target']
cat_features = ['city']
model = CatBoostClassifier(iterations=100, learning_rate=0.1, verbose=20)
model.fit(X, y, cat_features=cat_features)
preds = model.predict(X)Core Concepts
Native Categorical Feature Handling
Training CatBoostClassifier directly on raw categorical string columns:
from catboost import CatBoostClassifier, Pool
from sklearn.model_selection import train_test_split
import pandas as pd
# Load dataset with categorical features
data = pd.DataFrame({
'city': ['London', 'Paris', 'Tokyo', 'London', 'Tokyo', 'Berlin'],
'device': ['mobile', 'desktop', 'mobile', 'tablet', 'desktop', 'mobile'],
'age': [24, 45, 32, 19, 58, 29],
'churned': [0, 1, 0, 0, 1, 0]
})
X = data[['city', 'device', 'age']]
y = data['churned']
cat_features = ['city', 'device']
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.33, random_state=42)
train_pool = Pool(X_train, y_train, cat_features=cat_features)
val_pool = Pool(X_val, y_val, cat_features=cat_features)
model = CatBoostClassifier(
iterations=500,
learning_rate=0.05,
depth=6,
eval_metric='AUC',
early_stopping_rounds=30,
random_seed=42,
verbose=50
)
model.fit(train_pool, eval_set=val_pool)Feature Importance & SHAP Values
Interpreting model decisions with Tree SHAP:
import shap
# Compute SHAP values directly from CatBoost
explainer = shap.TreeExplainer(model)
shap_values = explainer(val_pool)
# Summarize feature impact
feature_importance = model.get_feature_importance(val_pool, type='PredictionValuesChange')
for name, score in zip(X.columns, feature_importance):
print(f"Feature: {name:10s} Importance: {score:.4f}")Exporting Model to ONNX for High-Speed Serving
Serializing trained models for cross-platform C++/Go/Rust inference:
# Save model in ONNX format
model.save_model("catboost_model.onnx", format="onnx")
# Or native binary format
model.save_model("catboost_model.cbm")Common Patterns
Early Stopping with Validation Pool
Problem: Overfitting on tabular training data during deep gradient tree boosting.
Solution: Pass validation pool with early stopping rounds:
train_pool = Pool(X_train, y_train, cat_features=cat_features)
eval_pool = Pool(X_val, y_val, cat_features=cat_features)
model = CatBoostClassifier(
iterations=1000,
early_stopping_rounds=50,
eval_metric='AUC',
random_seed=42
)
model.fit(train_pool, eval_set=eval_pool, verbose=100)
print(f"Best iteration: {model.get_best_iteration()}")Best Practices
Do:
- Pass categorical columns directly to
cat_featuresrather than manual one-hot encoding. - Use
early_stopping_roundswith a dedicated validation set to prevent overfitting. - Train on GPU (
task_type="GPU") for datasets exceeding 1 million rows for up to 10x-20x speedup. - Monitor evaluation metrics using
plot=Truein Jupyter or export training logs to TensorBoard.
Don't:
- Label encode high-cardinality categoricals manually; CatBoost's target encoding is statistically superior.
- Use too large
depth(> 10) unless explicitly regularized; CatBoost defaults (depth 6) are optimal. - Evaluate final performance on the validation set used for early stopping; evaluate on a held-out test set.
Troubleshooting
| Error | Cause | Solution |
CatBoostError: Cannot convert ... to float | Categorical column containing strings not listed in cat_features. | Explicitly pass list of categorical column names/indices to cat_features. |
CUDA out of memory in GPU training | Batch size or tree depth too large for GPU VRAM. | Reduce max_depth (default 6) or train on CPU with task_type='CPU'. |
Metric value is NaN | Label array contains missing values or infinite entries. | Clean target labels and verify binary classification target values are 0 and 1. |
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

