Professional Documents
Culture Documents
Sayan Chakraborty 33200120063 Taiwan
Sayan Chakraborty 33200120063 Taiwan
ipynb - Colaboratory
Choose Files No file chosen Upload widget is only available when the cell has been executed in the current
browser session. Please rerun this cell to enable.
Saving taiwan real estate2 - taiwan real estate2.csv to taiwan real estate2 - taiwan real estate2.csv
import pandas as pd
import seaborn as sns
import numpy as np
taiwan=pd.read_csv('taiwan_real_estate2 - taiwan_real_estate2.csv')
taiwan
0 84.87882 10 30 to 45 11.467474
1 306.59470 9 15 to 30 12.768533
2 561.98450 5 0 to 15 14.311649
3 561.98450 5 0 to 15 16.580938
4 390.56840 5 0 to 15 13.040847
taiwan.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 414 entries, 0 to 413
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 dist_to_mrt_m 414 non-null float64
1 n_convenience 414 non-null int64
2 house_age_years 414 non-null object
3 price_twd_msq 414 non-null float64
dtypes: float64(2), int64(1), object(1)
memory usage: 13.1+ KB
print (mdl_price_vs_conv.params)
Intercept 8.224237
n_convenience 0.798080
dtype: float64
https://colab.research.google.com/drive/1I90nEpJ1uvugk1H75JdEMZv289PlMKoL?authuser=1#printMode=true 1/3
2/15/23, 6:49 PM Sayak_Bhattacharyya_33200120058.ipynb - Colaboratory
n_convenience 0.791457
dtype: float64
sns.regplot(x='n_convenience',y='price_twd_msq',data=taiwan)
<matplotlib.axes._subplots.AxesSubplot at 0x7f62e14d6fd0>
sns.boxplot(x='house_age_years',y='price_twd_msq',data=taiwan)
<matplotlib.axes._subplots.AxesSubplot at 0x7f62e1144280>
coeffs = mdl_price_vs_both.params
ic_0_15, ic_15_30, ic_30_45, slope = coeffs
sns.scatterplot(x='n_convenience',y='price_twd_msq',hue='house_age_years',data=taiwan)
<matplotlib.axes._subplots.AxesSubplot at 0x7f62e10ce220>
n_convenience house_age_years
0 0 30 to 45
1 0 15 to 30
2 0 0 to 15
3 1 30 to 45
4 1 15 to 30
5 1 0 to 15
6 2 30 to 45
7 2 15 to 30
8 2 0 to 15
9 3 30 to 45
Code Text
from itertools import product
n_convenience= np.arange(0, 10)
house_age_years = taiwan['house_age_years'].unique()
https://colab.research.google.com/drive/1I90nEpJ1uvugk1H75JdEMZv289PlMKoL?authuser=1#printMode=true 2/3
2/15/23, 6:49 PM Sayak_Bhattacharyya_33200120058.ipynb - Colaboratory
p= product(n_convenience, house_age_years)
explanatory_data = pd.DataFrame(p,columns=['n_convenience','house_age_years'])
prediction_data = explanatory_data.assign(
price_twd_msq = mdl_price_vs_both.predict(explanatory_data)
)
print(prediction_data.head(n=10))
https://colab.research.google.com/drive/1I90nEpJ1uvugk1H75JdEMZv289PlMKoL?authuser=1#printMode=true 3/3