metacausal.aggregation.TrimmedMean¶
- class metacausal.aggregation.TrimmedMean(trim_count=1)[source]¶
Bases:
PointwiseStrategyPointwise trimmed-mean aggregation.
Drops the
trim_counthighest and lowest component estimates at each point, then averages the remainder. A tunable middle ground betweenMean(no trimming) andMedian(maximal trimming).- Parameters:
trim_count (int) – Number of models to drop from each tail. Default 1. Must satisfy
2 * trim_count < Kwhere K is the number of component models.
Examples
Same four component predictions as
Median’s example;trim_count=1drops the 90.0 outlier (and the lowest value, 10.0) before averaging, recovering the same robust result as the median:>>> import numpy as np >>> from metacausal.aggregation import TrimmedMean >>> values = np.array([[10.0, 5.0], [11.0, 5.0], [12.0, 5.0], [90.0, 5.0]]) >>> TrimmedMean(trim_count=1).aggregate(values) array([11.5, 5. ])
Methods
__init__Reduce a
(K, n)component-CATE matrix to a(n,)ensemble CATE.Attributes
ensemble_weightsEnsemble weights, if applicable.
strategy_familyDetails
- aggregate(values)[source]¶
Reduce a
(K, n)component-CATE matrix to a(n,)ensemble CATE.Kis the number of component models;nis the number of evaluation points. Subclasses define the per-family rule (pointwise statistical reduction, weighted combination, learned linear combination, etc.).PointwiseStrategyextends this contract to also accept(K,)1-D input (returning a 0-d scalar) for the component-ATE aggregation path; see its class docstring. Other families do not meaningfully support 1-D input.