UBC-MDS / DSCI_522_Group-11_Save-The-Earth

MIT License
0 stars 0 forks source link

Save The Earth

A data analysis group project for DSCI 522 (Data Science workflows); a course in the Master of Data Science program at the University of British Columbia.

About

Here we attempt to build a prediction model employing the k-nearest neighbours algorithm, designed to leverage energy consumption and energy generation measurements to predict CO2 emissions of a country. Understanding the correlation between consumption of various energy types and CO2 emission is critical for formulating policies aimed at reducing emissions and mitigating climate change impacts [Allen et al., 2018]. Our model’s performance on the unseen test dataset is quite commendable, as reflected by an $R^2$ of 0.97.

However, the model’s effectiveness lies in its ability to identify instances in the training dataset that closely resemble the data it is trying to predict. This means that when it encounters scenarios not represented in its training data, such as substantial shifts in energy usage or the introduction of new types of clean energy, its predictions may not be as accurate. Consequently, to tackle these potential limitations, it is advisable to continue research efforts to further enhance the model’s predictive capabilities.

The data set that was used in this project is from World Bank via GAPMINDER.ORG, which is an independent Swedish foundation with no political, religious or economic affiliations and the link can be found here).

Report

The final report can be found here.

Dependencies

Our project uses Docker to manage the software dependencies required. Please find the Docker image used for this project based on quay.io/jupyter/minimal-notebook:2023-11-19 image.

The additional dependencies can be found in the Dockerfile

Usage

Setup

  1. Install and launch Docker on your computer.

  2. Launch Docker on your local computer

  3. Clone this GitHub repository down to your local computer.

Running the analysis

  1. Please proceed to the project's root directory on your computer via the command line interface. Once there, execute the following command to reset the project to its initial state, effectively eliminating any files generated by prior executions of the script:
docker-compose run --rm save-the-earth-env make -C /home/jovyan/work clean
  1. To execute the complete analysis, enter the following command in the terminal in the project root:
docker-compose run --rm save-the-earth-env make -C /home/jovyan/work all

Developer notes

Working with the project in the container using Jupyter lab

  1. Please proceed to the project's root directory on your computer via the command line interface and enter the following command:
docker compose up save-the-earth-env
  1. In the terminal, look for and copy a URL that starts with http://127.0.0.1:8889/lab?token= Paste that URL into your browser.

  2. At this point, the Jupyter Lab IDE should be displayed in your browser, showcasing all project files within the file browser pane located on the left side of the screen.

Clean up
  1. To shut down the container and clean up the resources, please type Cntrl + C in the terminal, and then type docker compose rm

Working with the project in the container using VSCode

If you favor working in VS Code, executing the following command from the project's root directory within a terminal in VS Code will initiate the container within that terminal:

docker compose run --rm terminal bash

To exit the container, please type exit in the terminal.

Adding a new dependency

  1. To modify the Dockerfile and add the dependency to the Dockerfile file, please create a new branch.

  2. After updating the Dockerfile, proceed to build the Docker image locally.This step ensures that the Docker image is properly constructed and operates as expected.

  3. Upon successfully local building and testing of the Docker image, push the changes to GitHub. This action triggers an automatic build and push of a new Docker image to Docker Hub. The new image will carry a tag that corresponds to the SHA of that commit that instigated the change in the DOckerfile.

  4. Update the docker-compose.yml file on your branch with the new container image.

  5. After all the above steps are completed, please send a pull request to merge the changes into the main branch.

Tests

We have included tests and test data for functions used in our analysis in the tests folder. The test suite can be run at the root of the project via the code below:

pytest tests/*

License

The Save The Earth materials here are licensed under the Creative Commons Attribution 2.5 Canada License (CC BY 2.5 CA). If re-using/re-mixing please provide attribution and link to this webpage.

References

M Allen, OP Dube, W Solecki, F Aragón-Durand, W Cramer, S Humphreys, M Kainuma, and others. Special report: global warming of 1.5 c. Intergovernmental Panel on Climate Change (IPCC), 2018.