Ultimate Enterprise Data Analysis and Forecasting Using Python: Leverage Cloud Platforms with Azure Time Series Insights and AWS Forecast Components for Deep Learning Modeling Usin by Pandian Shanthababu;
Author:Pandian, Shanthababu; [Pandian, Shanthababu]
Language: eng
Format: epub
Publisher: Orange Education PVT Ltd
Published: 2023-03-15T00:00:00+00:00
β is the smoothing factor [ value range from 0 to 1].
xt is the observation from the dataset during the time(t) period.
In the following calculation, the smoothing factor for the current and previous data points is 0.1 and 0.9:
Figure 6.41: EMA model output â predicted price along with formula
Figure 6.42 shows the actual vs forecast line plot using the EMA model.
Figure 6.42: EMA model line plot for diesel price dataset
EMA implementation using Python
Letâs implement the EMA model using Python code with a diesel data set and plot the line chart to understand the movements.
#load the required libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import pyplot
#load dataset for EMA model analysis
df_diesel_price_EMA = pd.read_csv(âdiesel_price EMA.csvâ, header=0, index_col=0)
df_diesel_price_EMA.index.name = âSale_Dateâ
df_diesel_price_EMA[âaverage_priceâ] = df_diesel_price_EMA.mean(axis=1)
df_diesel_price_EMA[âEMAâ] = df_diesel_price_EMA.average_price.expanding().mean()
# smoothing factor - 0.1,0.25,.5
df_diesel_price_EMA[âEMA_0.1â] = df_diesel_price_EMA.average_price.ewm(alpha=0.1, adjust=False).mean()
df_diesel_price_EMA[âEMA_0.25â] = df_diesel_price_EMA.average_price.ewm(alpha=0.25, adjust=False).mean()
df_diesel_price_EMA[âEMA_0.5â] = df_diesel_price_EMA.average_price.ewm(alpha=0.5, adjust=False).mean()
colors = [âorangeâ,âblueâ, âgreenâ, âredâ]
df_diesel_price_EMA[[âaverage_priceâ, âEMA_0.1â,âEMA_0.25â,âEMA_0.5â]].plot(color=colors, linewidth=3, figsize=(12,6))
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.legend(labels =[âAverage priceâ, âEMA_0.1â,âEMA_0.25â,âEMA_0.5â], fontsize=14)
plt.title(âDieselâ, fontsize=20)
plt.xlabel(âSala_Dateâ, fontsize=16)
plt.ylabel(âDiesel Priceâ, fontsize=16)
print(â ############################################################â)
print(â Exponential Moving Average Plot for Diesel â)
print(â ############################################################â)
############################################################
Exponential Moving Average Plot for Diesel
############################################################
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26520)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19006)
The Fifty Shades Trilogy & Grey by E L James(18958)
Shot Through the Heart by Mercy Celeste(18878)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(16981)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(16873)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(16803)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16697)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16321)
The Subtle Art of Not Giving a F*ck by Mark Manson(14259)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14071)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13419)
Scorched Earth by Nick Kyme(12713)
Drei Generationen auf dem Jakobsweg by Stein Pia(10921)
Suna by Ziefle Pia(10845)
Scythe by Neal Shusterman(10269)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9474)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9315)
This is Going to Hurt by Adam Kay(9097)
