Instagram Reach Forecasting

Beytullah Soylev
3 min readJul 31, 2023

--

Instagram reach forecasting is the process of predicting how many people will see an Instagram post, story, or other content. This can be done using a variety of methods, including machine learning, statistical analysis, and expert opinion. The accuracy of reach forecasting depends on a number of factors, but even a simple model can provide valuable insights into how to improve Instagram reach.

Some of the benefits of Instagram reach forecasting:

  • It can help businesses and individuals to optimize their social media strategy.
  • It can help to identify the most effective times to post content.
  • It can help to determine which hashtags are most effective at reaching the target audience.
  • It can help to track the performance of social media campaigns.

Instagram Reach Forecasting with Python

Start this task by importing the necessary Python libraries

import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
import plotly.io as pio
pio.templates.default = "plotly_white"

data = pd.read_csv("Instagram-Reach.csv", encoding = 'latin-1')
print(data.head())
data["Date"] = pd.to_datetime(data["Date"])
print(data.head())
#Analyze the trend of Instagram reach over time using a line chart
fig = go.Figure()
fig.add_trace(go.Scatter(x=data["Date"],
y=data["Instagram reach"],
mode="lines", name="Instagram reach"))
fig.update_layout(title="Instagram Reach Trend", xaxis_title="Date",
yaxis_title="Instagram Reach")
fig.show()
Instagram Reach Trend
#Analyze Instagram reach for each day using a bar chart:
fig = go.Figure()
fig.add_trace(go.Bar(x=data["Date"],
y=data["Instagram reach"],
name="Instagram reach"))
fig.update_layout(title="Instagram Reach by Day",
xaxis_title="Date",
yaxis_title="Instagram Reach")
fig.show()
Instagram Reach by Day
import numpy as np

day_stats = data.groupby("Day")["Instagram reach"].agg(["mean", "median", "std"]).reset_index()
print(day_stats)
#Create a bar chart to visualize the reach for each day of the week
fig= go.Figure()
fig.add_trace(go.Bar(x=day_stats["Day"],
y=day_stats["mean"],
name="Mean"))
fig.add_trace(go.Bar(x=day_stats["Day"],
y=day_stats["median"],
name="Median"))
fig.add_trace(go.Bar(x=day_stats['Day'],
y=day_stats['std'],
name='Standard Deviation'))
fig.update_layout(title='Instagram Reach by Day of the Week',
xaxis_title='Day',
yaxis_title='Instagram Reach')
fig.show()
Instagram Reach by Day the Week
from statsmodels.graphics.tsaplots import plot_pacf
plot_pacf(data["Instagram reach"], lags = 100)
p, d, q = 8, 1, 2

import statsmodels.api as sm
import warnings
model=sm.tsa.statespace.SARIMAX(data["Instagram reach"],
order=(p, d, q),
seasonal_order=(p, d, q, 12))
model=model.fit()
print(model.summary())

#Make predictions using the model and have a look at the forecasted reach
predictions = model.predict(len(data), len(data)+100)

trace_train = go.Scatter(x=data.index,
y=data["Instagram reach"],
mode="lines",
name="Training Data")
trace_pred = go.Scatter(x=predictions.index,
y=predictions,
mode="lines",
name="Predictions")

layout = go.Layout(title="Instagram Reach Time Series and Predictions",
xaxis_title="Date",
yaxis_title="Instagram Reach")

fig = go.Figure(data=[trace_train, trace_pred], layout=layout)
fig.show()
Instagram Reach Time Series and Predictions

For Project Codes

“The biggest risk is not taking any risk. In a world that is changing quickly, the only strategy that is guaranteed to fail is not taking risks.”

— Mark Zuckerberg, CEO of Meta Platforms, Inc.

--

--

No responses yet