{"id":23732308,"url":"https://github.com/Himel-Sarder/ML-Exercise-Regression-Metrics","last_synced_at":"2025-09-04T07:31:59.697Z","repository":{"id":270131000,"uuid":"909423176","full_name":"Himel-Sarder/ML-Exercise-Income-Dataset-Regression-Metrics","owner":"Himel-Sarder","description":"This repository contains an exercise on regression metrics using an income dataset to predict happiness. The exercise includes data preprocessing, model training, evaluation, and visualization.","archived":false,"fork":false,"pushed_at":"2024-12-28T19:36:15.000Z","size":1578,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T20:25:04.316Z","etag":null,"topics":["error-handling","income-dataset","machine-learning","machine-learning-algorithms","machinelearning","ml","ml-exercise","ml-practice","regression","regression-metrics","simple-linear-regression"],"latest_commit_sha":null,"homepage":"","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/Himel-Sarder.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-12-28T16:55:27.000Z","updated_at":"2024-12-28T19:38:41.000Z","dependencies_parsed_at":"2024-12-28T18:16:32.085Z","dependency_job_id":null,"html_url":"https://github.com/Himel-Sarder/ML-Exercise-Income-Dataset-Regression-Metrics","commit_stats":null,"previous_names":["himel-sarder/ml-regression-metrics","himel-sarder/ml-exercise-income-dataset-regression-metrics"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himel-Sarder%2FML-Exercise-Income-Dataset-Regression-Metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himel-Sarder%2FML-Exercise-Income-Dataset-Regression-Metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himel-Sarder%2FML-Exercise-Income-Dataset-Regression-Metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himel-Sarder%2FML-Exercise-Income-Dataset-Regression-Metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Himel-Sarder","download_url":"https://codeload.github.com/Himel-Sarder/ML-Exercise-Income-Dataset-Regression-Metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231940769,"owners_count":18449194,"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":["error-handling","income-dataset","machine-learning","machine-learning-algorithms","machinelearning","ml","ml-exercise","ml-practice","regression","regression-metrics","simple-linear-regression"],"created_at":"2024-12-31T04:15:39.621Z","updated_at":"2025-09-04T07:31:54.349Z","avatar_url":"https://github.com/Himel-Sarder.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ML-Exercise-Income-Dataset-Regression-Metrics\n\nThis repository contains an exercise on regression metrics using an income dataset to predict happiness. The exercise includes data preprocessing, model training, evaluation, and visualization.   \n\n![image](https://github.com/user-attachments/assets/a5b61eb6-3238-436d-9872-fd8b0cef69fa)\n\n## Overview\n\n- **Coded by**: Himel Sarder\n- **Contact**: info.himelcse@gmail.com\n- **LinkedIn**: [Himel Sarder](https://www.linkedin.com/in/himel-sarder/)\n\n## Files in the Repository\n\n- `Exercise ~ Regression Metrics.ipynb`: Jupyter notebook containing the regression analysis.\n- `LICENSE`: License information.\n- `Mymodel.pkl`: Serialized model file.\n- `README.md`: This README file.\n- `Regression Metrics.ipynb`: Additional notebook for regression metrics.\n- `income.csv`: Dataset containing income and happiness data.\n\n## Dataset\n\nThe dataset `income.csv` contains the following columns:\n- `Unnamed: 0`: Index column.\n- `income`: Income values.\n- `happiness`: Happiness scores.\n\n## Getting Started\n\n### Prerequisites\n\n- Python 3.x\n- Jupyter Notebook\n- Required Python libraries:\n  - pandas\n  - numpy\n  - matplotlib\n  - scikit-learn\n\n### Installation\n\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/Himel-Sarder/ML-Exercise-Income-Dataset-Regression-Metrics.git\n   ```\n2. Navigate to the project directory:\n   ```sh\n   cd ML-Exercise-Income-Dataset-Regression-Metrics\n   ```\n3. Install the required libraries:\n   ```sh\n   pip install pandas numpy matplotlib scikit-learn\n   ```\n\n## Usage\n\n### 1. Load and Explore the Dataset\nLoad the dataset using pandas and display its structure:\n```python\nimport pandas as pd\ndf = pd.read_csv('income.csv')\nprint(df.head())\nprint(df.shape)\nprint(df.info())\n```\n\n### 2. Data Visualization\nVisualize the relationship between income and happiness:\n```python\nimport matplotlib.pyplot as plt\nplt.scatter(df['income'], df['happiness'], c=df['happiness'], cmap='coolwarm')\nplt.xlabel('Income')\nplt.ylabel('Happiness')\nplt.colorbar(label='Happiness')\nplt.show()\n```\n\n### 3. Data Splitting\nSplit the data into training and test sets:\n```python\nfrom sklearn.model_selection import train_test_split\nX = df.iloc[:, 1:2]\ny = df.iloc[:, -1]\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=2)\n```\n\n### 4. Model Training\nTrain a Linear Regression model:\n```python\nfrom sklearn.linear_model import LinearRegression\nlr = LinearRegression()\nlr.fit(X_train, y_train)\n```\n\n### 5. Model Evaluation\nEvaluate the model using various metrics:\n```python\nfrom sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score\ny_pred = lr.predict(X_test)\nprint(\"Mean Absolute Error:\", mean_absolute_error(y_test, y_pred))\nprint(\"Mean Squared Error:\", mean_squared_error(y_test, y_pred))\nprint(\"R-squared:\", r2_score(y_test, y_pred))\nprint(\"Root Mean Squared Error:\", np.sqrt(mean_squared_error(y_test, y_pred)))\n```\n\n### 6. Save the Model\nSave the trained model to a file:\n```python\nimport pickle\npickle.dump(lr, open('Mymodel.pkl', 'wb'))\n```\n\n## Additional Experiment\nTest the impact of adding random features and recalculating R² and adjusted R² scores.\n\n## License\n\nThis project is licensed under the MIT License - see the `LICENSE` file for details.\n\n## Acknowledgments\n\n- Thank you to everyone who contributed to this project.\n\n## Contact\n\nIf you have any questions or feedback, feel free to contact me at info.himelcse@gmail.com.\n\n---\n\nHappy coding! 😺\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHimel-Sarder%2FML-Exercise-Regression-Metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHimel-Sarder%2FML-Exercise-Regression-Metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHimel-Sarder%2FML-Exercise-Regression-Metrics/lists"}