您可以创建指定特定国家/地区的节假日以及指定您自己的特殊日期的数据框,并将它们作为特征包含在预测中。

import pandas as pd
from nixtla import NixtlaClient
from nixtla.date_features import CountryHolidays
from nixtla.date_features import SpecialDates
nixtla_client = NixtlaClient(
    # defaults to os.environ.get("NIXTLA_API_KEY")
    api_key = 'my_api_key_provided_by_nixtla'
)

👍 使用 Azure AI 端点

要使用 Azure AI 端点,请记住同时设置 base_url 参数

nixtla_client = NixtlaClient(base_url="you azure ai endpoint", api_key="your api_key")

# Get country holidays for the US
c_holidays = CountryHolidays(countries=['US'])
periods = 365 * 1
dates = pd.date_range(end='2023-09-01', periods=periods)
holidays_df = c_holidays(dates)

# Specify your own special dates
special_dates = SpecialDates(
    special_dates={
        'Important Dates': ['2021-02-26', '2020-02-26'],
        'Very Important Dates': ['2021-01-26', '2020-01-26', '2019-01-26']
    }
)
periods = 365 * 1
dates = pd.date_range(end='2023-09-01', periods=periods)
special_dates_df = special_dates(dates)

有关使用特殊日期和节假日的详细指南,请阅读我们的教程:节假日和特殊日期