{"id":25518472,"url":"https://github.com/rcode879/gdp-life-expectancy-predictor","last_synced_at":"2025-12-18T23:30:18.532Z","repository":{"id":276874644,"uuid":"930592185","full_name":"Rcode879/GDP-Life-expectancy-predictor","owner":"Rcode879","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-10T22:19:23.000Z","size":792,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T23:23:44.468Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rcode879.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-10T22:08:18.000Z","updated_at":"2025-02-10T22:19:27.000Z","dependencies_parsed_at":"2025-02-10T23:34:01.046Z","dependency_job_id":null,"html_url":"https://github.com/Rcode879/GDP-Life-expectancy-predictor","commit_stats":null,"previous_names":["rcode879/gdp-life-expectancy-predictor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rcode879%2FGDP-Life-expectancy-predictor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rcode879%2FGDP-Life-expectancy-predictor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rcode879%2FGDP-Life-expectancy-predictor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rcode879%2FGDP-Life-expectancy-predictor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rcode879","download_url":"https://codeload.github.com/Rcode879/GDP-Life-expectancy-predictor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239696855,"owners_count":19682322,"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-02-19T16:40:26.078Z","updated_at":"2025-12-18T23:30:18.068Z","avatar_url":"https://github.com/Rcode879.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDP-Life-expectancy-predictor\n# Life Expectancy vs GDP Prediction Model\n\n## 📌 Overview\n\nThis project analyzes the relationship between **GDP per Capita** and **Life Expectancy** using **Polynomial Regression**. The model fits a **7th-degree polynomial** to predict life expectancy based on GDP per capita. The project includes:\n\n- Data preprocessing (cleaning and transformation)\n- Polynomial regression model training\n- Data visualization using Matplotlib\n- Interactive **console-based predictions**\n- **R² error evaluation** to measure model accuracy\n\n## 🚀 Features\n\n✅ Reads data from a CSV file \n✅ Cleans and preprocesses the dataset \n✅ Applies **log transformation** to GDP for better model fit \n✅ Fits a **7th-degree polynomial regression model** \n✅ Plots **actual vs predicted values** with a logarithmic scale \n✅ Allows **user input to predict life expectancy** \n✅ Displays **R² score** to assess model accuracy \n✅ Interactive **menu for user interaction**\n\n---\n\n## 🛠️ Installation \u0026 Setup\n\n### **1️⃣ Clone the Repository**\n\n```sh\ngit clone https://github.com/Rcode879/GDP-Life-expectancy-predictor.git\ncd GDP-Life-expectancy-predictor\n```\n\n### **2️⃣ Install Dependencies**\n\nEnsure you have Python installed. Then, install the required libraries:\n\n```sh\npip install numpy pandas matplotlib scikit-learn\n```\n\n### **3️⃣ Run the Script**\n\n```sh\npython main.py\n```\n\n---\n\n## 📊 How It Works\n\n1. **Load \u0026 Clean Data**\n\n   - Reads the dataset from `life-expectancy-vs-gdp-per-capita.csv`\n   - Drops unnecessary columns and handles missing values\n\n2. **Apply Log Transformation**\n\n   - GDP is **log-transformed** to make the relationship more linear\n\n3. **Train Polynomial Regression Model**\n\n   - Fits a **7th-degree polynomial** using `np.polyfit()`\n\n4. **Plot the Model**\n\n   - Scatter plot of GDP vs. Life Expectancy\n   - Polynomial regression curve (red line) overlayed\n   - **Logarithmic x-axis** for better visualization\n\n5. **Interactive Console Menu**\n\n   - `p` → Predict life expectancy for a user-input GDP value\n   - `t` → Display the **R² error** of the model\n   - `g` → Show the **graph** of the model\n   - `q` → Quit the program\n\n---\n\n## 📈 Example Usage\n\n```\nEnter 'p' to make a prediction, 't' to view R² error, 'g' to view graph, 'q' to quit: p\nEnter the GDP per Capita: 65020.35\nThe estimated life expectancy of a country with 65020.35 GDP per capita is 77.7771393826115 years\n```\n\n## NOTE:\n\n   - There is also a notebook which provides a visual explaination of the code\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcode879%2Fgdp-life-expectancy-predictor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcode879%2Fgdp-life-expectancy-predictor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcode879%2Fgdp-life-expectancy-predictor/lists"}