Numerical features are the backbone of most machine learning models. KDP provides multiple ways to handle them, from simple normalization to advanced neural embeddings.
| Feature Type | What it does | Output width | When to use |
|---|---|---|---|
FLOAT_NORMALIZED |
Standardised to zero mean and unit variance, using the mean and variance from the statistics pass. | 1 | The sensible default for most numeric columns. |
FLOAT |
Identical to FLOAT_NORMALIZED. |
1 | An alias; there is no separate behaviour. |
FLOAT_RESCALED |
Multiplied by scale, which defaults to 1.0 — that is, unchanged. |
1 | Only useful when you pass scale yourself. See the warning below. |
FLOAT_DISCRETIZED |
One-hot over num_bins equal-width bins derived from the statistics. |
num_bins (default 10) |
When groups of values carry meaning rather than the magnitude. |
The simplest way to define numerical features is with the FeatureType enum:
from kdp import PreprocessingModel, FeatureType
# ✨ Quick numerical feature definition
features = {
"age": FeatureType.FLOAT_NORMALIZED, # 🧓 zero mean, unit variance
"income": FeatureType.FLOAT_NORMALIZED, # 💰 also standardised (see the warning above)
"transaction_count": FeatureType.FLOAT, # 🔢 alias for FLOAT_NORMALIZED
"rating": FeatureType.FLOAT_DISCRETIZED # ⭐ one-hot over 10 bins
}
# 🏗️ Create your preprocessor
preprocessor = PreprocessingModel(
path_data="customer_data.csv",
features_specs=features
)For more control, use the NumericalFeature class:
from kdp.features import NumericalFeature
features = {
# 🧓 Simple example with enhanced configuration
"age": NumericalFeature(
name="age",
feature_type=FeatureType.FLOAT_NORMALIZED,
use_embedding=True, # 🔄 Create neural embeddings
embedding_dim=16, # 📏 Size of embedding
preferred_distribution="normal" # 📊 Hint about distribution
),
# 💰 Financial data example
"transaction_amount": NumericalFeature(
name="transaction_amount",
feature_type=FeatureType.FLOAT_RESCALED,
use_embedding=True,
embedding_dim=32,
preferred_distribution="heavy_tailed"
),
# ⏳ Custom binning example
"years_experience": NumericalFeature(
name="years_experience",
feature_type=FeatureType.FLOAT_DISCRETIZED,
num_bins=5 # 📏 Number of bins
)
}| Parameter | Description | Default | Suggested Range |
|---|---|---|---|
feature_type |
🏷️ Base feature type | FLOAT_NORMALIZED |
Choose from 4 types |
use_embedding |
🧠 Enable neural embeddings | False |
True/False |
embedding_dim |
📏 Dimensionality of embedding | 8 | 4-64 |
preferred_distribution |
📊 Hint about data distribution | None |
"normal", "log_normal", etc. |
num_bins |
🔢 Bins for discretization | 10 | 5-100 |
Let KDP automatically detect and handle distributions:
# ✨ Enable distribution-aware processing for all numerical features
preprocessor = PreprocessingModel(
features_specs=features,
use_distribution_aware=True # 🔍 Enable distribution detection
) </div>
</div>
Using advanced numerical embeddings:
from kdp import FeatureType, NumericalFeature, PreprocessingModel
# Configure numerical embeddings
preprocessor = PreprocessingModel(
features_specs={
"income": NumericalFeature(
name="income",
feature_type=FeatureType.FLOAT_RESCALED,
use_embedding=True,
embedding_dim=32,
preferred_distribution="log_normal"
)
}
) </div>
</div>
from kdp import FeatureType, NumericalFeature, PreprocessingModel
# 📈 Financial metrics with appropriate processing
preprocessor = PreprocessingModel(
features_specs={
"income": NumericalFeature(
name="income",
feature_type=FeatureType.FLOAT_RESCALED,
preferred_distribution="log_normal" # 📉 Log-normal distribution
),
"credit_score": NumericalFeature(
name="credit_score",
feature_type=FeatureType.FLOAT_NORMALIZED,
use_embedding=True,
embedding_dim=16
),
"debt_ratio": NumericalFeature(
name="debt_ratio",
feature_type=FeatureType.FLOAT_NORMALIZED,
preferred_distribution="bounded" # 📊 Bounded between 0 and 1
)
},
use_distribution_aware=True # 🧠 Smart distribution handling
)</div>
from kdp import FeatureType, NumericalFeature, PreprocessingModel
# 📡 Processing sensor readings
preprocessor = PreprocessingModel(
features_specs={
"temperature": NumericalFeature(
name="temperature",
feature_type=FeatureType.FLOAT_RESCALED,
use_embedding=True,
embedding_dim=16
),
"humidity": NumericalFeature(
name="humidity",
feature_type=FeatureType.FLOAT_NORMALIZED,
preferred_distribution="bounded" # 💧 Bounded between 0 and 100
),
"pressure": NumericalFeature(
name="pressure",
feature_type=FeatureType.FLOAT_RESCALED,
use_embedding=True,
embedding_dim=16
)
}
)</div>
- Use
FLOAT_NORMALIZEDwhen your data has clear bounds (e.g., 0-100%) - Use
FLOAT_RESCALEDwhen your data has outliers (e.g., income, prices) - Use
FLOAT_DISCRETIZEDwhen your values naturally form groups (e.g., age groups)
- Enable when a simple scaling doesn't capture the pattern
- Increase embedding dimensions for more complex patterns (16→32→64)
- Enable
use_distribution_aware=Trueand let KDP automatically choose - This is especially important for skewed or multi-modal distributions
KDP supports different types of numerical features, each with specialized processing:
<div class="type-card">
<span class="type-icon">📏</span>
<h3>FLOAT_NORMALIZED</h3>
<p>Values normalized to the [0,1] range using min-max scaling</p>
</div>
<div class="type-card">
<span class="type-icon">⚖️</span>
<h3>FLOAT_RESCALED</h3>
<p>Values rescaled using standardization (mean=0, std=1)</p>
</div>
<div class="type-card">
<span class="type-icon">📊</span>
<h3>FLOAT_DISCRETIZED</h3>
<p>Continuous values binned into discrete buckets</p>
</div>
Below is a visualization of a model with a normalized numerical feature:
Below is a visualization of a model with a rescaled numerical feature:
Below is a visualization of a model with a discretized numerical feature:
<style> /* Base styling */ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: #333; margin: 0; padding: 0; } /* Feature header */ .feature-header-container { background: linear-gradient(135deg, #f0f7ff 0%, #e9ecef 100%); border-radius: 10px; padding: 30px; margin: 30px 0; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .feature-header-content h2 { margin-top: 0; color: #4a86e8; } /* Overview card */ .overview-card { background-color: #fff; border-radius: 10px; padding: 20px 25px; margin: 20px 0; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-left: 4px solid #4a86e8; } /* Tables */ .table-container { margin: 25px 0; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .feature-table, .config-table { width: 100%; border-collapse: collapse; } .feature-table th, .config-table th { background-color: #f0f7ff; padding: 15px; text-align: left; font-weight: 600; border-bottom: 2px solid #4a86e8; } .feature-table td, .config-table td { padding: 12px 15px; border-bottom: 1px solid #eaecef; } .feature-table tr:nth-child(even), .config-table tr:nth-child(even) { background-color: #f8f9fa; } .feature-table tr:hover, .config-table tr:hover { background-color: #f0f7ff; } /* Code sections */ .code-section { margin: 25px 0; } .code-description { margin-bottom: 15px; } .code-container { background-color: #f8f9fa; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } .code-container pre { margin: 0; padding: 20px; } /* Feature cards */ .feature-cards { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 30px 0; } .feature-card { background-color: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .feature-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); } .feature-card-header { display: flex; align-items: center; padding: 15px 20px; background: linear-gradient(135deg, #f0f7ff 0%, #e9ecef 100%); border-bottom: 1px solid #e9ecef; } .feature-icon { font-size: 1.5em; margin-right: 15px; } .feature-card-header h3 { margin: 0; color: #333; } .feature-card-content { padding: 20px; } /* Example cards */ .example-cards { display: grid; grid-template-columns: 1fr; gap: 20px; margin: 30px 0; } .example-card { background-color: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .example-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); } .example-header { display: flex; align-items: center; padding: 15px 20px; background: linear-gradient(135deg, #f0f7ff 0%, #e9ecef 100%); border-bottom: 1px solid #e9ecef; } .example-icon { font-size: 1.5em; margin-right: 15px; } .example-header h3 { margin: 0; color: #333; } /* Tips */ .tips-container { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 30px 0; } .tip-card { background-color: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .tip-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); } .tip-header { display: flex; align-items: center; padding: 15px 20px; background: linear-gradient(135deg, #f0f7ff 0%, #e9ecef 100%); border-bottom: 1px solid #e9ecef; } .tip-icon { font-size: 1.5em; margin-right: 15px; } .tip-header h3 { margin: 0; color: #333; } .tip-content { padding: 15px 20px; } .tip-content ul { margin: 0; padding-left: 20px; } .tip-content li { margin-bottom: 8px; } /* Related topics */ .related-topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin: 30px 0; } .related-topic-card { display: flex; align-items: center; background-color: #fff; border-radius: 10px; padding: 15px 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); text-decoration: none; color: #333; transition: transform 0.3s ease, box-shadow 0.3s ease; } .related-topic-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); background-color: #f0f7ff; } .related-topic-icon { font-size: 1.5em; margin-right: 15px; } .related-topic-content h3 { margin: 0 0 5px 0; color: #4a86e8; } .related-topic-content p { margin: 0; font-size: 14px; color: #555; } /* Types section */ .types-container { margin: 30px 0; } .types-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; } .type-card { background-color: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; text-align: center; } .type-card:hover { transform: translateY(-5px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); } .type-icon { font-size: 2em; display: block; margin-bottom: 10px; } .type-card h3 { margin: 10px 0; color: #4a86e8; } .type-card p { margin: 0; font-size: 15px; } /* Diagram section */ .diagram-section { display: grid; grid-template-columns: 1fr; gap: 30px; margin: 30px 0; } .diagram-card { background-color: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .diagram-card h3 { margin-top: 0; color: #4a86e8; border-bottom: 2px solid #eaecef; padding-bottom: 10px; } .diagram-container { text-align: center; margin-top: 20px; } .diagram-image { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: transform 0.3s ease; } .diagram-image:hover { transform: scale(1.02); } /* Navigation */ .nav-container { display: flex; justify-content: space-between; margin: 40px 0; } .nav-button { display: flex; align-items: center; padding: 10px 15px; background-color: #f8f9fa; border-radius: 8px; text-decoration: none; color: #333; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: background-color 0.3s ease, transform 0.3s ease; } .nav-button:hover { background-color: #f0f7ff; transform: translateY(-2px); } .nav-button.prev { padding-left: 10px; } .nav-button.next { padding-right: 10px; } .nav-icon { font-size: 1.2em; margin: 0 8px; } /* Responsive adjustments */ @media (max-width: 1024px) { .tips-container { grid-template-columns: 1fr; } } @media (max-width: 768px) { .tips-container, .example-cards, .related-topics, .types-grid { grid-template-columns: 1fr; } } </style>



