In this lecture, we will look at different Bhutto's relation techniques that are available for war
time series data.
First, we will start with floating line chad for our data cities.
Then we will look at how to zoom in at any particular window of time.
Then we will look at how to a trend line for a scatter plot of our data cities.
And then we will see how to use release just Air-Crane off of it daytime better cities by removing seasonality.
And at last, we will look at lotting like plots.
Plotting autocorrelation plots, four legged data.
So let's first start with plotting line, Chuck.
We will import my plot.
We will be using same data that we were using earlier.
And creating another data frame that is due to the relation underscore D.F. on let's look at first and
values of this dataset.
So, as you know, the first column is off dates and the second column is off.
No.
But notice here that indexes are ranging from zero one to three and so on.
So to plot a line, Chuck, you just have to mention the values that you want on your y axis.
So here we want Berts.
So we are just calling database underscore D.F..
Then we are selecting work column.
And then we are using dot plot method.
So if you just write dot plot matter.
It will plot that particular value as a line plot.
So if you run this,
this is the plot we are getting on the Y axis.
We have the birds value.
You can see.
You can see that trend then variation in number of birds using this plot.
And on the x axis, you can see we do not have the date, but we have the index value.
So this first value is the value of bird that is present at zero to index.
Which is 35.
So this plot is starting from 35 and so on.
So on the x axis, we have indexes value, but it will be better to have added value instead of this
index value since index value does not make any sense.
So to get the data value, we will first change our index value to over time values and then we will
plot the same plot.
So here I am changing the indexes of my database D.F. to database date column.
So let's run this.
I'm calling database DOT Index equal to database underscore D.F..
Then we are selecting that data column.
This command will change the value of indexes from zero and so on to this data values.
NetSuite on this
to again look at 30 duffing.
I will rerun this.
Come on.
Notice here we have indexes from zero.
If I run this again now, we have built in place of index.
So my new index are in the form of data values and they are not in the form of zero.
One, two, one.
And the other numerical value.
So if I again plot the same plot using database and as for the book and then calling the method dot
plot,
you can see.
Now I have bid values instead of this index value on my x axis.
So that so you plot a simple date time series and do a line plot.
Now let's look at how to zoom in at any particular interval of time.
It is very difficult for me to understand the pattern between first gen two today.
First Gen.
Since the values are clammed up.
So what I can do is I can just plot values between four subject to today.
First off.
Gen.
And this will help me in focusing at a particular time interval instead of looking at the overall time
frame.
So suppose I want to get the data.
From dates with Queen Foxtrot June to 10th of June, so I can just cleared another date frame by selecting
a segment of my original date.
So I am creating database and this could be a two.
And then I am selecting values where date lies between first of June 1959 to of 10, 1959.
We have already seen this how to select a particular enteral earlier in data preprocessing.
So let's find this and let's look at word database underscore B to do different that we have to do just.
You can see we have values from second of Jan since we selected greater than sine, not greater than
equal to St..
So we have values from second of 10 to 10th of June.
Now, to load this values, I can just call dot plot method.
You can see this is the line.
Lord, I'm getting just look at the difference here.
All these values are between these two points.
So it's really difficult for me to get any insight from this line to.
Whereas if I zoom in at any particular interval, I can look at and make some insights from this lecture.
The next thing we discuss in our theory lecture is trend line
here for line.
We are going to use Seabourne Library since it is very easy, from Seabourne Library to Blätter strangling.
You can do it with Matt Plourde as well, but it will be a lengthy process and it is better to use Seabourne
since it is very easy to plot Trainline using Seabourne.
So let's import Seabourne now in Seabourne.
We have a special plot known as Rect Plot, which will automatically Blätter tramline for you.
So here we will be calling Rect Plot.
And here we need to give our X and Y values.
So four X values.
I'm giving my index values and for Y value I'm giving the best values of forward.
Be up to date frame.
So let's look at this.
You can see we have a scatterplot where we have indexers values on the x axis and birth values on the
Y axis.
Also, notice that here we are using index values instead of date values.
Since for a scatterplot, we need numeric data.
So if I just run that plot with our date data, you will get an error.
And we were not able to load this graph just because on the x axis, we have some other data other than
numeric data.
So for scatterplot, you need numeric data.
And that's why we're using it next values.
So, again, you can see that there is a line plotted in between.
This is the regression line or a trend line.
You can see that is an increasing trend.
So using trend line, you can easily identified trend in your data.
So if the slope is positive here, you can see with the increase in values of X, my trend line values
is going up.
So there is a positive slope and you can say that there is a positive trend in your data.
So in any case, if you want to identify whether your data have trend or not, just plot direct plot
and see if the slope of the line is positive.
That is some trend.
And if the line is flat, then there is no trend.
No on.
This is a linear trend line.
You can also plot polynomial or quadratic trendline.
So if you want to have a quadratic trainline, that is the equation of your trend line as Vike to A
X squared plus B, X plus C.
So if you want any such trend line, you can provide another parameter here, which is the order parameter.
By default, the order value is one.
So that's why when we just direct plot with X and Y values, the order was one and the default trend
line was a linear trend line.
But if you provide the order parameter here using the same that plot method, a fibroid already equal
to this will lord the four predict trendline a fibroid already equal to three.
This will Lawder Kubic trend line.
If I provide all that equate to four or five, go to the trend line of order for or order five.
So let's run this again with the quadratic.
Can see we have the same graph, but this trend line here is not a straight line anymore.
So Quadri decline.
And you can also plot Kubic trend line or trend line with order four or five as well.
Now, for the next two days, relation examples, we will be using another dataset that is monthly aircraft,
mind blown dataset.
So this is the dataset which contains data of how many miles that U.S. airline aircrafts are flying.
Let's load this data set in two miles, underscore B if.
Let's take a look at top five values of this data so you can see on the first column V of the month
data where you have data from January 1963.
And the data is at the interval of one month.
So in the next call, I have data Fab 1963 and so on.
And I have another column in which we have values of miles and millions.
So in Jan, 1963, that total miles covered are six thousand eight hundred and twenty seven million
miles.
So I have this data, that first floor flautre, simple line chart.
So this is the data, you can see we have a positive trend or what all the number of miles are increasing.
And we also have a seasonal pattern in our data.
So you can see ups and down at the constant interval of time.
That is the indicator that our data have some seasonality.
In legs lawter crime line on this, Fruita will be using as an as daughter plot here, our Axwell Leuser
miles hundreds could be, if not indexed, taught values and our way values are just the minus number.
So if you plot this, we have scatterplot and see the ups and downs in the scatterplot as well.
And you can also see the trend line.
The slope of this trend line is positive, which indicates that the number of miles are increasing over
time.
Next, we are going to discuss how to remove seasonality from our data.
So in this data, you can see that we have a clear seasonal pattern.
The method we discuss in order to re-elect her was to aggregate values at yearly level to remove the
effect of monthly seasonality.
So what we are trying to do here is we are aggregating our data at the year level.
So I will be taking the average value of miles in 1963.
Then I will take the average value of miles in 1964.
And since a complete year is covering all the seasons.
So finally, if I applaud the aggregate values of this, Miles, on each level, my seasonality will
be gone.
So first, let's create another column in our data.
We are calling that column.
Yes.
And we are storing the easier information of the day.
So in the first column, which is the month column, we have the complete date.
Now we want another column.
Years where we are just picking the e're value.
So for all these values, I won the year column to take 1963 as the year value for all this for.
For all these five reports.
And of the year is 1964.
It should take 1964 as the year.
So we have already discussed how to do this.
And our data prepossessing, which again will be using beauty and beauty sense for dating and dot here.
So if I fed on this.
Let's look at our data frame again.
So now we have another problem here, which is taking the air value of this big family.
Now, I want to aggregate data on this each level.
So for all the records where it is 1963, I want to take the mean of all those values for for all the
records where it is 1964.
I want to take average or mean of my miles for those 12 records.
So how to do that?
We can do that using group by function.
So we are first grouping our data on the basis of years.
Then we are taking miles well use for all those loops and we are taking mean of those values.
So for 1963, I have 12 values on Miles.
Since there are four elements I can take, mean I can take some I can take maximum value.
I can take minimum value.
But here I am taking the mean value of this well values, then I will take another mean value of the
next 12 values of 1964 and so on.
So let's run this.
Those in Texas.
Very simple.
First you have to mention the group by clause.
So here we want to group our data using your data and then we want to mention what values are we going
to get.
So we want to be minus values and we want to take the mean of all the mind values.
Let's run this.
Now you can see that we have our data.
We have the year value and the mean value of that year.
So plotting this data is very easy.
We will again use dot plot metric.
So we have this data.
I can just use dot plot in front of this dataset.
You can also save this data and do another data frame and use that data frame and dot plot method plotted.
But it's the same.
I'm just using this.
You can see that this is our data from the same series that we have plotted earlier.
So earlier it was looking like this.
This ups and downs are due to seasonal pattern in our data.
Now, if I am aggregating all the values at the year level, I am reviewing seasonality.
And now I'm just getting these analyzed chart for our data.
The next Rusal election, my third is beating the leg block.
So as discussed in the two re-elected leg, values are very important in forecasting.
So mostly in forecasting problem.
The value we want to forecast is highly dependent on the previous values.
So suppose if you have a temperature data and you want to predict the temperature for tomorrow, it
is more likely to be plus or minus three or four degrees as compared to two days temperature.
So we have also discussed lagging value and our data people siccing.
So let's first create a lag variable.
We are calling a lag one.
And here we are creating a lag variable for just one time period.
So I can write minus underscore B minus M-m that this is the value we want to create like variables
for.
Then I can write, then I can call Lordship Shift method with argument as one.
So this will shift all the values my one time.
Let's run this.
Let's look at her.
So you can see.
Now I have another call them, which is leg one column.
And the values here are at the leg of one time period from minus M column.
So now I have these two columns for my lagged variables and for minus Amum values.
I can just create a scatterplot using these two values.
My ex here is the leg value.
And my way is the original value.
So you can see this is the scatter plot of the leg, the value and the original value.
And one thing you can notice is that there is some positive correlation between the two values.
So you can see that if my leg value is high.
My minus will lose also high.
And if my leg value is low, Miles.
Value is also low.
This means that there is a positive correlation between the leg, the values of minus.
Later on in our course, we will see why this leg values are important and why it is important to find
out any correlation between the leg variables.
Now, in this method of creating like Block B first created another column and then we plotted scatterplot,
that is another simple method of plotting a Lego block.
We can just import Lego block from Ponder's DOT plotting and we can directly call this method to load
the Lego block by default.
This will plot for Legoff one.
So here I am not giving any value to shift the volume.
This will automatically, by default, flawed.
This variable with its leg off one time embitter.
Let's run this.
You can see that both the charts are giving me the same result.
This are just two different approaches of plotting the same plot.
Now, the last part of data visualization is autocorrelation plots.
So if you noticed, I was talking about correlation between the leg values.
For our forecasting model.
It is very important to identify correlation between the lag variables.
But SAPOL, if I want to see the correlation between this value and with the lag too well.
So I want to see the coordination between my values and the values that the two time period ago.
Using this method, I have to create another variable lag too.
And then again, Lortel scatterplot on that data.
So it's a very lengthy process.
And that's why there is another alternative to directly get correlation values with all the possible
leg values.
We call that block autocorrelation plot, and this is available and fund us also.
So we will be importing auto correlation plot from point does not plotting.
And then we just straight autocorrelation plot and will mention the values for which even though autocorrelation
plot.
So if you wanted for Miles M-m.
Let's look at the chart here.
You can see we have cool relation values on the Y axis.
And then we have the leg values on my x axis.
So the first value here is the correlation value between variable miles M-m and X leg one.
The second value is the correlation value between my DMM.
And it's like two.
Similarly, we have this square relation data with up to nine BD legs values.
So now you don't have to create another lagged variables and create a scatterplot for individual lagged
variables.
You can just look at the single graph and this graph will tell you what is the correlation between the
value and its lack of value at an interval.
So now how to read this graph?
The important thing here is from all that, we have a very high correlation for the initial three to
four values.
So we are getting a correlation value of more than point five.
That mean for the first three predict, the leg values are highly correlated with the minus.
I mean value.
And then we have a dip at every sixth month.
So this is this probably is the sixth or seventh value.
This probably is the 18 or 19 value.
Similarly, this is around 30.
So at the multiple of every six month, we are getting a dip in our correlation values.
This is because of the seasonality.
So if you compare the ice cream sales over the.
So six month correlation means when there is a summer, you are looking at the value of winter sales
because of the six month delay.
And when there is a winter, you are looking at the lagged value of six months.
That is the summer values.
That's why you will find lows and highs in case of seasonal data.
So autocorrelation thoughts are very important.
We'll look at.
It's important in the later part of this course and it is very easy to plot any autocorrelation plot.
So that's all for data visualization.
We look at that flirting, simple line check using our data frame.
Then we'll look at how to zoom in at any particular time interval and plot a line chart for that time
interval.
Then we'll look at that whole two part trend line.
Then we look at how to move seasonality from our data.
By aggregating data on an eleven and after that, look at how to plot scatter plots with the lagged
values and how to plot or target a nation plot to get correlation values for all the possible land values.
That's all for this lecture.
Thank you.