├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Mohab Wafaie 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Study of the Effects of Climate Change on Crop Yields 2 | ## Prediction of crop yields based on climate variables using machine learning algorithms 3 | ![dataset-cover](https://user-images.githubusercontent.com/39447236/222884458-65707c2b-bade-4bfe-a41a-80e024cdabaf.jpg) 4 | 5 | ## Data 6 | The data contains 28242 rows and 7 columns 7 | 8 | ![Screenshot 2023-03-04 095913](https://user-images.githubusercontent.com/39447236/222884543-ef5eef10-e35f-4fe0-bb56-97b8c40ae563.png) 9 | 10 | ### the columns are : 11 | 1- Area 12 | 2- Crop 13 | 3- Year 14 | 4- Average rain fall mm per year 15 | 5- Pesticides tonnes 16 | 6- Average temperature 17 | 7- hg/ha_yield (Output) 18 | ## Data Analysis 19 | ![Screenshot 2023-03-04 100232](https://user-images.githubusercontent.com/39447236/222884637-960c37ee-9b79-4fa8-a349-a47c224c84d0.png) 20 | ![Screenshot 2023-03-04 100315](https://user-images.githubusercontent.com/39447236/222884667-7a5d7341-2aeb-4f9a-aca8-c0e32f8c22ff.png) 21 | ![Screenshot 2023-03-04 100419](https://user-images.githubusercontent.com/39447236/222884694-042bf2e2-f60f-403b-bcca-9240d2f5828a.png) 22 | 23 | ## Preprocessing 24 | 1- Dropped the "Year" column because it has no relevance 25 | 2- Hot encoded categorical data using pandas get dummis 26 | 3- Split the data into X (features) and Y (output) 27 | 4- Normalized the feature columns to be between 0 and 1 28 | 5- Split the data into 80% for training and 20% for testing 29 | ## Prediction 30 | 1- Used LazyPredict library to compare the results of multiple regression algorithms 31 | 32 | ![Screenshot 2023-03-04 100539](https://user-images.githubusercontent.com/39447236/222884758-0b02fef1-4f4e-42ae-ad6e-571f96040957.png) 33 | 34 | 2- Use Random Forest Regressor for regression as it has the best accuracy 35 | 36 | ![Screenshot 2023-03-04 100715](https://user-images.githubusercontent.com/39447236/222884810-502ac00e-ffe6-4a48-a386-07d9fc672de2.png) 37 | --------------------------------------------------------------------------------