pythonintermediate
Prophet Time Series Forecasting
Forecast time-series data with Facebook Prophet handling holidays, trends, and seasonality.
pythonPress ⌘/Ctrl + Shift + C to copy
from prophet import Prophet
import pandas as pd
import numpy as np
# Generate sample time series
dates = pd.date_range('2023-01-01', periods=365, freq='D')
trend = np.linspace(100, 150, 365)
seasonality = 10 * np.sin(2 * np.pi * np.arange(365) / 365)
noise = np.random.normal(0, 3, 365)
df = pd.DataFrame({'ds': dates, 'y': trend + seasonality + noise})
model = Prophet(yearly_seasonality=True, weekly_seasonality=True, daily_seasonality=False, seasonality_mode='multiplicative')
model.fit(df)
future = model.make_future_dataframe(periods=90)
forecast = model.predict(future)
future_only = forecast[forecast['ds'] > df['ds'].max()]
print(forecast[['ds','yhat','yhat_lower','yhat_upper']].tail(5).to_string(index=False))Use Cases
- sales forecasting
- traffic prediction
- demand planning
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonadvanced
NeuralProphet Deep Time Series Forecast
Forecast complex time series with NeuralProphet combining neural networks and classical decomposition.
Best for: neural forecasting
#neuralprophet#forecasting
pythonbeginner
LangChain Prompt Chain (Python)
Build a simple LLMChain with a prompt template and ChatOpenAI in LangChain.
Best for: prompt chaining
#langchain#openai
pythonintermediate
Async OpenAI Client in Python
Use the AsyncOpenAI client with asyncio to run concurrent chat completions without blocking.
Best for: concurrent LLM calls
#openai#async
pythonintermediate
LangChain Tool-Using Agent
Build a LangChain agent with custom tools for web search, calculator, and Python REPL.
Best for: AI agents
#langchain#agent