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(26765)
The Ultimate Python Exercise Book: 700 Practical Exercises for Beginners with Quiz Questions by Copy(20356)
De Souza H. Master the Age of Artificial Intelligences. The Basic Guide...2024 by Unknown(20177)
D:\Jan\FTP\HOL\Work\Alien Breed - Tower Assault CD32 Alien Breed II - The Horror Continues Manual 1.jpg by PDFCreator(20164)
The Fifty Shades Trilogy & Grey by E L James(19231)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(19218)
Shot Through the Heart by Mercy Celeste(19078)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(17258)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(17197)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(17039)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16960)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 01 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(16589)
The Subtle Art of Not Giving a F*ck by Mark Manson(14550)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(14281)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(13930)
Scorched Earth by Nick Kyme(12917)
Drei Generationen auf dem Jakobsweg by Stein Pia(11115)
Suna by Ziefle Pia(11039)
Scythe by Neal Shusterman(10505)