CompositeWeighter¶
yohou.weighting.CompositeWeighter
¶
Bases: BaseWeighter, _BaseComposition
Combine multiple named weighters into a single weight series.
Multiplies or averages the compute_weights outputs of its components.
Sub-weighters are named (name, weighter) tuples, so their parameters are
addressable as <name>__<param> (sklearn _BaseComposition) and tunable
through a forecaster, for example time_weighter__decay__half_life. Mirrors
CompositeSimilarity and the other yohou compositors (FeaturePipeline,
ColumnForecaster, the voting ensembles, …).
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
weighters
|
list of (str, BaseWeighter) tuples
|
Named component weighters to combine, e.g.
|
None
|
combination
|
('multiply', 'mean')
|
How to combine the component weight series.
|
"multiply"
|
weights
|
list of float or None
|
Per-component exponents (under |
None
|
See Also ¶
ExponentialDecayWeighter: Exponential recency weighting.SeasonalEmphasisWeighter: Seasonal emphasis weighting.
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> times = pl.Series("time", [datetime(2024, 1, d) for d in range(1, 4)])
>>> w = CompositeWeighter([
... ("decay", ExponentialDecayWeighter(2)),
... ("seasonal", SeasonalEmphasisWeighter(2, 1.5)),
... ])
>>> _ = w.compute_weights(times)
Source Code ¶
Source code in src/yohou/weighting/weighters.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
Methods ¶
get_params(deep=True)
¶
Get parameters, including nested component parameters.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
deep
|
bool
|
If True, include component parameters as |
True
|
Returns ¶
| Type | Description |
|---|---|
dict
|
Parameter names mapped to values. |
Source Code ¶
Source code in src/yohou/weighting/weighters.py
set_params(**params)
¶
compute_weights(key, group_name=None)
¶
Combine all component weights for key by product or mean.
Source Code ¶
Source code in src/yohou/weighting/weighters.py
Tutorials¶
The following example notebooks use this component:
-
How to Apply Time-Weighted Training
Use time_weight and sample_weight_alignment to emphasise recent or seasonal training samples in PointReductionForecaster, with visualisation of weight curves and alignment strategy comparison.
-
How to Score with Time-Weighted Metrics
Apply exponential decay, linear decay, and seasonal emphasis weighting to forecast evaluation, prioritising recent or periodic time steps.
-
Quickstart
Comprehensive end-to-end tour of yohou beyond the Getting Started tutorials, covering data loading, baseline forecasting, preprocessing pipelines, decomposition, cross-validation search, and interval prediction.