Зміст курсу
Time Series Analysis
Time Series Analysis
Simple Moving Average
Mathematically, the simple moving average model is represented as follows:
In this equation, the prediction SMA consists of variables, where k
is the window size (how many past values we will take to calculate the next value), and p
is the value taken.
How does this model work? In fact, the simple moving average at each prediction moment calculates the average of several past values - the resulting number is the next prediction. You can imagine a graph on the path of which a window of size n
moves (you can take 2 values, you can take 3, etc.). The smaller the window, the smoother the predictions. Let's demonstrate it below:
In the first image, the window size for which the average value is calculated is 8, while on the second graph, n
= 3. The smaller the window, the fewer peaks it can capture.
Python allows you to implement this model like this:
rolling()
- a function used to calculate the moving average.
The simple moving average is one of the simplest models, so it is enough to use the pandas
library to implement it.
Завдання
Make predictions for dataset pr_air_quality.csv
with window size 5.
- Convert the
"date.utc"
column todatetime
type. - Calculate moving averages using moving windows with the size of
5
. - Compare the results on a plot: visualize the first 50 values of the
"value"
column of thedf
within the first call of the.plot()
function and the first 50 values of thepred
within the second call. - Display the legend and the plot.
Дякуємо за ваш відгук!
Simple Moving Average
Mathematically, the simple moving average model is represented as follows:
In this equation, the prediction SMA consists of variables, where k
is the window size (how many past values we will take to calculate the next value), and p
is the value taken.
How does this model work? In fact, the simple moving average at each prediction moment calculates the average of several past values - the resulting number is the next prediction. You can imagine a graph on the path of which a window of size n
moves (you can take 2 values, you can take 3, etc.). The smaller the window, the smoother the predictions. Let's demonstrate it below:
In the first image, the window size for which the average value is calculated is 8, while on the second graph, n
= 3. The smaller the window, the fewer peaks it can capture.
Python allows you to implement this model like this:
rolling()
- a function used to calculate the moving average.
The simple moving average is one of the simplest models, so it is enough to use the pandas
library to implement it.
Завдання
Make predictions for dataset pr_air_quality.csv
with window size 5.
- Convert the
"date.utc"
column todatetime
type. - Calculate moving averages using moving windows with the size of
5
. - Compare the results on a plot: visualize the first 50 values of the
"value"
column of thedf
within the first call of the.plot()
function and the first 50 values of thepred
within the second call. - Display the legend and the plot.
Дякуємо за ваш відгук!
Simple Moving Average
Mathematically, the simple moving average model is represented as follows:
In this equation, the prediction SMA consists of variables, where k
is the window size (how many past values we will take to calculate the next value), and p
is the value taken.
How does this model work? In fact, the simple moving average at each prediction moment calculates the average of several past values - the resulting number is the next prediction. You can imagine a graph on the path of which a window of size n
moves (you can take 2 values, you can take 3, etc.). The smaller the window, the smoother the predictions. Let's demonstrate it below:
In the first image, the window size for which the average value is calculated is 8, while on the second graph, n
= 3. The smaller the window, the fewer peaks it can capture.
Python allows you to implement this model like this:
rolling()
- a function used to calculate the moving average.
The simple moving average is one of the simplest models, so it is enough to use the pandas
library to implement it.
Завдання
Make predictions for dataset pr_air_quality.csv
with window size 5.
- Convert the
"date.utc"
column todatetime
type. - Calculate moving averages using moving windows with the size of
5
. - Compare the results on a plot: visualize the first 50 values of the
"value"
column of thedf
within the first call of the.plot()
function and the first 50 values of thepred
within the second call. - Display the legend and the plot.
Дякуємо за ваш відгук!
Mathematically, the simple moving average model is represented as follows:
In this equation, the prediction SMA consists of variables, where k
is the window size (how many past values we will take to calculate the next value), and p
is the value taken.
How does this model work? In fact, the simple moving average at each prediction moment calculates the average of several past values - the resulting number is the next prediction. You can imagine a graph on the path of which a window of size n
moves (you can take 2 values, you can take 3, etc.). The smaller the window, the smoother the predictions. Let's demonstrate it below:
In the first image, the window size for which the average value is calculated is 8, while on the second graph, n
= 3. The smaller the window, the fewer peaks it can capture.
Python allows you to implement this model like this:
rolling()
- a function used to calculate the moving average.
The simple moving average is one of the simplest models, so it is enough to use the pandas
library to implement it.
Завдання
Make predictions for dataset pr_air_quality.csv
with window size 5.
- Convert the
"date.utc"
column todatetime
type. - Calculate moving averages using moving windows with the size of
5
. - Compare the results on a plot: visualize the first 50 values of the
"value"
column of thedf
within the first call of the.plot()
function and the first 50 values of thepred
within the second call. - Display the legend and the plot.