{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.11.11","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":7327,"databundleVersionId":861871,"isSourceIdPinned":false,"sourceType":"competition"},{"sourceId":6092787,"sourceType":"datasetVersion","datasetId":3489360}],"dockerImageVersionId":31040,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"## Import dataset","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19"}},{"cell_type":"code","source":"import warnings\nwarnings.filterwarnings('ignore')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.722849Z","iopub.execute_input":"2025-06-30T14:03:04.723199Z","iopub.status.idle":"2025-06-30T14:03:04.728751Z","shell.execute_reply.started":"2025-06-30T14:03:04.723176Z","shell.execute_reply":"2025-06-30T14:03:04.727411Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\ndf = pd.read_csv(\"/kaggle/input/housing-price-prediction/Housing.csv\")\n\ndf.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.730591Z","iopub.execute_input":"2025-06-30T14:03:04.731020Z","iopub.status.idle":"2025-06-30T14:03:04.770305Z","shell.execute_reply.started":"2025-06-30T14:03:04.730993Z","shell.execute_reply":"2025-06-30T14:03:04.769283Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Basic info and summary","metadata":{}},{"cell_type":"code","source":"df.tail()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.771134Z","iopub.execute_input":"2025-06-30T14:03:04.771464Z","iopub.status.idle":"2025-06-30T14:03:04.786091Z","shell.execute_reply.started":"2025-06-30T14:03:04.771437Z","shell.execute_reply":"2025-06-30T14:03:04.784771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.787788Z","iopub.execute_input":"2025-06-30T14:03:04.788694Z","iopub.status.idle":"2025-06-30T14:03:04.815942Z","shell.execute_reply.started":"2025-06-30T14:03:04.788653Z","shell.execute_reply":"2025-06-30T14:03:04.814890Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Statistical Summary","metadata":{}},{"cell_type":"code","source":"df.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.840510Z","iopub.execute_input":"2025-06-30T14:03:04.840853Z","iopub.status.idle":"2025-06-30T14:03:04.868710Z","shell.execute_reply.started":"2025-06-30T14:03:04.840822Z","shell.execute_reply":"2025-06-30T14:03:04.867500Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.describe(include='object')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.870619Z","iopub.execute_input":"2025-06-30T14:03:04.871432Z","iopub.status.idle":"2025-06-30T14:03:04.894899Z","shell.execute_reply.started":"2025-06-30T14:03:04.871408Z","shell.execute_reply":"2025-06-30T14:03:04.893914Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Missing Values","metadata":{}},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.896175Z","iopub.execute_input":"2025-06-30T14:03:04.896817Z","iopub.status.idle":"2025-06-30T14:03:04.922523Z","shell.execute_reply.started":"2025-06-30T14:03:04.896757Z","shell.execute_reply":"2025-06-30T14:03:04.921570Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Univariate Analysis","metadata":{}},{"cell_type":"code","source":"sns.histplot(df['price'], kde=True, bins=30)\nplt.title('Price Distribution')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:04.923579Z","iopub.execute_input":"2025-06-30T14:03:04.923913Z","iopub.status.idle":"2025-06-30T14:03:05.204530Z","shell.execute_reply.started":"2025-06-30T14:03:04.923888Z","shell.execute_reply":"2025-06-30T14:03:05.203210Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(df['area'], kde=True, bins=30)\nplt.title('Area Distribution')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:05.207726Z","iopub.execute_input":"2025-06-30T14:03:05.208115Z","iopub.status.idle":"2025-06-30T14:03:05.497184Z","shell.execute_reply.started":"2025-06-30T14:03:05.208092Z","shell.execute_reply":"2025-06-30T14:03:05.496029Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(df['bedrooms'], kde=True, bins=30)\nplt.title('Bedrooms Distribution')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:05.498532Z","iopub.execute_input":"2025-06-30T14:03:05.500103Z","iopub.status.idle":"2025-06-30T14:03:05.776329Z","shell.execute_reply.started":"2025-06-30T14:03:05.500027Z","shell.execute_reply":"2025-06-30T14:03:05.774782Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.histplot(df['stories'], kde=True, bins=30)\nplt.title('Stories Distribution')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:05.777688Z","iopub.execute_input":"2025-06-30T14:03:05.778112Z","iopub.status.idle":"2025-06-30T14:03:06.040595Z","shell.execute_reply.started":"2025-06-30T14:03:05.778082Z","shell.execute_reply":"2025-06-30T14:03:06.039444Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.countplot(x='bedrooms', data=df, palette='Set2')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:06.041905Z","iopub.execute_input":"2025-06-30T14:03:06.042349Z","iopub.status.idle":"2025-06-30T14:03:06.192527Z","shell.execute_reply.started":"2025-06-30T14:03:06.042303Z","shell.execute_reply":"2025-06-30T14:03:06.191454Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Heatmap","metadata":{}},{"cell_type":"code","source":"sns.heatmap(df[['price', 'area', 'bedrooms', 'bathrooms', 'stories', 'parking']].corr(), annot=True, cmap='coolwarm')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:06.193458Z","iopub.execute_input":"2025-06-30T14:03:06.193776Z","iopub.status.idle":"2025-06-30T14:03:06.537174Z","shell.execute_reply.started":"2025-06-30T14:03:06.193683Z","shell.execute_reply":"2025-06-30T14:03:06.536195Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Bivariate Analysis\n## Numerical vs Numerical\n\n* ### Price vs Area\n* ### Price vs Bedroom\n* ### Price vs stories","metadata":{}},{"cell_type":"code","source":"sns.scatterplot(x='area', y='price', data=df)\nplt.title('Price vs Area')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:06.538185Z","iopub.execute_input":"2025-06-30T14:03:06.538453Z","iopub.status.idle":"2025-06-30T14:03:06.763290Z","shell.execute_reply.started":"2025-06-30T14:03:06.538432Z","shell.execute_reply":"2025-06-30T14:03:06.762154Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.scatterplot(x='bedrooms', y='price', data=df)\nplt.title('Price vs Bedroom')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:06.764838Z","iopub.execute_input":"2025-06-30T14:03:06.765168Z","iopub.status.idle":"2025-06-30T14:03:06.972241Z","shell.execute_reply.started":"2025-06-30T14:03:06.765145Z","shell.execute_reply":"2025-06-30T14:03:06.971070Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.scatterplot(x='stories', y='price', data=df)\nplt.title('Price vs stories')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:06.973506Z","iopub.execute_input":"2025-06-30T14:03:06.973796Z","iopub.status.idle":"2025-06-30T14:03:07.188392Z","shell.execute_reply.started":"2025-06-30T14:03:06.973774Z","shell.execute_reply":"2025-06-30T14:03:07.187249Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Categorical vs Numerical\n\n*  Price by mainroad\n*  Price by airconditioning\n*  Price by hotwaterheating\n*  Price by furnishingstatus","metadata":{}},{"cell_type":"code","source":"cat_features = ['airconditioning', 'mainroad', 'hotwaterheating', 'furnishingstatus', 'basement', 'guestroom']\n\nfor cat in cat_features:\n    sns.boxplot(data=df, x=cat, y='price')\n    plt.title(f'Price by Air {cat}')\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:07.189481Z","iopub.execute_input":"2025-06-30T14:03:07.189730Z","iopub.status.idle":"2025-06-30T14:03:08.736886Z","shell.execute_reply.started":"2025-06-30T14:03:07.189711Z","shell.execute_reply":"2025-06-30T14:03:08.735385Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Categorical vs Categorical","metadata":{"execution":{"iopub.status.busy":"2025-06-30T13:22:27.315145Z","iopub.execute_input":"2025-06-30T13:22:27.315470Z","iopub.status.idle":"2025-06-30T13:22:27.320201Z","shell.execute_reply.started":"2025-06-30T13:22:27.315440Z","shell.execute_reply":"2025-06-30T13:22:27.319121Z"}}},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:08.741178Z","iopub.execute_input":"2025-06-30T14:03:08.741497Z","iopub.status.idle":"2025-06-30T14:03:08.759013Z","shell.execute_reply.started":"2025-06-30T14:03:08.741474Z","shell.execute_reply":"2025-06-30T14:03:08.757895Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct = pd.crosstab(df['guestroom'], df['basement'])\nct.plot(kind='bar', stacked=True, colormap='viridis')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:08.760132Z","iopub.execute_input":"2025-06-30T14:03:08.760507Z","iopub.status.idle":"2025-06-30T14:03:08.960685Z","shell.execute_reply.started":"2025-06-30T14:03:08.760473Z","shell.execute_reply":"2025-06-30T14:03:08.959661Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct = pd.crosstab(df['airconditioning'], df['guestroom'])\nct.plot(kind='bar', stacked=True, colormap='viridis')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:08.962114Z","iopub.execute_input":"2025-06-30T14:03:08.962477Z","iopub.status.idle":"2025-06-30T14:03:09.164835Z","shell.execute_reply.started":"2025-06-30T14:03:08.962447Z","shell.execute_reply":"2025-06-30T14:03:09.163664Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct = pd.crosstab(df['airconditioning'], df['mainroad'])\nct.plot(kind='bar', stacked=True, colormap='viridis')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:09.165964Z","iopub.execute_input":"2025-06-30T14:03:09.166277Z","iopub.status.idle":"2025-06-30T14:03:09.358277Z","shell.execute_reply.started":"2025-06-30T14:03:09.166247Z","shell.execute_reply":"2025-06-30T14:03:09.357179Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct = pd.crosstab(df['airconditioning'], df['hotwaterheating'])\nct.plot(kind='bar', stacked=True, colormap='viridis')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:09.359405Z","iopub.execute_input":"2025-06-30T14:03:09.359767Z","iopub.status.idle":"2025-06-30T14:03:09.563074Z","shell.execute_reply.started":"2025-06-30T14:03:09.359728Z","shell.execute_reply":"2025-06-30T14:03:09.562062Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ct = pd.crosstab(df['airconditioning'], df['furnishingstatus'])\nct.plot(kind='bar', stacked=True, colormap='viridis')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:09.564240Z","iopub.execute_input":"2025-06-30T14:03:09.564577Z","iopub.status.idle":"2025-06-30T14:03:09.780174Z","shell.execute_reply.started":"2025-06-30T14:03:09.564549Z","shell.execute_reply":"2025-06-30T14:03:09.779124Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Plot for Multivariate Relationships","metadata":{}},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:09.781229Z","iopub.execute_input":"2025-06-30T14:03:09.781560Z","iopub.status.idle":"2025-06-30T14:03:09.795869Z","shell.execute_reply.started":"2025-06-30T14:03:09.781536Z","shell.execute_reply":"2025-06-30T14:03:09.794792Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"sns.pairplot(df, vars=['area', 'price', 'bedrooms', 'stories', 'bathrooms', 'parking'])\nplt.suptitle('Pairplot ')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:09.797086Z","iopub.execute_input":"2025-06-30T14:03:09.797403Z","iopub.status.idle":"2025-06-30T14:03:18.215235Z","shell.execute_reply.started":"2025-06-30T14:03:09.797381Z","shell.execute_reply":"2025-06-30T14:03:18.213872Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"## Outlier Detection","metadata":{}},{"cell_type":"code","source":"sns.boxplot(x=df['price'])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-06-30T14:03:18.216391Z","iopub.execute_input":"2025-06-30T14:03:18.216667Z","iopub.status.idle":"2025-06-30T14:03:18.353445Z","shell.execute_reply.started":"2025-06-30T14:03:18.216647Z","shell.execute_reply":"2025-06-30T14:03:18.352214Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}