CFPB daily complaint forecasting¶
This notebook forecasts daily credit-card complaint volume for the fixed evaluation window 17ā30 November 2025. All exploration and model choices are based on information available up to 16 November 2025.
Methods compared on the same 14-day holdout:
- Seven-day seasonal-naive forecast
- SARIMA statistical forecast
- Zero-shot Amazon Chronos-2 foundation-model forecast
- Optional zero-shot Chronos-2 forecast with known-future calendar covariates
0. Setup¶
A GPU is recommended for Chronos-2 inference, although the model can run on CPU.
%pip install -q "chronos-forecasting>=2.2" "pandas[pyarrow]" statsmodels matplotlib seaborn
import time
import warnings
from itertools import product
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import torch
from chronos import Chronos2Pipeline
from sklearn.metrics import mean_absolute_error
from statsmodels.graphics.tsaplots import plot_acf
from statsmodels.tsa.statespace.sarimax import SARIMAX
RANDOM_STATE = 42
TEST_START = pd.Timestamp("2025-11-17")
TEST_END = pd.Timestamp("2025-11-30")
H = (TEST_END - TEST_START).days + 1
SEASON = 7
device = "cuda" if torch.cuda.is_available() else "cpu"
print("Running on:", device)
if device == "cuda":
print("GPU:", torch.cuda.get_device_name(0))
print("Forecast horizon:", H, "days")
Running on: cpu Forecast horizon: 14 days
1. Load and understand the data¶
The target is not stored directly. It is constructed by counting unique complaint IDs received on each calendar day. The received date and complaint ID are available when a complaint enters the system.
"""from google.colab import files
uploaded = files.upload()
DATA_FILE = "cfpb_creditcard_2025.csv"
if DATA_FILE not in uploaded:
raise FileNotFoundError(f"Please upload {DATA_FILE}")
df = pd.read_csv(DATA_FILE)
print("Rows:", len(df))
print("Columns:", len(df.columns))
if len(df) != 38336:
print("WARNING: the assignment describes an extract with 38,336 rows. Check that the complete CSV was uploaded.")
display(df.head())"""
import pandas as pd
from pathlib import Path
DATA_FILE = "cfpb_creditcard_2025.csv"
DATA_URL = "https://localhost:3000/datasets/cfpb_creditcard_2025.csv"
# Use local file if available, otherwise load from Thinking Red
if Path(DATA_FILE).exists():
df = pd.read_csv(DATA_FILE)
else:
df = pd.read_csv(DATA_URL)
print("Rows:", len(df))
print("Columns:", len(df.columns))
if len(df) != 38336:
print("WARNING: Expected 38,336 rows. Check that the complete CSV was loaded.")
display(df.head())
Rows: 38336 Columns: 14
| Date received | Product | Sub-product | Issue | Sub-issue | Consumer complaint narrative | Company | State | Tags | Submitted via | Date sent to company | Company response to consumer | Timely response? | Complaint ID | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2025-11-26T04:48:32.000Z | Credit card | General-purpose credit card or charge card | Problem with a purchase shown on your statement | Card was charged for something you did not pur... | Summary of Incident as documented in Police Re... | BANK OF AMERICA, NATIONAL ASSOCIATION | TX | NaN | Web | 2025-11-26T05:21:42.000Z | Closed with monetary relief | No | 17889217.0 |
| 1 | 2025-01-21T22:31:05.000Z | Credit card | General-purpose credit card or charge card | Problem with a purchase shown on your statement | Credit card company isn't resolving a dispute ... | A subscription service I had with XXXX renewed... | AMERICAN EXPRESS COMPANY | MA | NaN | Web | 2025-01-21T22:43:43.000Z | Closed with explanation | Yes | 11750463.0 |
| 2 | 2025-11-06T17:20:36.000Z | Credit card | General-purpose credit card or charge card | Fees or interest | Charged too much interest | Credit card issuer : Imprint ( XXXX XXXX XXXX ... | Imprint Payments, Inc. | IL | NaN | Web | 2026-05-06T20:35:28.000Z | Closed with explanation | Yes | 21948206.0 |
| 3 | 2025-07-02T00:10:30.000Z | Credit card | Store credit card | Incorrect information on your report | Account information incorrect | My CareCredit account through Synchrony Bank w... | SYNCHRONY FINANCIAL | CA | NaN | Web | 2025-07-02T01:15:15.000Z | Closed with explanation | Yes | 14402760.0 |
| 4 | 2025-11-07T18:02:10.000Z | Credit card | General-purpose credit card or charge card | Problem with a purchase shown on your statement | Credit card company isn't resolving a dispute ... | The credit card company had access to my bank ... | We Collect Inc | NY | NaN | Web | 2025-11-07T18:13:40.000Z | Untimely response | No | 17819351.0 |
df["Date received"] = pd.to_datetime(
df["Date received"],
format="mixed",
utc=True,
errors="coerce"
)
print("Missing received dates:", df["Date received"].isna().sum())
print("Missing complaint IDs:", df["Complaint ID"].isna().sum())
print("Duplicated complaint IDs:", df["Complaint ID"].duplicated().sum())
print("First received date:", df["Date received"].min())
print("Last received date:", df["Date received"].max())
Missing received dates: 0 Missing complaint IDs: 0 Duplicated complaint IDs: 0 First received date: 2025-01-01 00:00:00+00:00 Last received date: 2025-11-30 00:00:00+00:00
Reference-value check¶
Daily volume is a measured/derived target rather than a human judgement: each value is the number of unique complaint IDs carrying that received date. Possible errors include missing or duplicated complaint IDs, invalid dates, extraction omissions, and changes in CFPB intake or publication processes. The following checks look for impossible negative or fractional counts, missing calendar dates and duplicate identifiers.
observed_daily_counts = (
df.dropna(subset=["Date received", "Complaint ID"])
.assign(date=lambda x: x["Date received"].dt.tz_convert(None).dt.normalize())
.groupby("date")["Complaint ID"]
.nunique()
.rename("Complaint Count")
)
required_index = pd.date_range(
"2025-01-01",
TEST_END,
freq="D"
)
missing_calendar_dates = required_index.difference(observed_daily_counts.index)
missing_evaluation_dates = pd.date_range(TEST_START, TEST_END, freq="D").difference(observed_daily_counts.index)
print("Calendar dates absent from the source records:", len(missing_calendar_dates))
print("Evaluation dates absent from the source records:", list(missing_evaluation_dates.date))
if len(missing_evaluation_dates) > 0:
raise ValueError(
"The CSV does not contain records for every date in the fixed 17-30 November evaluation window. "
"Do not treat these dates as zero automatically; confirm that the complete 38,336-row assignment extract was uploaded."
)
daily_counts = observed_daily_counts.reindex(required_index, fill_value=0)
daily_counts.index.name = "timestamp"
print("Daily observations:", len(daily_counts))
print("Negative counts:", (daily_counts < 0).sum())
print("Non-integer counts:", ((daily_counts % 1) != 0).sum())
display(daily_counts.describe())
Calendar dates absent from the source records: 0 Evaluation dates absent from the source records: [] Daily observations: 334 Negative counts: 0 Non-integer counts: 0
| Complaint Count | |
|---|---|
| count | 334.000000 |
| mean | 114.778443 |
| std | 37.797691 |
| min | 1.000000 |
| 25% | 85.000000 |
| 50% | 119.500000 |
| 75% | 141.000000 |
| max | 211.000000 |
2. Fixed chronological split¶
The notebook fixes 17ā30 November 2025 as the evaluation window. These observations are separated before exploration or model choice. Random splitting would leak future complaint volumes into the forecast history.
train_series = daily_counts.loc[daily_counts.index < TEST_START].copy()
test_series = daily_counts.loc[TEST_START:TEST_END].copy()
assert len(test_series) == H, "The fixed evaluation window should contain 14 daily observations."
assert train_series.index.max() == TEST_START - pd.Timedelta(days=1)
assert test_series.index.min() == TEST_START
print("Training:", train_series.index.min().date(), "to", train_series.index.max().date())
print("Evaluation:", test_series.index.min().date(), "to", test_series.index.max().date())
print("Training observations:", len(train_series))
print("Evaluation observations:", len(test_series))
Training: 2025-01-01 to 2025-11-16 Evaluation: 2025-11-17 to 2025-11-30 Training observations: 320 Evaluation observations: 14
3. Training-only exploration¶
Only the pre-evaluation history is used here. The plots assess trend, unusual observations and weekly seasonality without exposing the fixed holdout.
fig, ax = plt.subplots(figsize=(12, 4))
ax.plot(train_series.index, train_series.values, lw=1)
ax.set(title="Daily CFPB credit-card complaints: training period", xlabel="Date", ylabel="Complaint count")
plt.tight_layout()
plt.show()
display(train_series.describe(percentiles=[0.05, 0.25, 0.5, 0.75, 0.95]))
| Complaint Count | |
|---|---|
| count | 320.000000 |
| mean | 114.646875 |
| std | 37.403380 |
| min | 1.000000 |
| 5% | 56.900000 |
| 25% | 85.000000 |
| 50% | 119.000000 |
| 75% | 140.000000 |
| 95% | 172.050000 |
| max | 211.000000 |
weekday_order = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
weekday_summary = (
train_series.groupby(train_series.index.day_name())
.agg(["mean", "median", "count"])
.reindex(weekday_order)
)
display(weekday_summary.round(2))
fig, ax = plt.subplots(figsize=(10, 4))
ax.bar(weekday_summary.index, weekday_summary["mean"])
ax.set(title="Average daily complaint volume by weekday: training only", xlabel="Weekday", ylabel="Mean complaints")
ax.tick_params(axis="x", rotation=45)
plt.tight_layout()
plt.show()
| mean | median | count | |
|---|---|---|---|
| timestamp | |||
| Monday | 122.76 | 124.0 | 45 |
| Tuesday | 138.02 | 138.0 | 45 |
| Wednesday | 136.35 | 136.5 | 46 |
| Thursday | 138.96 | 135.0 | 46 |
| Friday | 127.26 | 123.0 | 46 |
| Saturday | 74.85 | 77.5 | 46 |
| Sunday | 65.02 | 64.0 | 46 |
fig, ax = plt.subplots(figsize=(11, 4))
plot_acf(train_series, lags=42, ax=ax)
ax.set_title("Autocorrelation of daily complaint volume: training only")
plt.tight_layout()
plt.show()
Interpret after running: describe whether the training series shows trend, outliers and repeating correlations at lags 7, 14, 21 and later. Weekly repetition motivates a seven-day seasonal-naive baseline and weekly SARIMA seasonality. Risks include the short 2025 history, holidays, reporting delays, structural changes, and the fact that published CFPB records may not represent every complaint received by a financial provider.
4. No-training baseline: seasonal naive¶
The roster is prepared two weeks ahead, and the training analysis indicates a weekly pattern. The baseline therefore repeats the last observed week across the 14-day horizon.
def seasonal_naive(history, forecast_index, season=7):
"""Repeat the final observed seasonal cycle across the forecast horizon."""
last_cycle = history.iloc[-season:].to_numpy()
repeated = np.resize(last_cycle, len(forecast_index))
return pd.Series(repeated, index=forecast_index, name="Seasonal naive")
naive_forecast = seasonal_naive(train_series, test_series.index, SEASON)
naive_mae = mean_absolute_error(test_series, naive_forecast)
print(f"Seasonal-naive MAE: {naive_mae:.2f} complaints per day")
display(pd.concat([test_series, naive_forecast], axis=1))
Seasonal-naive MAE: 34.07 complaints per day
| Complaint Count | Seasonal naive | |
|---|---|---|
| timestamp | ||
| 2025-11-17 | 147 | 148 |
| 2025-11-18 | 168 | 150 |
| 2025-11-19 | 171 | 157 |
| 2025-11-20 | 157 | 184 |
| 2025-11-21 | 149 | 188 |
| 2025-11-22 | 45 | 101 |
| 2025-11-23 | 77 | 89 |
| 2025-11-24 | 133 | 148 |
| 2025-11-25 | 164 | 150 |
| 2025-11-26 | 155 | 157 |
| 2025-11-27 | 85 | 184 |
| 2025-11-28 | 88 | 188 |
| 2025-11-29 | 60 | 101 |
| 2025-11-30 | 50 | 89 |
MAE is used because it is expressed in complaints per day and is easy to explain operationally. MAPE is less suitable because division by small or zero daily counts can produce unstable or undefined percentages.
5. Trained statistical baseline: SARIMA¶
SARIMA candidates are selected using a 14-day validation window taken from the end of the training history. The fixed 17ā30 November test period remains untouched. The candidate space is deliberately small so the notebook remains practical and explainable.
validation_horizon = H
sarima_train = train_series.iloc[:-validation_horizon]
sarima_validation = train_series.iloc[-validation_horizon:]
candidate_orders = list(product([0, 1], [0, 1], [0, 1]))
candidate_seasonal = list(product([0, 1], [1], [0, 1], [SEASON]))
sarima_search_rows = []
for order in candidate_orders:
for seasonal_order in candidate_seasonal:
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
fitted = SARIMAX(
sarima_train,
order=order,
seasonal_order=seasonal_order,
enforce_stationarity=False,
enforce_invertibility=False
).fit(disp=False)
validation_prediction = fitted.get_forecast(steps=validation_horizon).predicted_mean
validation_prediction.index = sarima_validation.index
validation_mae = mean_absolute_error(sarima_validation, validation_prediction)
sarima_search_rows.append({
"order": order,
"seasonal_order": seasonal_order,
"validation_MAE": validation_mae
})
except Exception as error:
print("Skipped", order, seasonal_order, type(error).__name__)
sarima_search = (
pd.DataFrame(sarima_search_rows)
.sort_values("validation_MAE")
.reset_index(drop=True)
)
display(sarima_search.head(10).round(3))
| order | seasonal_order | validation_MAE | |
|---|---|---|---|
| 0 | (0, 1, 0) | (1, 1, 0, 7) | 17.734 |
| 1 | (0, 1, 1) | (0, 1, 1, 7) | 18.578 |
| 2 | (0, 1, 1) | (1, 1, 1, 7) | 18.583 |
| 3 | (1, 1, 0) | (1, 1, 0, 7) | 18.841 |
| 4 | (1, 1, 1) | (1, 1, 0, 7) | 19.009 |
| 5 | (1, 1, 0) | (0, 1, 1, 7) | 19.252 |
| 6 | (1, 1, 0) | (1, 1, 1, 7) | 19.281 |
| 7 | (0, 0, 0) | (0, 1, 0, 7) | 19.357 |
| 8 | (0, 1, 1) | (1, 1, 0, 7) | 19.577 |
| 9 | (0, 0, 1) | (0, 1, 0, 7) | 19.669 |
best_order = sarima_search.loc[0, "order"]
best_seasonal_order = sarima_search.loc[0, "seasonal_order"]
with warnings.catch_warnings():
warnings.simplefilter("ignore")
sarima_model = SARIMAX(
train_series,
order=best_order,
seasonal_order=best_seasonal_order,
enforce_stationarity=False,
enforce_invertibility=False
).fit(disp=False)
sarima_result = sarima_model.get_forecast(steps=H)
sarima_forecast = sarima_result.predicted_mean
sarima_forecast.index = test_series.index
sarima_forecast.name = "SARIMA"
sarima_interval = sarima_result.conf_int(alpha=0.20)
sarima_interval.index = test_series.index
sarima_interval.columns = ["SARIMA lower", "SARIMA upper"]
sarima_mae = mean_absolute_error(test_series, sarima_forecast)
sarima_coverage = test_series.between(sarima_interval.iloc[:, 0], sarima_interval.iloc[:, 1]).mean()
print("Selected order:", best_order)
print("Selected seasonal order:", best_seasonal_order)
print(f"SARIMA MAE: {sarima_mae:.2f}")
print(f"SARIMA empirical 80% interval coverage: {sarima_coverage:.1%}")
Selected order: (0, 1, 0) Selected seasonal order: (1, 1, 0, 7) SARIMA MAE: 41.23 SARIMA empirical 80% interval coverage: 100.0%
6. Zero-shot Chronos-2¶
Chronos-2 is used without dataset-specific fitting. The model receives only the history available through 16 November and returns predictive quantiles for the fixed 14-day horizon.
pipeline = Chronos2Pipeline.from_pretrained(
"amazon/chronos-2",
device_map=device
)
chronos_history = train_series.rename("target").reset_index()
chronos_history.insert(0, "item_id", "credit_card_complaints")
chronos_history = chronos_history[["item_id", "timestamp", "target"]]
started = time.time()
chronos_forecast = pipeline.predict_df(
chronos_history,
prediction_length=H,
quantile_levels=[0.1, 0.5, 0.9]
)
chronos_seconds = time.time() - started
display(chronos_forecast.head())
print(f"Chronos-2 inference time: {chronos_seconds:.2f} seconds")
| item_id | timestamp | target_name | predictions | 0.1 | 0.5 | 0.9 | |
|---|---|---|---|---|---|---|---|
| 0 | credit_card_complaints | 2025-11-17 | target | 159.764648 | 125.917511 | 159.764648 | 189.387085 |
| 1 | credit_card_complaints | 2025-11-18 | target | 171.038055 | 138.940491 | 171.038055 | 199.901031 |
| 2 | credit_card_complaints | 2025-11-19 | target | 170.734390 | 137.007553 | 170.734390 | 201.800842 |
| 3 | credit_card_complaints | 2025-11-20 | target | 170.788055 | 136.648300 | 170.788055 | 200.706497 |
| 4 | credit_card_complaints | 2025-11-21 | target | 159.315598 | 122.613106 | 159.315598 | 190.431778 |
Chronos-2 inference time: 1.04 seconds
chronos_evaluation = (
test_series.rename("actual").reset_index()
.merge(
chronos_forecast[["timestamp", "0.1", "0.5", "0.9"]],
on="timestamp",
how="inner"
)
)
assert len(chronos_evaluation) == H, "Chronos timestamps do not match the fixed holdout."
chronos_mae = mean_absolute_error(
chronos_evaluation["actual"],
chronos_evaluation["0.5"]
)
chronos_inside = chronos_evaluation["actual"].between(
chronos_evaluation["0.1"],
chronos_evaluation["0.9"]
)
chronos_coverage = chronos_inside.mean()
chronos_width = (chronos_evaluation["0.9"] - chronos_evaluation["0.1"]).mean()
print(f"Chronos-2 median MAE: {chronos_mae:.2f} complaints per day")
print(f"Empirical 80% interval coverage: {chronos_coverage:.1%} ({chronos_inside.sum()} of {H} days)")
print(f"Mean 80% interval width: {chronos_width:.2f} complaints")
print("Negative median forecasts:", (chronos_evaluation["0.5"] < 0).sum())
Chronos-2 median MAE: 24.51 complaints per day Empirical 80% interval coverage: 78.6% (11 of 14 days) Mean 80% interval width: 61.83 complaints Negative median forecasts: 0
Coverage and accuracy answer different questions. An 80% prediction interval is calibrated when it contains the realised value on approximately 80% of comparable forecast dates over repeated evaluations. Fourteen holdout days are too few to assess calibration precisely, so coverage here is descriptive.
7. Known-future calendar covariates¶
Weekday and weekend indicators are known when the roster is prepared and are therefore legitimate future inputs. Realised future Issue, Company, State, Submitted via and response fields are not known before complaints arrive and would leak future information. This zero-shot covariate experiment is pre-specified from the training-only weekday analysis.
def add_calendar_covariates(frame):
result = frame.copy()
for day_number in range(7):
result[f"weekday_{day_number}"] = (result["timestamp"].dt.dayofweek == day_number).astype(int)
result["is_weekend"] = (result["timestamp"].dt.dayofweek >= 5).astype(int)
return result
chronos_history_cov = add_calendar_covariates(chronos_history)
future_covariates = pd.DataFrame({
"item_id": "credit_card_complaints",
"timestamp": test_series.index
})
future_covariates = add_calendar_covariates(future_covariates)
chronos_cov_forecast = pipeline.predict_df(
chronos_history_cov,
future_df=future_covariates,
prediction_length=H,
quantile_levels=[0.1, 0.5, 0.9]
)
chronos_cov_evaluation = (
test_series.rename("actual").reset_index()
.merge(chronos_cov_forecast[["timestamp", "0.1", "0.5", "0.9"]], on="timestamp")
)
chronos_cov_mae = mean_absolute_error(chronos_cov_evaluation["actual"], chronos_cov_evaluation["0.5"])
chronos_cov_inside = chronos_cov_evaluation["actual"].between(chronos_cov_evaluation["0.1"], chronos_cov_evaluation["0.9"])
chronos_cov_coverage = chronos_cov_inside.mean()
print(f"Chronos-2 + calendar MAE: {chronos_cov_mae:.2f}")
print(f"Chronos-2 + calendar 80% coverage: {chronos_cov_coverage:.1%}")
Chronos-2 + calendar MAE: 18.89 Chronos-2 + calendar 80% coverage: 78.6%
8. Final comparison on the fixed holdout¶
Every method below is scored against exactly the same 14 actual daily counts. The baseline ratio is method MAE divided by seasonal-naive MAE; values below 1 indicate improvement over the no-training baseline.
comparison = pd.DataFrame([
{"Method": "Seasonal naive", "MAE": naive_mae, "80% interval coverage": np.nan},
{"Method": "SARIMA", "MAE": sarima_mae, "80% interval coverage": sarima_coverage},
{"Method": "Chronos-2 zero-shot", "MAE": chronos_mae, "80% interval coverage": chronos_coverage},
{"Method": "Chronos-2 + calendar", "MAE": chronos_cov_mae, "80% interval coverage": chronos_cov_coverage}
])
comparison["MAE / seasonal-naive MAE"] = comparison["MAE"] / naive_mae
comparison = comparison.sort_values("MAE").reset_index(drop=True)
display(comparison.round(3))
| Method | MAE | 80% interval coverage | MAE / seasonal-naive MAE | |
|---|---|---|---|---|
| 0 | Chronos-2 + calendar | 18.895 | 0.786 | 0.555 |
| 1 | Chronos-2 zero-shot | 24.513 | 0.786 | 0.719 |
| 2 | Seasonal naive | 34.071 | NaN | 1.000 |
| 3 | SARIMA | 41.225 | 1.000 | 1.210 |
plot_df = pd.DataFrame({
"Actual": test_series,
"Seasonal naive": naive_forecast,
"SARIMA": sarima_forecast,
"Chronos-2": chronos_evaluation.set_index("timestamp")["0.5"]
})
fig, ax = plt.subplots(figsize=(12, 5))
for column in plot_df.columns:
ax.plot(plot_df.index, plot_df[column], marker="o", label=column)
ax.fill_between(
chronos_evaluation["timestamp"],
chronos_evaluation["0.1"],
chronos_evaluation["0.9"],
color="tab:red",
alpha=0.15,
label="Chronos-2 80% interval"
)
ax.set(title="Forecasts for the fixed evaluation window", xlabel="Date", ylabel="Complaint count")
ax.legend(ncol=2)
plt.tight_layout()
plt.show()
9. Extra-input availability¶
| Potential input | Available when forecasting? | Appropriate use |
|---|---|---|
| Historical daily complaint counts | Yes | Core target history |
| Future weekday/weekend | Yes | Known-future calendar covariate |
| Public-holiday calendar | Yes, if prepared in advance | Known-future calendar covariate |
| Historical Issue or channel counts | Yes for past dates | Past-only covariates |
| Future realised Issue, Company, State or Submitted via | No | Exclude; would leak future arrivals |
| Company response and Timely response | No, created after submission | Exclude; post-outcome leakage |
Before operational use, monitor MAE by forecast origin and horizon, interval coverage across repeated origins, systematic weekday bias, data delays, missing dates, structural breaks, inference runtime and model/library version changes.
import matplotlib.pyplot as plt
red = "#C71E31"
grey = "#777B80"
background = "#F5F4F0"
fig, ax = plt.subplots(figsize=(8, 4.5))
fig.patch.set_facecolor(background)
ax.set_facecolor(background)
# Historical observations - final 14 days
history = train_series.tail(14)
ax.plot(
history.index,
history.values,
color=grey,
linewidth=1.8,
label="Historical"
)
# Actual Chronos median forecast
ax.plot(
chronos_evaluation["timestamp"],
chronos_evaluation["0.5"],
color=red,
linewidth=2.2,
label="Chronos-2"
)
# Actual 80% prediction interval
ax.fill_between(
chronos_evaluation["timestamp"],
chronos_evaluation["0.1"],
chronos_evaluation["0.9"],
color=red,
alpha=0.12,
label="80% prediction interval"
)
# Actual observed complaint volumes
ax.plot(
test_series.index,
test_series.values,
color="#222222",
linewidth=1.5,
linestyle="--",
label="Actual"
)
# Forecast starting point
ax.axvline(
TEST_START,
color=grey,
linestyle=":",
linewidth=1
)
ax.set_ylabel("Daily complaints")
ax.grid(axis="y", alpha=0.2)
for spine in ax.spines.values():
spine.set_visible(False)
ax.legend(
loc="upper center",
bbox_to_anchor=(0.5, -0.15),
ncol=2,
frameon=False,
fontsize=9
)
ax.tick_params(axis="both", labelsize=9, length=0)
fig.autofmt_xdate(rotation=0)
plt.tight_layout()
plt.savefig(
"chronos-forecast.png",
dpi=200,
bbox_inches="tight",
facecolor=background
)
plt.show()
from google.colab import files
files.download("chronos-forecast.png")