Skip to content

Submitting Historical Forecasts

Forecasters must submit historical forecast samples to the Predico platform before making their first forecast submission. This step is mandatory to assess the forecaster's potential and define the ensemble methodology. In this example, we'll demonstrate how to prepare and submit 1 month of historical forecast data with a 15-minute time resolution. Replace the random data generation with your actual forecasting model as needed.

API Endpoints:

To interact with the Predicto API and submit
your historical forecasts, you can use the following endpoints:

Prerequisites

  • Access Token: Ensure you have a valid access token. Refer to the Authentication section if needed.
  • Selected Challenge: You should have a selected challenge from the Listing Challenges section.
  • Prepared Historical Forecast Data: Follow the steps outlined below to prepare your historical forecasts.

Check this out

Check our Useful Links section for additional resources (Jupyter Notebook, API Specifications) to help you get started with the Predico platform.

Overview

Submitting historical forecasts is essential for new forecasters to participate in a collaborative forecasting session. This process involves generating or preparing a dataset of historical forecasts and submitting them to the Predico API. Proper handling of this data ensures the integrity and reliability of your submissions.

Unpacking Selected Challenge Information

Before submitting your forecast, extract essential information from the selected challenge:

submit_historical_forecast.py
# Get the session id from `/market/session/` endpoint
open_market_session_id = "your_open_market_session_id"

# Request the challenges for the open market session:
response = requests.get(
    url='https://predico-elia.inesctec.pt/api/v1/market/challenge',
    params={'market_session': int(open_market_session_id)},
    headers=headers
)

# Check if the request was successful
if response.status_code == 200:
    challenges = response.json()
else:
    print("Failed to retrieve challenges.")
    print(f"Status code: {response.status_code}")
    exit()

# Select the first challenge of the list of challenges previous retrieved
selected_challenge = challenges["data"][0]

# Unpack selected challenge information
resource_id = selected_challenge["resource"]
challenge_id = selected_challenge["id"]
start_datetime = selected_challenge["start_datetime"]

Preparing Historical Forecast Data

Prepare the historical forecast data for submission.

Important

In this example, our submission will be exclusively composed by random samples. However, you should prepare your model based on the raw measurements data for the challenge resource (see Downloading Raw Data section), and any external information sources you might have access to.

submit_historical_forecast.py
# Create 1month of historical data (sampled from uniform dist):
# Generate datetime values for the challenge period:
n_historical_days = 35

dt_now = pd.to_datetime(dt.datetime.utcnow()).round("15min")
hist_datetime_range = pd.date_range(start=dt_now - pd.DateOffset(days=n_historical_days),
                                    end=dt_now.replace(hour=23, minute=45, second=00),
                                    freq='15min')
hist_datetime_range = [x.strftime("%Y-%m-%dT%H:%M:%SZ") for x in hist_datetime_range]

# Generate random values for the "value" column
hist_values = np.random.uniform(low=0.0, high=1.0, size=len(hist_datetime_range))
hist_values = [round(x, 3) for x in hist_values]

# Prepare historical data for 3 different quantiles submissions Q10, Q50, Q90
hist_submission_list = []
for qt in ["q10", "q50", "q90"]:
    qt_forec = pd.DataFrame({
    'datetime': hist_datetime_range,
    'value': hist_values,
    })
    hist_submission_list.append({
        "resource": resource_id,
        "variable": qt,
        "launch_time": dt_now.strftime("%Y-%m-%dT%H:%M:%SZ"),
        "forecasts": qt_forec.to_dict(orient="records")
    })

Submitting Historical Forecast Data

After preparing your historical forecast data, submit it to the Predico platform:

Important

  • Forecast Integrity: Ensure that your historical forecasts are realistic (i.e., for an out-of-sample set). Providing unrealistic historical forecasts (e.g., overfitting to historical data) may compromise your submission. Remember, payment is based on ex-post performance calculations and not on the quality of this initial historical forecasts.
  • Submission Volume: Avoid transferring a high volume of samples in a single request to prevent potential request failures. It's recommended to batch your submissions appropriately.
submit_historical_forecast.py
# Submit historical forecasts:
for submission in hist_submission_list:
    response = requests.post(url=f"https://predico-elia.inesctec.pt/api/v1/data/individual-forecasts/historical",
                            json=submission,
                            headers=headers)

    # Check if the request was successful
    if response.status_code == 201:
        print(f"Forecast submission successful for {submission['variable']} quantile.")
    else:
        print(f"Failed to submit forecast for {submission['variable']} quantile.")
        print(f"Status code: {response.status_code}")

Download Full Example

What's next?

Learn how to download your historical forecasts on the Listing Historical Forecasts section.