#
src/data_loading.py
import pandas as pd
# Load the dataset
# Make sure to replace 'your_todoist_export.csv' with the actual file name
try:
df = pd.read_csv('your_todoist_export.csv')
print("File loaded successfully!")
print(df.head())
except FileNotFoundError:
print("Error: Make sure the CSV file is in the same directory or provide the full path.")
# Expected output: A preview of the first few rows of your Todoist data.
# src/data_processing.py
import pandas as pd
# Assuming 'df' is the DataFrame from the previous step
# Filter for completed tasks if your export includes incomplete ones
# The column name for the completion date might vary, inspect your CSV file.
# Common names are 'Date Completed', 'Completed Date', etc.
df_completed = df[df['Date Completed'].notna()].copy()
# Convert the date column to datetime objects
df_completed['ds'] = pd.to_datetime(df_completed['Date Completed'])
# Group by date and count the number of tasks
daily_tasks = df_completed.groupby(df_completed['ds'].dt.date).size().reset_index(name='y')
# Rename the date column to 'ds' for Prophet
daily_tasks.rename(columns={'index': 'ds'}, inplace=True)
# Convert the 'ds' column back to datetime objects after grouping
daily_tasks['ds'] = pd.to_datetime(daily_tasks['ds'])
print(daily_tasks.head())
# Expected output: A DataFrame with two columns: 'ds' (the date) and 'y' (the number of tasks completed on that day).
# src/model_training.py
from prophet import Prophet
# Initialize the Prophet model
model = Prophet()
# Fit the model to our data
model.fit(daily_tasks)
# Create a DataFrame for future predictions (e.g., for the next 90 days)
future = model.make_future_dataframe(periods=90)
print(future.tail())
# Expected output: A DataFrame with a 'ds' column extending 90 days into the future.
# src/forecasting.py
# Make predictions
forecast = model.predict(future)
# Print the last few forecasted values
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail())
# Plot the forecast
fig1 = model.plot(forecast)
# Plot the forecast components (trend, weekly, and yearly seasonality)
fig2 = model.plot_components(forecast)
# Expected output: A table with forecasted values and two plots.
# The first plot shows the historical data, the forecast, and the uncertainty interval.
# The second plot breaks down the forecast into its trend and seasonal components.