This project implements a Long Short-Term Memory (LSTM) model for predicting the modal price of a commodity based on the historical data provided in the "Agmar.csv" dataset.
The main steps of the project are as follows:
-
Data Preprocessing: The dataset is preprocessed by converting the "Price Date" column to datetime format and extracting the year and month. The relevant columns are selected, and the data is scaled using the MinMaxScaler.
-
Model Building: A sequential LSTM model is constructed using Keras. It consists of an LSTM layer with 128 units and a dense layer with 1 unit.
-
Model Training: The model is compiled with the Adam optimizer and trained on the preprocessed data for 100 epochs with a batch size of 32.
-
Model Evaluation: The trained model is evaluated using the testing data, and the Mean Squared Error (MSE) is calculated as the evaluation metric.
-
Prediction and Visualization: The model is utilized to make predictions on the testing data, and the results are visualized by comparing the actual and predicted values.
-
Model Saving: The trained LSTM model is saved to a file named "model.h5" for future use.
To run the notebook and reproduce the results, the following dependencies are required:
- Python 3.x
- pandas
- numpy
- scikit-learn
- matplotlib
- seaborn
- tensorflow
-
Clone this repository or download the "agmar_lstm_model.ipynb" notebook file.
-
Install the required dependencies using pip or conda:
pip install pandas numpy scikit-learn matplotlib seaborn tensorflow
-
Open the "agmar_lstm_model.ipynb" notebook in Jupyter Notebook or JupyterLab.
-
Execute each cell in the notebook sequentially to reproduce the results and visualize the data.
-
Customize the code as needed, such as modifying hyperparameters, adding additional visualizations, or applying different preprocessing techniques.
- pandas Documentation
- scikit-learn Documentation
- matplotlib Documentation
- seaborn Documentation
- TensorFlow Documentation
Feel free to explore and utilize this LSTM model for predicting modal prices based on historical agricultural data. If you have any questions or suggestions, please feel free to reach out.