{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt # graphs\nimport seaborn as sns # graphs\n\n\ndf = pd.read_csv('../input/train.csv')\ndf.head()","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","collapsed":true,"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":false},"cell_type":"markdown","source":"My hypothesis is that the yera a house was built will positivley correlate with the eventual sale price. There are 2 reasons for my belief. First, older houses in Boston have been built in a specific style, they tend to be the smaller, terraced houses inside the city centre. Newer houses tend to be larger and on the outskirts of the city. Further, newer houses are seen as more desirable, as there is a smaller risk of major structural problems, that would need lots of money to repair.\n\nTo test this hypothesis, I will take a random sample of 100 values from the dataset, and find the PMCC. Then, we can test the hypothesis."},{"metadata":{"trusted":true,"_uuid":"0f09480d27bc86ace24ba52647e9787a2c9147af"},"cell_type":"code","source":"sample = df.sample(n=100, random_state=100)\nsample.corr().iloc[6,-1]","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"91e5fb126fb7f9b8ab951c80fbd93165f47daa40"},"cell_type":"markdown","source":"The correlation coefficiant between sale price and age of 100 datapoints was 0.5498. \n\nOur hypothesis are:\n\nH<sub>0</sub>: ρ=0\n\nH<sub>1</sub>: ρ>0\n\nTesting at the 0.5% level, the critical value is ρ=0.2565. Since our PMCC is greater than this critical value, there is enough evidence to reject H<sub>0</sub> and accept the alternative hypothesis. At the 0.5% level, these 2 variables are correlated.\n\nWe can now plot these variable on a scatter plot."},{"metadata":{"_uuid":"30397d8fc79b970c1b8123c3a022ae16b2cf4b0e"},"cell_type":"raw","source":""},{"metadata":{"trusted":true,"_uuid":"46120e1462516fb6e62fe2aba16a8772d2810c44"},"cell_type":"code","source":"ax = sns.regplot(x=\"YearBuilt\", y=\"SalePrice\", data=df)\nregression_line = np.polyfit(df['YearBuilt'], df['SalePrice'], 1)\nprint('The regression line is sale price = ', int(abs(regression_line[0])), '* yearBuilt + ', int(abs(regression_line[1])))","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}