data

Attributes

WeightingStrategy

logger

Classes

NightlyForecasts

Functions

uniform_weighting()

first_n_weighting([n, group_col, time_col])

last_n_weighting([n, group_col, time_col])

exponential_weighting([lambda_, time_col])

time_to_last_weighting([min_hours, max_hours])

Filter predictions based on their time gap to the market close time.

Module Contents

data.WeightingStrategy
data.logger
data.uniform_weighting()
data.first_n_weighting(n=1, group_col: list[str] = ['forecaster', 'event_ticker'], time_col: str = 'round')
data.last_n_weighting(n=1, group_col: list[str] = ['forecaster', 'event_ticker'], time_col: str = 'round')
data.exponential_weighting(lambda_=0.1, time_col: str = 'time_rank')
data.time_to_last_weighting(min_hours: float = 0.0, max_hours: float = float('inf'))

Filter predictions based on their time gap to the market close time.

This weighting function filters predictions based on how many hours before market close they were made. It automatically calculates ‘time_to_last’ if not present using the calculate_time_to_last_submission function from utils.py.

Special handling for single-submission events: - Events with only one submission are ALWAYS included regardless of time range - This prevents filtering out events that had no opportunity for multiple predictions

Args:

min_hours: Minimum hours before market close (inclusive). Default: 0.0 max_hours: Maximum hours before market close (exclusive). Default: inf (no upper limit)

Returns:

A weighting function that filters predictions within [min_hours, max_hours) and assigns weight=1.0

Example:

# Only keep predictions made 6-12 hours before market close weight_fn = time_to_last_weighting(min_hours=6.0, max_hours=12.0)

# Only keep predictions made more than 24 hours before market close weight_fn = time_to_last_weighting(min_hours=24.0, max_hours=float(‘inf’))

# Only keep predictions made within 3 hours of market close weight_fn = time_to_last_weighting(min_hours=0.0, max_hours=3.0)

class data.NightlyForecasts(forecasts: pandas.DataFrame, exclude_forecasters: list[str] = None)
PREDICTION_COLS = ['predictor_name', 'event_ticker', 'submission_count', 'prediction', 'market_outcome', 'category']
SUBMISSION_COLS = ['event_ticker', 'submission_count', 'market_data', 'snapshot_time', 'close_time']
RENAMES
data
static turn_market_data_to_odds(market_data: dict) tuple[numpy.ndarray, numpy.ndarray]
static simplify_prediction(prediction: dict) numpy.ndarray
static simplify_market_outcome(market_outcome: dict) numpy.ndarray
classmethod from_prophet_arena_csv(predictions_csv: str, submissions_csv: str, weight_fn=uniform_weighting(), exclude_forecasters: list[str] = None)