BrierScore¶
yohou.metrics.BrierScore
¶
Bases: BaseClassProbaScorer
Multi-class Brier score for class-probability forecasts.
Measures the mean squared difference between predicted probabilities and one-hot encoded true class labels. Equivalent to the Brier score generalized to multiple classes.
The multi-class Brier score is:
where \(\\hat{p}_{ik}\) is the predicted probability for class \(k\), \(o_{ik}\) is 1 if class \(k\) is the true class and 0 otherwise, and \(K\) is the number of classes.
Parameters ¶
| Name | Type | Description | Default |
|---|---|---|---|
aggregation_method
|
list of str or str
|
Dimensions to aggregate over. See |
"all"
|
groups
|
list of str, dict of str to float, or None
|
Panel group filter (list) or filter with weights (dict). See |
None
|
components
|
list of str, dict of str to float, or None
|
Component filter (list) or filter with weights (dict). See |
None
|
time_weighter
|
BaseWeighter or None
|
Weighter applied along the time axis (observed timestamps). If None, all timestamps contribute equally. |
None
|
step_weighter
|
BaseWeighter or None
|
Weighter applied along the forecasting-step axis. If None, all forecasting steps contribute equally. |
None
|
vintage_weighter
|
BaseWeighter or None
|
Weighter applied along the vintage-time axis. If None, all vintages contribute equally. |
None
|
Attributes ¶
| Name | Type | Description |
|---|---|---|
lower_is_better |
bool
|
Always True for BrierScore. |
Examples ¶
>>> import polars as pl
>>> from datetime import datetime
>>> from yohou.metrics import BrierScore
>>> y_true = pl.DataFrame({
... "time": [datetime(2020, 1, 1), datetime(2020, 1, 2), datetime(2020, 1, 3)],
... "weather": ["sunny", "rainy", "cloudy"],
... })
>>> y_pred = pl.DataFrame({
... "vintage_time": [datetime(2019, 12, 31)] * 3,
... "time": [datetime(2020, 1, 1), datetime(2020, 1, 2), datetime(2020, 1, 3)],
... "weather_proba_sunny": [0.7, 0.1, 0.2],
... "weather_proba_rainy": [0.2, 0.8, 0.1],
... "weather_proba_cloudy": [0.1, 0.1, 0.7],
... })
>>> scorer = BrierScore()
>>> _ = scorer.fit(y_true)
>>> scorer.score(y_true, y_pred)
0.113...
Notes ¶
- Ranges from 0 (perfect) to 2 (worst possible for binary).
- More sensitive to calibration than accuracy.
- Proper scoring rule: optimized by the true probability distribution.
See Also ¶
Source Code ¶
Source code in src/yohou/metrics/class_proba.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
Tutorials¶
The following example notebooks use this component:
-
Class-Probability Forecasting
Forecast air quality categories using ClassProbaReductionForecaster, producing a probability distribution over four WHO air quality classes.
-
How to Combine Classification Forecasters
Build classification ensembles with VotingClassProbaForecaster using soft and hard voting strategies.
-
How to Forecast Class Probabilities
Use ClassProbaReductionForecaster to produce calibrated probability forecasts and evaluate them with Brier score, log loss, and accuracy.
-
How to Score Class-Probability Forecasts
Evaluate categorical forecasts with LogLoss, BrierScore, and Accuracy. Covers per-timestep scoring, aggregation modes, and reliability diagrams.