frequency¶
Shared typed keys and frozen unary-frequency mappings.
apply_frequency_mapping(series, mapping)
¶
Apply a frozen frequency mapping without learning from the current batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
Series
|
Values to transform, with any index or batch size. |
required |
mapping
|
Mapping[str, float]
|
Fitted mapping from |
required |
Returns:
| Type | Description |
|---|---|
Series
|
Float frequencies with the same index. Unknown and missing/nonfinite values return zero. Neither the input nor the mapping is modified. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a value is not a supported scalar. |
Source code in featcopilot/utils/frequency.py
category_key(value)
¶
Encode a scalar using the existing fitted-rule key convention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
String, boolean, real number or missing scalar. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
JSON key distinguishing strings, booleans and numbers. Integral floats and equal integers share a key. Missing/nonfinite numbers return None. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value is not a supported scalar. Its contents are not logged. |
Source code in featcopilot/utils/frequency.py
category_keys(series)
¶
Encode series values positionally with the fitted-rule key convention.
fit_frequency_mapping(series)
¶
Fit unary frequencies using only the supplied training rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
series
|
Series
|
Nonempty training values. Missing values count in the denominator, but do not create mapping entries. No targets are accepted. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, float]
|
Typed keys mapped to count / total training rows, preserving the existing fitted-rule serialization format. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If training is empty or contains unsupported scalar types. |