-
To compute local spatial features to instill spatial awareness in the rocky terrain predictor.
-
This implementation takes the point-based data as input, computes spatial features, and returns the dataset with spatial features.
- Clone this repository.
git clone https://github.com/Gaurav0502/grid-based-spatial-feature-engineer.git- Install all packages in the
requirements.txtfile.
pip install -r requirements.txt-
The
scripts/spatialfeaturegenerator.pycontains the code for generating the spatial features. To get the updated dataset (with the spatial features), you need to execute thecompute_spatial_features()function inside the classSpatialFeatureGenerator. -
After execution, you must get four new features for every remote sensing index (i.e., any column except the depth and coordinate):
*_spatial_mean*_spatial_std*_spatial_weighted_mean(excludes the point itself*)*_spatial_weighted_std(excludes the point itself*)
* prevent zero division error.
Notes:
-
The function only computes features for a grid of dimensions (3 x 3). To use any other dimensions, you must use the
compute_spatial_features_with_stride()with thegrid_sizeas input and thestridefor the sliding window. -
Any values outside the bounds of the feature space are considered as NaN and are excluded from the computation.
-
When using the output dataframe for modelling, ensure you make use of the
GroupKFoldfrom sklearn to mitigate chances of data leakage. In other words, a grid (in its entirety) must either be in the train set or the test set. -
Preferably, keep the grids for both depths in the same set to instill spatial awareness and depth perception into the model.