-
Geographical Analysis 6
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
Lecture1.6
-
-
Cap Table 3
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
-
Simulation 6
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
Lecture3.6
-
-
Search Index 8
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
Lecture4.5
-
Lecture4.6
-
Lecture4.7
-
Lecture4.8
-
-
Fund Distributions 5
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Lecture5.4
-
Lecture5.5
-
Insights from Decomposition
Finding Insights from the Decomposition¶
Now that we have run the decomposition, understand how each part is created, we can finally see how it might be useful in terms of the insights it can provide. The trend is very useful to understand what cycle of hype something might be in. If, for example, the number of searches has been steadily increasing, we can assume that the business model has been getting more and more popular. A decreasing trend shows how something may be becoming less popular.
Let’s do a comparison of two series, one for airbnb and one for generic hotel searches. What this is going to show is how people have been shifting from the classic hotel to airbnb and similar products over the years. These trends are not relative to one and other (meaning the hotel search volume is actually much larger at all points), but what we are trying to see is the direction of the trends which is why this works.
#Get the airbnb trend
result = seasonal_decompose(Y, model='multiplicative', period=12)
airbnb_trend = result.trend
#Get the hotel trend
hotel = pd.read_csv("Hotel.csv",index_col=0)
hotel.index = pd.to_datetime(hotel.index)
result = seasonal_decompose(hotel, model='multiplicative', period=12)
hotel_trend = result.trend
#Combine to compare
trend_comparison = pd.concat([airbnb_trend, hotel_trend], axis=1)
trend_comparison.columns = ['Airbnb', 'Hotel']
trend_comparison.plot(kind='line')
plt.show()
Now that we see how the direction of the trends are moving, we could also compare the seasonality present in both. By using this seasonality comparison we can see if the seasonality in airbnb seems to match that of the overall hotel industry or if there are special differences (like if for example it is much stronger in summer when people want a get-away).
#Get the airbnb trend
result = seasonal_decompose(Y, model='multiplicative', period=12)
airbnb_seasonal = result.seasonal
#Get the hotel trend
hotel = pd.read_csv("Hotel.csv",index_col=0)
hotel.index = pd.to_datetime(hotel.index)
result = seasonal_decompose(hotel, model='multiplicative', period=12)
hotel_seasonal = result.seasonal
#Combine to compare
seasonal_comparison = pd.concat([airbnb_seasonal, hotel_seasonal], axis=1)
seasonal_comparison.columns = ['Airbnb', 'Hotel']
#Take just the one year of data, all others are repeats
seasonal_comparison = seasonal_comparison.loc['2019-01-01':'2019-12-31']
#Subtract 1 to see difference from the mean
seasonal_comparison = seasonal_comparison-1
#Change index to be the month
seasonal_comparison.index = seasonal_comparison.index.month
seasonal_comparison.plot(kind='bar')
plt.show()