- Python 3.11
- Conda
- Clone/download the repository
- Set up and activate the environment
- Download the dataset in the directory
# Downloading the directory
git clone git@github.com:saif8091/yield-multi.git
cd yield-multi
# Setting up environment
conda env create -f environment.yml
conda activate yield_multiNote: The data should be downloaded and placed as data directory in the project root. Look here for detailed directory structure.
Run the following code:
python make.pyThis code zips the images, performs preprocessing (HSI only) and then extracts the vegetation from the croped plot images.
- Spectral downsampling by averaging every 3 adjacent bands
- Savitsky Golay filter
- Cut off extremities
python gen_feat.pyThis code generates different types of features of each plot and compiles them in a csv file and can be found here.
- gdd: Growing Degree Days
- evap: Accumulated Evapotranspiration
- vol: Volume (obtained from SFM)
- vol_lidar: Volume (obtained from LiDAR)
-
y: Beet root yield (
$kg/m^2$ )
- Format:
ref_x_mean_nx:hfor hyperspectral,mfor multispectraln: Index number (0-79 for HSI, corresponding to wavelengths between 400.80 to 928.35 nm)
- Format:
xxx_h_nxxx: Decomposition method (pca,fa,ica,plsr)h: Indicates hyperspectral datan: Band number- Note: 3-component decomposition is used as it explains 95% of the variance.
- Format:
vi_xxx_h_meanxxx: Vegetation indexh: Indicates hyperspectral data,mfor multispectral data
- Both spectral decomposition and vegetation indices are calculated from the mean plot reflectance spectra.
python -m feature_filter.filter.pyThis is code is run to find the relevant spectral features. The filtered feature can be found here.
Model schematic:
python -m model_tests.gpr_score_22Trains and outputs GPR model scores at different feature combinations for the 2022 dataset. The scores can be found here.
python -m model_tests.rf_score_22Trains and evaluates Random Forest models with hyperparameter tuning.
python -m model_tests.xgb_score_22Trains and evaluates XGBoost models with hyperparameter tuning.
python -m model_tests.svr_score_22Trains and evaluates Support Vector Regression models with hyperparameter tuning.
python -m model_tests.plsr_score_22Trains and evaluates PLSR models with hyperparameter tuning.
To test for transferability to 2021 test set run the following code:
python -m model_tests.gpr_testing_21To visualise the result open this notebook.
Open model_performance.
yield-multi/
βββ data/ # Main data directory
β βββ 2021_data.xlsx # Field measurements from 2021 growing season
β βββ 2022_data.xlsx # Field measurements from 2022 growing season
β βββ all_weather_data.csv # Meteorological data from weather station
β βββ hyper/ # Hyperspectral imagery
β β βββ 2021/ # 2021 growing season data
β β β βββ YYYYMMDD/ # Date-organized folders
β β β βββ x_YYYYMMDD.tif # Plot images (x = plot number)
β β βββ 2022/ # 2022 growing season data
β β βββ YYYYMMDD/ # Date-organized folders
β β βββ disease_grid_yield_2022/ # LBRN12Disease location
β β βββ lovebeets_grid_2022/ # LBRN12EAST location
β β βββ UV_efficacy_2022/ # LBRN12WEST location
β β βββ x_YYYYMMDD.tif # Plot images
β βββ multi/ # Multispectral imagery (same structure as hyper/)
β βββ structure/ # Canopy height models
β β βββ chm/ # CHMs from structure from motion (same structure as hyper/)
β β βββ chm_lidar/ # CHMs from LiDAR (same structure as hyper/)
β βββ preprocessed/ # Processed data files
| | βββ decomposer/ # Directory for storing decomposition models
β β βββ features_21_22.csv # Compiled features from plots
β β βββ various .pkl files # Pickled data objects
β βββ ReadMe.md # Dataset documentation
βββ data_load/
| βββ all_data_load.py # Script for loading all types of data
| βββ gt_data_load.py # Script for loading ground truth data
| βββ wt_data_load.py # Script for loading weather data
βββ feature_filter/
β βββ filtered_features/ # Directory containing filtered features
β βββ feat_filter_cfs.py # feature filtering through correlation
β βββ feat_filter_mfs.py # feature filtering through mutual information
β βββ feat_filter_micorfs.py # feature filtering using combination correlation and mutual information
β βββ feature_selection.py # feature selection function
| βββ filter.py # Implementation of feature filtering
βββ feature_formation/
| βββ feat_split_ratio.py # Contains the ratio for spliting features
| βββ feat_split.py # Script for spliting the dataset into train and test
β βββ hsi_decomposer.py # Functions for hyperspectral image decomposition
βββ figures/ # Figures and visualizations
β βββ model_schematic.jpg # Schematic diagram of the model
βββ model_files/ # Model files directory
β βββ gpr_model_func.py # GPR model functions
β βββ rf_model_func.py # Random Forest model functions
β βββ xgb_model_func.py # XGBoost model functions
β βββ svr_model_func.py # SVR model functions
β βββ plsr_model_func.py # PLSR model functions
β βββ mlp_model_func.py # MLP model functions
β βββ load_feats.py # Feature loading utilities
β βββ model_scores/ # Directory containing model score outputs
βββ model_tests/ # Model testing scripts
β βββ gpr_score_22.py # GPR model scoring for 2022 data
β βββ rf_score_22.py # Random Forest model scoring for 2022 data
β βββ xgb_score_22.py # XGBoost model scoring for 2022 data
β βββ svr_score_22.py # SVR model scoring for 2022 data
β βββ plsr_score_22.py # PLSR model scoring for 2022 data
β βββ mlp_score_22.py # MLP model scoring for 2022 data
β βββ gpr_testing_21.py # GPR model testing for transferability to 2021
β βββ visualising_performance.ipynb # Notebook for visualizing model performance
β βββ model_schematic.jpg # Visual representation of the model
βββ preprocess/ # Preprocessing scripts
β βββ zip_im.py # Script for zipping images into dictionaries
βββ src/ # Source code directory
β βββ utils.py # Utility functions for data processing
β βββ misc.py # Miscellaneous helper functions
βββ environment.yml # Conda environment definition file
βββ make.py # Script for preprocessing and vegetation extraction
βββ gen_feat.py # Script for generating features
βββ model_performance.ipynb # Notebook for model performance analysis
βββ README.md # Project documentation
