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.
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).
The final report can be found here.
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
Install and launch Docker on your computer.
Launch Docker on your local computer
Clone this GitHub repository down to your local computer.
docker-compose run --rm save-the-earth-env make -C /home/jovyan/work clean
docker-compose run --rm save-the-earth-env make -C /home/jovyan/work all
docker compose up save-the-earth-env
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.
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.
Cntrl
+ C
in the terminal, and then type docker compose rm
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.
To modify the Dockerfile
and add the dependency to the
Dockerfile
file, please create a new branch.
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.
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.
Update the docker-compose.yml
file on your branch with the new
container image.
After all the above steps are completed, please send a pull request
to merge the changes into the main
branch.
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/*
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.