This repository contains a simple linear regression model built with PyTorch to predict crop yields based on rainfall, temperature, and humidity.
Predicting crop yields is crucial for efficient agricultural planning and management. This project uses a simple linear regression model implemented in PyTorch to predict crop yields based on key environmental parameters: rainfall, temperature, and humidity.
The dataset used in this project includes historical data on crop yields and corresponding values for rainfall, temperature, and humidity. Ensure your dataset is in a CSV format and follows this structure: [ ] Rainfall [ ] Temperature [ ] Humidity [ ] Crop_yield
The model is a simple linear regression model with the following structure:
- Input layer: 3 neurons (rainfall, temperature, humidity)
- Output layer: 1 neuron (predicted crop yield)
The training loop includes:
- Data loading and preprocessing
- Forward pass
- Loss calculation using Mean Squared Error (MSE)
- Backward pass and optimization using Stochastic Gradient Descent (SGD)
- Clone the repository:
git clone https://github.com/swarajkumarsingh/linear-regression-basic.git ll_model cd ll_model
- Prepare your dataset and place it in the data/ directory.
- Train the model by running:
python train.pyAfter training, the model will output the predicted crop yields. You can evaluate the model's performance using metrics like Mean Squared Error (MSE).
Contributions are welcome! Please open an issue or submit a pull request for any changes or enhancements.
This project is licensed under the MIT License. See the LICENSE file for details.