cursus.processing.categorical.risk_table_processor

class RiskTableMappingProcessor(column_name, label_name, smooth_factor=0.0, count_threshold=0, risk_tables=None)[source]

Bases: Processor

A 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.

get_name()[source]
set_risk_tables(risk_tables)[source]
fit(data)[source]
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.

get_risk_tables()[source]
save_risk_tables(output_dir)[source]
load_risk_tables(filepath)[source]