Summary: CatBoost Feature Type Auto-Detection with Manual Configuration Override plus some additional fixes
This will also enable feature selection on embedding, text and categorial features when using the Mother Carboost with freature type detection for the feature selectors
This PR adds flexible feature type handling to CatBoost models by combining automatic dtype-based detection with explicit manual configuration through the Mother config system.
The callback logic was improved to automatically skip Optuna early stopping when hold-out validation or any cross-validation with fewer than 2 splits is used, preventing errors and ensuring correct behavior. This allows the use of hold out sets.
The default boostrap for catboost optimization using Optuna is now MVS, was not clear from the documentation if Bayesian or MVS, but generated some catboost models to check.
The catboost ranker can now handle non integer query groups i.e. dtype category and if the data is not sorted according to groups will be auto sorted.
🎯 What This Adds
Two complementary approaches for specifying feature types:
-
Automatic Detection (opt-in via flags):
auto_class_categorical=True - Auto-detects columns with category dtype
auto_parse_text=True - Auto-detects object dtype columns containing strings
auto_parse_embedding=True - Auto-detects object dtype columns containing vectors (lists, arrays)
-
Manual Configuration (via Mother config):
categorical_features: [] - Explicitly specify categorical feature column names
text_features: [] - Explicitly specify text feature column names
embedding_features: [] - Explicitly specify embedding feature column names
-
Why 'category' dtype is required instead of 'object':
- The ambiguity problem with object dtype (can be categorical strings, text, or vectors)
- The design philosophy of being explicit and intentional
- The practical benefit of better pandas and catboost performance
🔄 How Old and New Approaches Combine
Smart Precedence System:
- Manual configuration ALWAYS takes precedence over auto-detection
- Auto-detection only activates when:
- The feature type is NOT explicitly specified in config, AND
- The corresponding auto-detection flag is enabled, AND
- Input is a pandas DataFrame (auto-detection requires column names)
Cross-type exclusion:
- Features manually specified in any type list are automatically excluded from auto-detection in other types
- Prevents a single feature from appearing in multiple type lists
Example workflow:
# Config specifies some features manually
categorical_features: ["feature_A"]
text_features: ["feature_B"]
# At runtime with auto_parse_embedding=True:
# - "feature_A" used as categorical (from config)
# - "feature_B" used as text (from config)
# - Embedding features auto-detected from remaining object dtype vector columns
# - "feature_A" and "feature_B" excluded from embedding auto-detection
🚀 Extension Points
Architecture improvements:
- Reusable detection utilities (
mother/ml/models/utils.py):
detect_categorical_features() - Finds 'category' dtype columns
detect_text_features() - Finds object dtype string columns
detect_embedding_features() - Finds object dtype vector columns
- Can be reused by future model implementations beyond CatBoost
Summary: CatBoost Feature Type Auto-Detection with Manual Configuration Override plus some additional fixes
This will also enable feature selection on embedding, text and categorial features when using the Mother Carboost with freature type detection for the feature selectors
This PR adds flexible feature type handling to CatBoost models by combining automatic dtype-based detection with explicit manual configuration through the Mother config system.
The callback logic was improved to automatically skip Optuna early stopping when hold-out validation or any cross-validation with fewer than 2 splits is used, preventing errors and ensuring correct behavior. This allows the use of hold out sets.
The default boostrap for catboost optimization using Optuna is now MVS, was not clear from the documentation if Bayesian or MVS, but generated some catboost models to check.
The catboost ranker can now handle non integer query groups i.e. dtype category and if the data is not sorted according to groups will be auto sorted.
🎯 What This Adds
Two complementary approaches for specifying feature types:
Automatic Detection (opt-in via flags):
auto_class_categorical=True- Auto-detects columns withcategorydtypeauto_parse_text=True- Auto-detects object dtype columns containing stringsauto_parse_embedding=True- Auto-detects object dtype columns containing vectors (lists, arrays)Manual Configuration (via Mother config):
categorical_features: []- Explicitly specify categorical feature column namestext_features: []- Explicitly specify text feature column namesembedding_features: []- Explicitly specify embedding feature column namesWhy 'category' dtype is required instead of 'object':
🔄 How Old and New Approaches Combine
Smart Precedence System:
Cross-type exclusion:
Example workflow:
🚀 Extension Points
Architecture improvements:
mother/ml/models/utils.py):detect_categorical_features()- Finds 'category' dtype columnsdetect_text_features()- Finds object dtype string columnsdetect_embedding_features()- Finds object dtype vector columns