This repository contains two main components:
- Cleaning Module: A set of scripts and tools for preparing and cleaning AIS (Automatic Identification System) data.
- AI_V2 Module: A hybrid Transformer-GRU model designed for predicting coordinates based on the cleaned AIS data.
The Cleaning folder contains scripts for preprocessing and cleaning AIS data. These scripts handle tasks such as:
- Filtering cargo data (
cargoFilter.py) - Removing outliers (
removeOutliers.py) - Reducing trajectory data (
trajectoryReducer.py) - Detecting and clustering ship movements (
clusterDetection.py,clusterRunner.py) - Handling missing time intervals (
missingTime.py) - Extracting geographical features (
geo.py)
cleaning.py: Main script for cleaning AIS data.ShipNotMovingFiltre.py: Filters out ships that are not moving.polyIntersect.py: Handles polygon intersection for geographical data.main.py: Entry point for running the cleaning pipeline.
The AI_V2 folder contains the implementation of a hybrid Transformer-GRU model for predicting coordinates. This module leverages the cleaned AIS data to train and evaluate the model.
- Transformer-GRU Architecture: Combines the strengths of Transformers for capturing long-term dependencies and GRUs for sequential data processing.
- Model Training and Evaluation: Scripts for training and evaluating the model (
Transformer.py). - Preprocessing: Scripts for preparing data for the model (
preprocess.py).
Transformer.py: Main script for training the model.merge.py: Combines multiple datasets for training.preprocess.py: Prepares the data for the model.
The models folder contains pre-trained models and checkpoints for the hybrid Transformer-GRU model. These can be used for inference or further fine-tuning.
The Data folder includes geographical data files such as:
land_poly.geojson: Land polygon data.river_poly.geojson: River polygon data.
The scripts folder contains shell scripts for automating various tasks, including:
- Cleaning AIS data (
cleaning.sh) - Running clustering algorithms (
clusterRunner.sh) - Extracting features (
extractor.sh) - Reducing trajectories (
trajectory_reducer.sh)
- Python 3.10 or later
- Required Python libraries (install using
requirements.txtif available) - Shell environment for running
.shscripts
- Clone the repository:
git clone <repository-url> cd data-cleaning
- Install dependencies:
pip install -r requirements.txt
- Navigate to the
Cleaningfolder:cd Cleaning - Run the main cleaning script:
or use the bash script:
python main.py
sbatch main.sh
- Navigate to the
AI_V2folder:cd AI_V2 - Preprocess the data:
python preprocess.py
- Train and eval the model:
python Transformer.py
This project was designed to run on supercomputers using Singularity containers and the SLURM workload manager. All scripts, including the data cleaning pipeline and AI model training, are executed via sbatch commands for job scheduling.
Singularity containers were used to ensure a consistent runtime environment across different systems. The AI model and data cleaning scripts were executed within these containers.
-
Build or pull the required Singularity image:
singularity build <image-name>.sif <definition-file>
or
singularity pull <image-name>.sif <image-url>
-
Load the Singularity module (if required by the supercomputer):
module load singularity
To run a script inside a Singularity container, use the following pattern:
singularity exec <image-name>.sif sbatch <script-name>.sh- Submit the cleaning job:
singularity exec <image-name>.sif sbatch Cleaning/main.sh
- Submit the training job:
singularity exec <image-name>.sif sbatch AI_V2/Transformer.sh
This approach ensures reproducibility and efficient resource utilization on supercomputers.
To build the required Singularity container for this project, simply run the builder.sh script. This script uses SLURM to allocate resources and builds the container using Singularity's --fakeroot option.
- Navigate to the
AI_V2folder:cd AI_V2 - Submit the build job:
sbatch builder.sh
This will create the Singularity container ai_container_l4_v2.sif based on the definition file ai_container_l4.def. The build process is configured to use 20 CPUs, 100GB of memory, and a maximum runtime of 12 hours.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- The AIS data used in this project.
- Libraries and frameworks that made this project possible.