cursus.processing.categorical.risk_table_processor¶
- class RiskTableMappingProcessor(column_name, label_name, smooth_factor=0.0, count_threshold=0, risk_tables=None)[source]¶
Bases:
ProcessorA processor that performs risk-table-based mapping on a specified categorical variable. The ‘process’ method (called via __call__) handles single values. The ‘transform’ method handles pandas Series or DataFrames.
- process(input_value)[source]¶
Process a single input value (for the configured ‘column_name’), mapping it to its binned risk value. This method is called when the processor instance is called as a function.
- transform(data)[source]¶
Transform data using the computed risk tables. - If data is a DataFrame, transforms the ‘column_name’ Series within it. - If data is a Series, transforms the Series (assumed to be the target column). - If data is a single value, uses the ‘process’ method.
Performance optimized: Uses fast path for single-value Series.