Prophet of The Future. 
Prophet is a procedure for forecasting time series data
based on an additive model where non-linear trends are fit with yearly, weekly,
and daily seasonality, plus holiday effects. It works best with time series
that have strong seasonal effects and several seasons of historical data.
Prophet is robust to missing data and shifts in the trend, and typically
handles outliers well.
- Accurate and fast.
- Fully automatic.
- Tunable forecasts.
- Available in R or Python.
Let’s explore this with an example. Here we are using Air Passenger dataset and our jupyter workbook. (you can get the link to this dataset at the end)
df = pd.read_csv('..//AirPassengers.csv')
Installing Prophet using pip and import prophet
df.rename(columns={'Month':'ds','#Passengers':'y'},inplace=True)
df.rename(columns={'Month':'ds','#Passengers':'y'},inplace=True)
df.head()

Now we fit the model and
instantiating new prophet object. Then you call it fit method and pass in the
dataframe.
Predictions are then made
on a dataframe with a column ds containing the dates for which a prediction is
to be made. You can get a suitable dataframe that extends into the future a
specified number of months using the helper method
Prophet.make_future_dataframe. By default it will also include the dates from
the history, so we will see the model fit as well.

The model will assign predicted value by
the name of yhat. If you pass in historical dates, it will provide an in-sample
fit. The forecast object here is a new dataframe that includes a column yhat
with the forecast, as well as columns for components and uncertainty intervals.
Now plot
the forecast by calling the Prophet.plot method and passing in your forecast
dataframe.
fig1 = model.plot(forecast)

fig2 = model.plot_components(forecast)

So, We can see the forecast trend and
seasonality with the help of Facebook Prophet library. That's a wrap for Prophet Library in Jupyter. For more details you can
visit https://facebook.github.io/prophet/docs/quick_start.html#python-api.
You can download the dataset from kaggle https://www.kaggle.com/rakannimer/air-passengers
Hope you find it useful and informative.
Follow my blog for more Data related quests.
-DataDevil
Honey Saini
That's some good content on Data Science... keep goin :)
ReplyDelete