2017年8月17日星期四

人工智能 與 樓價預測(二)

將 ClassA 資料分為三類
ClassA_HK   =  Hong Kong
ClassA_KLN = Kowloon
ClassA_NT    = New Territories
#Data Preparation
ClassA_HK  =  data.where(data.Class == 'A').where(data.Place=='Hong Kong').dropna()[['Date','Value','Rent']]
ClassA_KLN =  data.where(data.Class == 'A').where(data.Place=='Kowloon').dropna()[['Date','Value','Rent']]
ClassA_NT  =  data.where(data.Class == 'A').where(data.Place=='New Territories').dropna()[['Date','Value','Rent']]



將香港/九龍/新界樓價 用圖表顯示, 可見到香港區波幅 會比 九龍/新界大, 九龍與新界樓價 於1999至2007 比較接近,2007之後九龍樓價開始拋離新界。
  %pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Domestic Price(Class A) from 1999 to 2017', size=26)
plt.xlabel('Year' , size=20)
plt.ylabel('Price', size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_HK.Date,  ClassA_HK.Value,color="red", label='Hong Kong')
plt.plot(ClassA_KLN.Date, ClassA_KLN.Value,color="blue", label="Kowloon")
plt.plot(ClassA_NT.Date,  ClassA_NT.Value,color="black", label="New Territories")
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()





%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Domestic Rent(Class A)',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Rent',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_HK.Date,  ClassA_HK.Rent,color="red", label='Hong Kong')
plt.plot(ClassA_KLN.Date, ClassA_KLN.Rent,color="blue", label="Kowloon")
plt.plot(ClassA_NT.Date,  ClassA_NT.Rent,color="black", label="New Territories")
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()


租金方面,香港區 明顯高於九龍/新界


# Normalized ClassA(HK) Price VS Rent
ClassA_HK['normalizePrice']=(ClassA_HK['Value'] / ClassA_HK['Value'].iloc[0])
ClassA_HK['normalizeRent']=(ClassA_HK['Rent'] / ClassA_HK['Rent'].iloc[0])

%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Normalized Price and Rent',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Price and Rent',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_HK.Date,  ClassA_HK['normalizePrice'],color="red", label='Price')
plt.plot(ClassA_HK.Date,  ClassA_HK['normalizeRent'],color="blue", label='Rent')
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()



為左更好表示樓價與租金升幅比例,將Price 和 Rent Normalized  ,租金升幅遠不及樓價升幅




# ClassA(HK) Rent Return
ClassA_HK['rentReturn'] = ClassA_HK['Rent']*12 / ClassA_HK['Value']
#print(ClassA_HK)
%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Rent Return',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Rent Return',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_HK.Date,  ClassA_HK['rentReturn'],color="black", label='Return')
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()


Class A HONG KONG 租金回報.. 最高係2003 年,超過8厘


# Normalized ClassA(KLN) Price VS Rent
ClassA_KLN['normalizePrice']=(ClassA_KLN['Value'] / ClassA_KLN['Value'].iloc[0])
ClassA_KLN['normalizeRent']=(ClassA_KLN['Rent'] / ClassA_KLN['Rent'].iloc[0])

%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Class A Kowloon Normalized Price and Rent',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Price and Rent',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_KLN.Date,  ClassA_KLN['normalizePrice'],color="red", label='Price')
plt.plot(ClassA_KLN.Date,  ClassA_KLN['normalizeRent'],color="blue", label='Rent')
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()


九龍區 Normalized Price and Rent  .. 樓價自1999年升幅3.5.. 租金升幅約 2 左右.






# ClassA(KLN) Rent Return
ClassA_KLN['rentReturn'] = ClassA_KLN['Rent']*12 / ClassA_KLN['Value']
#print(ClassA_KLN)
%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('ClassA Kowloon Rent Return',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Rent Return',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_KLN.Date,  ClassA_KLN['rentReturn'],color="black", label='Return')
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()


九龍區租金收入最高 2007年   7厘多少少





# Normalized ClassA(NT) Price VS Rent
ClassA_NT['normalizePrice']=(ClassA_NT['Value'] / ClassA_NT['Value'].iloc[0])
ClassA_NT['normalizeRent']=(ClassA_NT['Rent'] / ClassA_NT['Rent'].iloc[0])

%pylab inline
pylab.rcParams['figure.figsize'] = (20, 20)
plt.title('Class A New Territories Normalized Price and Rent',size=26)
plt.xlabel('Year',size=20)
plt.ylabel('Price and Rent',size=20)

plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))
plt.plot(ClassA_NT.Date,  ClassA_NT['normalizePrice'],color="red", label='Price')
plt.plot(ClassA_NT.Date,  ClassA_NT['normalizeRent'],color="blue", label='Rent')
plt.gcf().autofmt_xdate()
plt.legend(loc=0 , prop={'size': 20})
plt.rc('xtick',labelsize=20)
plt.rc('ytick',labelsize=20)
plt.show()


新界區 Normalized Price and Rent







沒有留言:

發佈留言