BaseWeighter¶
yohou.weighting.BaseWeighter
¶
Bases: BaseEstimator
Base class for time-axis weighter estimators.
A weighter maps a key series (datetime times, vintage times, or integer
forecasting steps) to a series of non-negative weights. Concrete subclasses
declare their tunable parameters in _parameter_constraints and implement
:meth:compute_weights. Because weighters are scikit-learn estimators, their
parameters can be addressed with the __ syntax (e.g.
time_weighter__half_life) and tuned by search.
Notes ¶
Weighters are stateless by default: :meth:fit is a no-op that exists so a
future data-dependent weighter can hook into the host estimator's fit
without an API change.
See Also ¶
ExponentialDecayWeighter: Recency decay weighting.LinearDecayWeighter: Linear recency weighting.SeasonalEmphasisWeighter: Seasonal emphasis weighting.LookupWeighter: Explicit per-key weights.TableWeighter: DataFrame-driven weights.CompositeWeighter: Combine weighters by product or mean.
Source Code ¶
Source code in src/yohou/weighting/weighters.py
Methods ¶
__init_subclass__(**kwargs)
¶
Merge parameter constraints from all classes in the MRO.
Source Code ¶
Source code in src/yohou/weighting/weighters.py
fit(y=None, **params)
¶
Fit the weighter (no-op by default).
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
y
|
DataFrame or None
|
Training data. Ignored by stateless weighters. |
None
|
**params
|
dict
|
Ignored. Present for routing compatibility. |
{}
|
Returns ¶
| Type | Description |
|---|---|
self
|
|
Source Code ¶
Source code in src/yohou/weighting/weighters.py
compute_weights(key, group_name=None)
abstractmethod
¶
Compute one weight per element of key.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Series
|
Key series to weight: datetime times, vintage times, or integer forecasting steps. |
required |
group_name
|
str or None
|
Panel group name for panel-aware weighting, or None for global data. |
None
|
Returns ¶
| Type | Description |
|---|---|
Series
|
Float64 weight series aligned to |