{"id":26367491,"url":"https://github.com/rahulrmcoder/linear-regression--boston-house-value-prediction","last_synced_at":"2025-03-16T21:17:23.803Z","repository":{"id":245483920,"uuid":"818384121","full_name":"RahulRmCoder/Linear-Regression--Boston-House-Value-Prediction","owner":"RahulRmCoder","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-27T11:18:03.000Z","size":432,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-28T09:34:36.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RahulRmCoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-21T18:20:25.000Z","updated_at":"2024-06-27T11:18:06.000Z","dependencies_parsed_at":"2024-06-22T10:46:44.382Z","dependency_job_id":null,"html_url":"https://github.com/RahulRmCoder/Linear-Regression--Boston-House-Value-Prediction","commit_stats":null,"previous_names":["rahulrmcoder/linear-regression--boston-house-value-prediction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RahulRmCoder%2FLinear-Regression--Boston-House-Value-Prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RahulRmCoder%2FLinear-Regression--Boston-House-Value-Prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RahulRmCoder%2FLinear-Regression--Boston-House-Value-Prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RahulRmCoder%2FLinear-Regression--Boston-House-Value-Prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RahulRmCoder","download_url":"https://codeload.github.com/RahulRmCoder/Linear-Regression--Boston-House-Value-Prediction/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243933454,"owners_count":20370988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-16T21:17:23.143Z","updated_at":"2025-03-16T21:17:23.786Z","avatar_url":"https://github.com/RahulRmCoder.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linear-Regression--Boston-House-Value-Prediction\n\n\nThis project demonstrates the use of linear regression to predict the median value of owner-occupied homes in the Boston area using various predictors.\n\n## Dataset\n\nThe dataset contains the following columns:\n\n1. **crim**: per capita crime rate by town.\n2. **zn**: proportion of residential land zoned for lots over 25,000 sq.ft.\n3. **indus**: proportion of non-retail business acres per town.\n4. **chas**: Charles River dummy variable (= 1 if tract bounds river; 0 otherwise).\n5. **nox**: nitrogen oxides concentration (parts per 10 million).\n6. **rm**: average number of rooms per dwelling.\n7. **age**: proportion of owner-occupied units built prior to 1940.\n8. **dis**: weighted mean of distances to five Boston employment centres.\n9. **rad**: index of accessibility to radial highways.\n10. **tax**: full-value property-tax rate per 10,000 dollars.\n11. **ptratio**: pupil-teacher ratio by town.\n12. **black**: 1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town.\n13. **lstat**: lower status of the population (percent).\n14. **medv**: median value of owner-occupied homes in $1000s.\n\n## Steps to Run the Analysis\n\n### 1. Import Necessary Libraries\n\n```python\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn import metrics\n```\n\n### 2. Load the Data\n\n```python\ndata = pd.read_csv('path/to/your/boston.csv')  # Update the path to your dataset\ndata.head()\n```\n\n### 3. Data Visualization and Correlation Analysis\n\n```python\nfig = plt.figure(figsize=(15, 15))\nsns.heatmap(data.corr(), annot=True)\nplt.show()\n```\n\n### 4.Select Relevant Features Based on Correlation Analysis\n\n```python\ndata2 = data[['indus', 'rm', 'lstat', 'medv']]\n```\n\n### 5. Check for Linearity\n\n```python\nfig = plt.figure(figsize=(15, 15))\nplt.subplot(2, 3, 1)\nplt.scatter(data2['indus'], data2['medv'])\nplt.subplot(2, 3, 2)\nplt.scatter(data2['rm'], data2['medv'])\nplt.subplot(2, 3, 3)\nplt.scatter(data2['lstat'], data2['medv'])\nplt.show()\n```\n\n### 6. Split the Data into Training and Testing Sets\n\n```python\nX = pd.DataFrame(data2[['indus', 'rm', 'lstat']])\ny = pd.DataFrame(data2['medv'])\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=2)\n```\n\n### 7. Train the Linear Regression Model\n\n```python\nmodel = LinearRegression()\nmodel.fit(X_train, y_train)\n```\n\n### 8. Model Evaluation\n\n```python\ny_pred = model.predict(X_test)\n\n# Mean Absolute Error\nmae = metrics.mean_absolute_error(y_test, y_pred)\nprint(\"Mean Absolute Error:\", mae)\n\n# Mean Squared Error\nmse = metrics.mean_squared_error(y_test, y_pred)\nprint(\"Mean Squared Error:\", mse)\n\n# Root Mean Squared Error\nrmse = np.sqrt(mse)\nprint(\"Root Mean Squared Error:\", rmse)\n\n# R-Squared\nr2 = metrics.r2_score(y_test, y_pred)\nprint(\"R-Squared:\", r2)\n```\n\n### 9. Calculate Adjusted R-Squared\n\n```python\nn = len(X_test)\nk = X_test.shape[1]\nadjusted_r2 = 1 - ((1 - r2) * (n - 1)) / (n - k - 1)\nprint(\"Adjusted R-Squared:\", adjusted_r2)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulrmcoder%2Flinear-regression--boston-house-value-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahulrmcoder%2Flinear-regression--boston-house-value-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulrmcoder%2Flinear-regression--boston-house-value-prediction/lists"}