dev-resources.site
for different kinds of informations.
Predicting Environment Impact of Food Production caused by C02 Emission
Introduction
In this tutorial, we will be predicting the C02 emissions and their impact on food production with MindsDB. MindsDB is an open-source machine-learning tool that brings automated machine learning to your database. MindsDB offers predictive capabilities in your database.
To complete this tutorial, you are required to have a working MindsDB connection, either locally or viaĀ cloud.mindsdb.com. You can use thisĀ guideĀ to connect to the MindsDB cloud.
Data Setup
Connecting the data as a file
Follow the steps below to upload a file to MindsDB Cloud.
- Log in to yourĀ MindsDB CloudĀ account to open the MindsDB Editor.
- Navigate toĀ
Add data
Ā the section by clicking theĀAdd data
Ā button located in the top right corner.
- Choose the File tab
- Choose theĀ
Import File
Ā option. - Upload a file Food_Production.csv, name a table used to store the file data (here it isĀ
Food_Production
), and click theĀSave and Continue
Ā button. - Once you are done uploading, you can query the data directly with the;
SELECT * FROM files.Food_Production LIMIT 10;
Understanding the Dataset
Context
As the worldās population has expanded and gotten richer, the demand for food, energy, and water has seen a rapid increase. Not only has demand for all three increased, but they are also strongly interlinked: food production requires water and energy; traditional energy production demands water resources; agriculture provides a potential energy source. This article focuses on the environmental impacts of food. Ensuring everyone in the world has access to a nutritious diet in a sustainable way is one of the greatest challenges we face.
Content
This dataset contains most 43 most common foods grown across the globe and 23 columns as their respective land, water usage, and carbon footprints.
Columns
- Land use change - Kg CO2 - equivalents per kg product
- Animal Feed - Kg CO2 - equivalents per kg product
- Farm - Kg CO2 - equivalents per kg product
- Processing - Kg CO2 - equivalents per kg product
- Transport - Kg CO2 - equivalents per kg product
- Packaging - Kg CO2 - equivalents per kg product
- Retail - Kg CO2 - equivalents per kg product
These represent greenhouse gas emissions per kg of food product(Kg CO2 - equivalents per kg product) across different stages in the lifecycle of food production.
Eutrophication ā the pollution of water bodies and ecosystems with excess nutrients ā is a major environmental problem. The runoff of nitrogen and other nutrients from agricultural production systems is a leading contributor.
Acknowledgments and Credits
Credit: Vivek
Original Source: *Environment Impact of Food Production*
Creating the Predictor
To being, letās create a predictor that uses the columns to predict CO2 emission. You can learn more about creating a predictor by checkingĀ here. You can predict a classification series model using the following syntax
CREATE PREDICTOR mindsdb.[predictor_name]
FROM [integration_name]
(SELECT [sequential_column], [partition_column], [other_column], [target_column]
FROM [table_name])
PREDICT [target_column]
-
CREATE PREDICTOR
: Creates a predictor with the nameĀpredictor_name
Ā in theĀmindsdb
Ā table. -
FROM files
: Points to the table containing the data. -
PREDICT
: Dictates the column to predict.
CREATE PREDICTOR mindsdb.CO2_emission
FROM files (SELECT * FROM files.Food_Produuction)
PREDICT Total_emissions
On execution we get:
Query successfully completed
Status of a Predictor
A predictor may take a couple of minutes for the training to complete. You can monitor the status of the predictor by using this SQL command:
SELECT status
FROM mindsdb.predictors
WHERE name='CO2_emission';
Your output should be:
+------------+
| status |
+------------+
| complete |
+------------+
Making Predictions
Now that we have our Prediction Model, we can simply execute some simple SQL query statements to predict the target value based on the feature parameters:
Making a Single Prediction
You can make predictions by querying the predictor as if it were a table. TheĀ SELECTĀ statement lets you make predictions for theĀ CO2_emission
Ā on the chosen feature parameter.
SELECT Total_emissions, Total_emissions_explain
FROM mindsdb.CO2_emission
WHERE Food_Product = 'Rice'
AND Land_use_charge = 0
AND Animal_Feed = 0
AND Farm = 1.4
AND Processing = 0.1
AND Transport = 0.1
AND Packaging = 0.1
AND Retail = 0.3
Making a Bulk Prediction
Now letās make bulk predictions or multiple predictions to predict theĀ CO2_emission
Ā by joining our table with the model.
SELECT * FROM mindsdb.CO2_emission
JOIN files.Food_Production
LIMIT 100;
Whatās Next?
Have fun while trying it out yourself!
- Star theĀ MindsDB repository on GitHub.
- Sign up for aĀ free MindsDB account
- Engage with the MindsDB community onĀ SlackĀ orĀ GitHubĀ to ask questions and share your ideas and thoughts.
Give a like or a comment if this tutorial was helpful
Featured ones: