{"id":135642,"date":"2026-08-26T13:07:23","date_gmt":"2026-08-26T07:37:23","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=135642"},"modified":"2026-08-26T13:07:25","modified_gmt":"2026-08-26T07:37:25","slug":"facebook-prophet-tutorial","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/facebook-prophet-tutorial\/","title":{"rendered":"Facebook Prophet Tutorial for Time Series Forecasting"},"content":{"rendered":"\n<p>Forecasting future values from historical data is an important task in data science. Businesses use time series forecasting to predict sales, demand, website traffic, revenue, and other metrics. <strong>Facebook Prophet<\/strong> is a forecasting library designed to make this process easier, especially when working with time series that contain trends, seasonality, and holidays.<\/p>\n\n\n\n<p>Prophet was developed at Facebook, now Meta, to make forecasting accessible without requiring users to build complex statistical models from scratch. It provides a practical framework for creating forecasts while allowing developers to customize important components of the model.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR<\/strong><\/h2>\n\n\n\n<ul>\n<li>Facebook Prophet is a time series forecasting framework developed at Facebook.<\/li>\n\n\n\n<li>It works particularly well with data containing trends and seasonal patterns.<\/li>\n\n\n\n<li>Prophet expects a dataframe with ds and y columns.<\/li>\n\n\n\n<li>You can include holidays and additional regressors in forecasts.<\/li>\n\n\n\n<li>Forecast quality should be evaluated using historical holdout data rather than visual inspection alone.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Is Facebook Prophet?<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"628\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-1200x628.webp\" alt=\"What Is Facebook Prophet?\" class=\"wp-image-135644\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-1200x628.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-300x157.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-768x402.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-1536x803.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet-150x78.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/What-Is-Facebook-Prophet.webp 1734w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p><a href=\"https:\/\/facebook.github.io\/prophet\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Facebook Prophet<\/a> is an open-source forecasting framework designed for time series data.<\/p>\n\n\n\n<p>It models a time series as a combination of components such as:<\/p>\n\n\n\n<ul>\n<li>Trend<\/li>\n\n\n\n<li>Seasonality<\/li>\n\n\n\n<li>Holiday effects<\/li>\n\n\n\n<li>Additional regressors<\/li>\n\n\n\n<li>Random error<\/li>\n<\/ul>\n\n\n\n<p>A simplified representation is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>y(t) = g(t) + s(t) + h(t) + \u03b5(t)<\/strong><\/code><\/pre>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul>\n<li><strong>g(t)<\/strong> represents the trend.<\/li>\n\n\n\n<li><strong>s(t)<\/strong> represents seasonality.<\/li>\n\n\n\n<li><strong>h(t)<\/strong> represents holiday or event effects.<\/li>\n\n\n\n<li><strong>\u03b5(t)<\/strong> represents unexplained variation.<\/li>\n<\/ul>\n\n\n\n<p><strong>Read More: <\/strong><a href=\"https:\/\/www.guvi.in\/blog\/time-series-forecasting-with-prophet\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Facebook Prophet Tutorial for Time Series Forecasting<\/strong><\/a><\/p>\n\n\n\n<p>Master time series forecasting and machine learning with <strong>HCL GUVI&#8217;s <\/strong><a href=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=facebook-prophet-tutorial\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/mlp\/artificial-intelligence-and-machine-learning?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=facebook-prophet-tutorial\" rel=\"noreferrer noopener\"><strong>Artificial Intelligence &amp; Machine Learning Course<\/strong><\/a>. Learn AI, data analysis, and predictive modeling through hands-on projects.\u00a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Use Facebook Prophet?<\/strong><\/h2>\n\n\n\n<p>Traditional forecasting methods can require substantial statistical knowledge and careful model configuration. Prophet provides a simpler interface while still offering useful forecasting capabilities.<\/p>\n\n\n\n<p>It is particularly useful when your data contains:<\/p>\n\n\n\n<ul>\n<li>Long-term trends<\/li>\n\n\n\n<li>Weekly seasonality<\/li>\n\n\n\n<li>Yearly seasonality<\/li>\n\n\n\n<li>Holiday effects<\/li>\n\n\n\n<li>Missing observations<\/li>\n\n\n\n<li>Outliers<\/li>\n\n\n\n<li>Multiple seasonal patterns<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong>Pro Tip:<\/strong> Start with Prophet&#8217;s default configuration before adding advanced parameters. Establishing a baseline makes it easier to understand whether later changes actually improve the forecast.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Installing Prophet<\/strong><\/h2>\n\n\n\n<p>You can install the current Prophet <a href=\"https:\/\/www.guvi.in\/blog\/what-are-python-packages\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python package<\/a> using pip:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install prophet<\/code><\/pre>\n\n\n\n<p>Then import it into your Python program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from prophet import Prophet<\/code><\/pre>\n\n\n\n<p>The package was previously known as fbprophet, so older tutorials may use a different import name.<\/p>\n\n\n\n<div style=\"background-color: #099f4e; border: 3px solid #110053; border-radius: 12px; padding: 18px 22px; color: #FFFFFF; font-size: 18px; font-family: Montserrat, Helvetica, sans-serif; line-height: 1.6; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); max-width: 750px;\"> \n  <strong style=\"font-size: 22px; color: #FFFFFF;\">\ud83d\udca1 Did You Know?<\/strong> \n  <br \/><br \/> \n   Prophet was designed with practical business forecasting in mind, particularly for time series that contain strong seasonal patterns and irregular events.\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Preparing Data for Prophet<\/strong><\/h2>\n\n\n\n<p>Prophet expects two important columns:<\/p>\n\n\n\n<ul>\n<li><strong>ds<\/strong> \u2014 the date or timestamp.<\/li>\n\n\n\n<li><strong>y<\/strong> \u2014 the numerical value you want to forecast.<\/li>\n<\/ul>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\ndf = pd.DataFrame({\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"ds\": pd.date_range(\"2025-01-01\", periods=100),\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"y\": &#91;120, 125, 128, 130, 135, 140, 142, 145, 150, 153] * 10\n\n})<\/code><\/pre>\n\n\n\n<p>In a real project, your y column would contain actual historical measurements.<\/p>\n\n\n\n<p>Make sure your dates are correctly formatted and ordered before training the model.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong>Best Practice:<\/strong> Clean duplicate timestamps, verify missing values, and confirm that the target column contains numeric values before fitting Prophet.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Building Your First Forecast<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"625\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-1200x625.webp\" alt=\"Building Your First Forecast\" class=\"wp-image-135645\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-1200x625.webp 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-300x156.webp 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-768x400.webp 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-1536x800.webp 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast-150x78.webp 150w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Building-Your-First-Forecast.webp 1738w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p>Once your data is prepared, creating a basic forecast requires only a few steps.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from prophet import Prophet\n\nmodel = Prophet()\n\nmodel.fit(df)\n\nfuture = model.make_future_dataframe(periods=30)\n\nforecast = model.predict(future)<\/code><\/pre>\n\n\n\n<p>The forecast dataframe contains predicted values along with uncertainty information and several model components.<\/p>\n\n\n\n<p>You can inspect the predictions with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>forecast&#91;&#91;\"ds\", \"yhat\", \"yhat_lower\", \"yhat_upper\"]].tail()<\/code><\/pre>\n\n\n\n<p>Here:<\/p>\n\n\n\n<ul>\n<li><strong>yhat<\/strong> is the predicted value.<\/li>\n\n\n\n<li><strong>yhat_lower<\/strong> represents the lower uncertainty boundary.<\/li>\n\n\n\n<li><strong>yhat_upper<\/strong> represents the upper uncertainty boundary.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Understanding Trend and Seasonality<\/strong><\/h2>\n\n\n\n<p>One of Prophet&#8217;s strengths is its ability to model multiple patterns within a time series.<\/p>\n\n\n\n<p>For example, an online store might experience:<\/p>\n\n\n\n<ul>\n<li>Long-term growth in sales.<\/li>\n\n\n\n<li>Higher demand every weekend.<\/li>\n\n\n\n<li>Increased purchases during certain months.<\/li>\n\n\n\n<li>Temporary spikes around holidays.<\/li>\n<\/ul>\n\n\n\n<p>Prophet attempts to model these patterns separately so you can understand how each contributes to the overall forecast.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Adding Seasonality<\/strong><\/h2>\n\n\n\n<p>Prophet automatically handles common seasonal patterns, but you can also define custom seasonal effects.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>model = Prophet(\n\n&nbsp;&nbsp;&nbsp;&nbsp;yearly_seasonality=True,\n\n&nbsp;&nbsp;&nbsp;&nbsp;weekly_seasonality=True,\n\n&nbsp;&nbsp;&nbsp;&nbsp;daily_seasonality=False\n\n)\n\nYou can also add custom seasonality:\n\nmodel.add_seasonality(\n\n&nbsp;&nbsp;&nbsp;&nbsp;name=\"monthly\",\n\n&nbsp;&nbsp;&nbsp;&nbsp;period=30.5,\n\n&nbsp;&nbsp;&nbsp;&nbsp;fourier_order=5\n\n)<\/code><\/pre>\n\n\n\n<p>This can be useful when your business data follows a recurring pattern that is not adequately represented by standard seasonal components.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Adding Holidays<\/strong><\/h2>\n\n\n\n<p>Events and holidays can cause unusual changes in demand.<\/p>\n\n\n\n<p>Prophet allows you to provide a holiday dataframe and incorporate these effects into the forecast.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>holidays = pd.DataFrame({\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"holiday\": &#91;\"festival\"],\n\n&nbsp;&nbsp;&nbsp;&nbsp;\"ds\": pd.to_datetime(&#91;\"2025-10-20\"]),\n\n})\n\nmodel = Prophet(holidays=holidays)\n\nmodel.fit(df)<\/code><\/pre>\n\n\n\n<p>This allows the model to account for recurring or one-time events that influence the target variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Forecasting with Additional Regressors<\/strong><\/h2>\n\n\n\n<p>Sometimes historical values alone are not enough to explain future behavior.<\/p>\n\n\n\n<p>For example, sales may depend on advertising expenditure, temperature, or another external variable.<\/p>\n\n\n\n<p>Prophet allows additional regressors to be incorporated into the model.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>model = Prophet()\n\nmodel.add_regressor(\"ad_spend\")<\/code><\/pre>\n\n\n\n<p>The corresponding regressor must also be available for the future dates you want to forecast.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong>Warning:<\/strong> Future regressor values must be known or reliably forecasted. Adding an external variable that you cannot estimate for the forecast period can make the forecasting pipeline impractical.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Visualizing Forecasts<\/strong><\/h2>\n\n\n\n<p>Prophet provides built-in visualization functionality.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from prophet.plot import plot_plotly\n\nfig = plot_plotly(model, forecast)\n\nfig.show()<\/code><\/pre>\n\n\n\n<p>The visualization can help you examine:<\/p>\n\n\n\n<ul>\n<li>Historical observations<\/li>\n\n\n\n<li>Forecasted values<\/li>\n\n\n\n<li>Uncertainty intervals<\/li>\n\n\n\n<li>Overall trends<\/li>\n<\/ul>\n\n\n\n<p>You can also inspect individual components to understand how trend and seasonality influence the forecast.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How Do You Evaluate Prophet Forecasts?<\/strong><\/h2>\n\n\n\n<p>A forecast should not be considered accurate simply because the predicted line looks reasonable.<\/p>\n\n\n\n<p>Instead, separate historical data into training and validation periods.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Training data \u2192 Model \u2192 Future predictions \u2192 Compare with actual values<\/strong><\/code><\/pre>\n\n\n\n<p>Common evaluation metrics include:<\/p>\n\n\n\n<ul>\n<li><a href=\"https:\/\/www.guvi.in\/hub\/house-price-prediction-using-machine-learning-xgboost\/understanding-mean-absolute-error-mae-\/\" target=\"_blank\" rel=\"noreferrer noopener\">Mean Absolute Error (MAE)<\/a><\/li>\n\n\n\n<li>Mean Squared Error (MSE)<\/li>\n\n\n\n<li>Root Mean Squared Error (RMSE)<\/li>\n\n\n\n<li>Mean Absolute Percentage Error (MAPE)<\/li>\n<\/ul>\n\n\n\n<p>The appropriate metric depends on the characteristics of your data and business requirements.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong>Best Practice:<\/strong> Use time-based validation rather than randomly shuffling time series observations. Random splitting can leak future information into the training set.<\/p><\/blockquote><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key Takeaways<\/strong><\/h2>\n\n\n\n<ul>\n<li>Facebook Prophet simplifies time series forecasting.<\/li>\n\n\n\n<li>Prophet models trend, seasonality, holidays, and optional regressors.<\/li>\n\n\n\n<li>Data must use ds and y columns.<\/li>\n\n\n\n<li>Custom seasonal patterns can be added when needed.<\/li>\n\n\n\n<li>Future regressors must be available for the forecast period.<\/li>\n\n\n\n<li>Time-based validation is essential for measuring forecast quality.<\/li>\n\n\n\n<li>Prophet works particularly well for many business forecasting scenarios.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Facebook Prophet provides a practical way to build time series forecasts without requiring extensive manual statistical modeling. Its ability to handle trends, seasonality, holidays, and additional regressors makes it useful for many business and operational forecasting tasks.<\/p>\n\n\n\n<p>However, Prophet should be treated as a forecasting tool rather than a universal solution. Preparing clean data, selecting appropriate seasonal components, validating predictions against historical observations, and comparing alternative models are all essential for producing reliable forecasts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1787725573403\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is Facebook Prophet used for?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Facebook Prophet is used for time series forecasting, including applications such as sales, demand, traffic, revenue, and other business metrics.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787725579105\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What format does Prophet require?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Prophet expects a dataframe containing a ds column for dates or timestamps and a y column containing the values to forecast.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787725590180\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can Facebook Prophet handle seasonality?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. Prophet can model yearly, weekly, and custom seasonal patterns.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787725598874\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can Prophet include holidays?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. You can provide holiday information so the model can account for changes associated with specific events or dates.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1787725642230\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>How should a Prophet model be evaluated?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Use time-based validation and forecasting metrics such as MAE, RMSE, or MAPE to compare predictions with actual future observations.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<ol start=\"5\">\n<li><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Forecasting future values from historical data is an important task in data science. Businesses use time series forecasting to predict sales, demand, website traffic, revenue, and other metrics. Facebook Prophet is a forecasting library designed to make this process easier, especially when working with time series that contain trends, seasonality, and holidays. Prophet was developed [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":135648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[933],"tags":[],"views":"23","authorinfo":{"name":"HCL GUVI","url":"https:\/\/www.guvi.in\/blog\/author\/guvipr\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/08\/Facebook-Prophet-Tutorial-for-Time-Series-Forecasting-300x116.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135642"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=135642"}],"version-history":[{"count":3,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135642\/revisions"}],"predecessor-version":[{"id":135709,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/135642\/revisions\/135709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/135648"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=135642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=135642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=135642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}