# A code distribution-based trajectory representation and its application to similarity, clustering and classification of AIS big data

Iwao Fujino, Clément Iphar, Christophe Claramunt

► To cite this version:

Iwao Fujino, Clément Iphar, Christophe Claramunt. A code distribution-based trajectory representation and its application to similarity, clustering and classification of AIS big data. Expert Systems with Applications, 2026, 310, pp.131216. 10.1016/j.eswa.2026.131216. hal-05511550

HAL Id: hal-05511550

https://hal.science/hal-05511550v1

Submitted on 15 Feb 2026

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
# A code distribution-based trajectory representation and its application to similarity, clustering and classification of AIS big data

Iwao Fujino ID a,*, Clément Iphar ID b, Christophe Claramunt ID c

## ARTICLE INFO

### Keywords:

AIS

Trajectory representation

Vector quantization

TF-IDF

Clustering

Classification

## ABSTRACT

Automatic Identification System (AIS) data received from vessels in a maritime area of interest is a valuable resource for understanding vessel behavior and gaining insights into maritime activities. This paper presents a novel approach for representing vessel trajectories using code distribution and analyzing AIS trajectory big data through machine learning techniques. By introducing PQk-means vector quantization algorithms, AIS trajectory data records are transformed into a series of code documents. Applying the TF-IDF (Term Frequency-Inverse Document Frequency) technique from text mining to these code documents produces a code distribution-based representation of vessel trajectories. This preliminary process enables the application of machine learning algorithms to AIS trajectory big data. Using this representation, three types of applications have been developed: detecting similar trajectories and vessels using vector space models and cosine similarity, clustering voyages and vessels with the K-means algorithm, and recognizing vessels with support vector machine algorithms. The potential of the proposed approach is demonstrated through a series of experiments using practical AIS datasets from a region in northwest France. Overall, the experimental results show that the proposed approach is highly effective for mining AIS big data, outperforms other methods, and confirms its ability to handle high-dimensional trajectories and massive amounts of AIS data within a reasonable computational cost. Moreover, this work provides an opportunity to develop an AIS-oriented version of a large language model based on our code distribution representation of trajectories, and to extend trajectory representation to any type of moving object or numerical vector from diverse sensors.

## 1. Introduction

AIS (Automatic Identification System) is an automatic electronic tracking system based on transceivers used by vessels to broadcast their position and identification messages. This system originated from Sweden in the early 1990s for navigation safety and collision avoidance. Nowadays, AIS messages from vessels can be received by vessels and coastal stations around the world. Moreover, AIS receivers are commonly connected to computer networks and data centers so that AIS messages can be daily stored and reused for various secondary purposes. AIS data have emerged as the dominant contributor to maritime big data, thus offering useful resources for discovering maritime trends and patterns, moreover offering valuable supports for maritime transport and surveillance operational decisions.

AIS trajectory data have been utilized to overlook and analyze maritime traffic for many years (Dobrkovic et al., 2015, 2018; Edlund et al.,

2006; Liu et al., 2023; Piciarelli et al., 2008; Ray et al., 2013; Vries & Someren, 2012). However, previous approaches have some challenges with scalability and adaptability when dealing with practical AIS big data. First, most previous studies focus solely on positional data (namely, latitude and longitude), while neglecting other critical attributes available in AIS messages, such as the MMSI, navigational status, rate of turn, speed over ground, course over ground, and true heading of the vessel. As a result, these methods fail to capture comprehensive navigational patterns and route characteristics that include heading, speed, and maneuvering behaviors. For example, many approaches are unable to distinguish between inbound and outbound routes connecting the same pair of ports. Second, the accuracy achieved by many existing methods remains limited. A common reason for this is the reliance on spatial distance metrics such as the Hausdorff distance to evaluate trajectory similarity. While widely used, the Hausdorff distance is a coarse metric that considers only the maximum and minimum deviations between trajectories, thereby overlooking finer-grained struc-

<footnote>a School of Information and Telecommunication Engineering, Tokai University, 2-3-23, Takanawa, Minato, 108-8619, Tokyo, Japan</footnote>

<footnote>b LETG-Brest GEOMER, UMR 6554 CNRS, IUEM-University of Western Brittany, Rue Dumont D'Urville, Plouzané, F-29280, France</footnote>

<footnote>c Naval Academy Research Institute, Lanvéoc, F-29160, France</footnote>

<footnote>* Corresponding author.
E-mail addresses: fujino@tokai.ac.jp (I. Fujino), clement.iphar@univ-brest.fr (C. Iphar), christophe.claramunt@ecole-navale.fr (C. Claramunt).</footnote>
tural information crucial for accurate comparison. Third, scalability to large-scale AIS datasets remains an open problem. Many studies process datasets with fewer than one million records, and when larger datasets are considered, compression techniques are often introduced to reduce data volume, typically at the cost of analytic precision and accuracy.

Our research aims to provide a comprehensive framework to overcome these questions from a novel standpoint of information retrieval and text mining. In recent years, with the development of internet and social network media, information retrieval (IR) and natural language processing (NLP) techniques have made remarkable progresses in mining big text data, such as Facebook and X (formerly Twitter). Inspired by this, we consider treating AIS trajectory data in a similar manner with a textual approach. The core idea of our research is to introduce vector quantization to transform AIS data records to text codes, which corresponds to the "words" in natural language processing, and then introduce TF-IDF (Term Frequency-Inverse Document Frequency) technique to represent the code documents in vector spaces of code distribution feature. In this way, each trajectory is transformed to a code distribution representation and all trajectories can be represented in numerical vectors of same dimension. With this code distribution representation, the vector space model, cosine similarity and other machine learning techniques can be applied to AIS trajectory data.

However, when applied to large-scale AIS data, conventional vector quantization using K-means algorithm is computationally expensive due to its iterative nature and sensitivity to high-dimensional feature vector spaces. To address this challenge, we adopt PQk-means (Product Quantization K-means) (Matsui et al., 2017), a recent high-performance clustering algorithm that reduces memory usage and accelerates computation by partitioning the feature vector spaces into smaller subspaces. This enables efficient vector quantization, making it feasible to analyze massive AIS datasets in reasonable cost of time. By introducing a PQk-means algorithm for implementing vector quantization, we elaborated a series of procedures to explore AIS big data and collect knowledge of vessels' navigation from the superficial trajectory time series records. To evaluate our proposed approach, a set of comparison experiments have been conducted with a practical AIS dataset collected from a region of northwest France.

This study introduces a novel framework for representing and analyzing AIS trajectory data by adapting techniques from text mining-specifically, vector quantization and TF-IDF-to the maritime domain. Unlike traditional trajectory representation learning (TRL) methods that rely on deep learning architectures tailored to urban mobility or GPS data, our approach transforms AIS trajectories into code documents, enabling scalable and interpretable analysis using well-established information retrieval models. This code distribution-based representation allows for consistent vector embedding of trajectories, facilitating similarity detection, clustering, and classification with reduced computational cost. To our knowledge, this is the first application of a text mining-inspired pipeline to AIS big data, offering a new perspective on maritime movement analysis.

Our main contributions are summarized as follows:

1. Introduce PQk-means vector quantization to transform AIS trajectory data to a series of code documents.

2. Use TF-IDF technique to obtain a code distribution-based representation to vessels' trajectories from these code documents.

3. Detect similar trajectories and vessels by calculating cosine similarity with the code distribution-based representation.

4. Cluster voyages and vessels by applying K-means clustering algorithm to the code distribution-based representation.

5. Recognize vessels by applying support vector machine algorithm to the code distribution-based representation.

6. Deal with high dimension (not only longitude, latitude but also heading and speed) data of trajectories and a massive amount of AIS data.

7. Analyze the effect of multiscale vector quantization to downstream tasks of similarity, clustering and recognition of vessels and voyages.

Recent advances in trajectory representation learning (TRL) have introduced sophisticated models such as graph attention networks, Transformer-based encoders, and contrastive learning frameworks, primarily applied to urban GPS data such as START (Jiang et al., 2023), RED (Zhou et al., 2024), DSTC (Wang et al., 2024), ATTraj2vec (Li et al., 2025), and C-STAR (Chen et al., 2024). These methods focus on capturing temporal regularities, spatial semantics, or user behavior, often relying on deep learning architectures that require extensive training and domain-specific tuning. In contrast, our approach leverages a code distribution-based representation derived from vector quantization and TF-IDF, inspired by text mining paradigms. This enables efficient and interpretable modeling of AIS trajectories without the need for deep neural networks. Unlike prior TRL methods, our framework is designed to handle high-dimensional maritime data, including heading and speed, while maintaining scalability and computational efficiency. Moreover, by treating trajectories as code documents, our method opens the door to applying natural language processing techniques to maritime movement analysis, offering a novel and transferable perspective not explored in existing TRL literature.

The rest of the paper is organized as follows: Section 2 briefly reviews current work related to AIS trajectory data utilization, especially trajectory representation, trajectory clustering and trajectory classification. Section 3 describes the methodology of our research, including PQk-means algorithm of vector quantization, TF-IDF, cosine similarity, clustering and classification of vessel's navigation. Section 4 shows some experimental results of vector quantization of AIS data, similarity of trajectories and vessels, clustering of trajectories and vessels, classification of trajectories, with different scale of data amount. Finally, Section 5 concludes our works and gives a few directions for future works.

## 2. Related work

One of the earliest studies on trajectory representation was conducted by Dixon and Khosla (2004). In this work, a trajectory is generally defined as a series of m-dimensional vectors. Based on this definition, the authors proposed a representation using sequenced linear dynamical systems, segmenting trajectories into stable subcomponents. These segments are designed to generalize well through closed-form least-squares fitting. However, the study remains theoretical and does not provide experimental validation on practical datasets.

In recent years, Trajectory Representation Learning (TRL) has gained significant attention as a way to efficiently encode the complex spatiotemporal structure of movement data for downstream tasks such as similarity computation, clustering, and classification. A number of studies have proposed innovative TRL methods that aim to improve the expressiveness and utility of trajectory embeddings. However, most of these studies focus on urban traffic scenarios and are limited to GPS data collected from vehicles. In such contexts, trajectories are typically represented as sequences of points in the form of (longitude, latitude, times-tamp). Another prominent approach is the START system introduced by Jiang et al. (2023). START employs a two-stage framework combining a trajectory pattern-enhanced graph attention network with a time-aware encoder to capture temporal regularities and travel semantics. This self-supervised method also leverages span-masked recovery and contrastive learning to improve cross-dataset transferability. Despite these contributions, the method exhibits limited practical performance, achieving only an $F_1$ score of 0.669 for trajectory classification on the GeoLife dataset. Another significant contribution is the RED framework by Zhou et al. (2024), which improves trajectory embeddings using a Transformer-based masked autoencoder. It integrates road-aware masking and a joint spatial-temporal-user embedding, achieving strong results across multiple benchmarks. More domain-specific applications of TRL have also emerged. For example, C-STAR, proposed by Chen et al. (2024), targets shopping behavior by modeling shopping trajectories. This framework balances inter-trajectory similarity with intra-trajectory semantic coherence, aiming to improve customer profiling in e-commerce con-
texts. In a clustering-oriented direction, Wang et al. (2024) proposed DSTC, a deep representation framework that addresses spatiotemporal inconsistencies through density-based tokenization and polar coordinate encoding. This approach aligns the latent space for improved cluster separability. Finally, ATTraj2vec, introduced by Li et al. (2025), focuses on driver identification. The model captures both local and global trajectory features via a multilevel attention mechanism, and jointly optimizes representation learning through classification and Siamese losses.

These contributions collectively highlight a trend toward increasingly sophisticated, self-supervised, and context-aware trajectory representation models, especially for GPS data from cars in the city, which our proposed code distribution-based method aims to extend in the specific domain of AIS maritime data. In the context of our research work, processing AIS data from vessels, then clustering and classification are main focal points. Zhao et al. (2017) presented a method of hierarchical clustering and a statistical method to determine parameters according to the dataset itself. Their experiments show that the method can identify ship trajectories by their similarity as clusters, and result conforms to the actual traffic flow, thus, the method can provide assistant decision-making in the field of waterway construction, maritime control and so on. Chen et al. (2020) proposed a Convolutional Neural Network-Ship Movement Modes Classification (CNN-SMMC) algorithm. The idea of their approach is to generate ship movement image from AIS data and assign label for each image. Then they train a neural network to learn from the labelled images, and the unlabeled AIS data can be effectively classified by using this trained network. Wang et al. (2021) proposed a ship AIS trajectory clustering method based on Hausdorff distance and Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN), which can adaptively cluster ship trajectories with their shape characteristics and has good clustering scalability. Afflisio et al. (2024) reported an innovative approach that leverages MASK R-CNN, a state-of-the-art computer vision algorithm, to classify maritime trajectories. Their key idea is to convert trajectory data into images that capture spatiotemporal patterns. These trajectory images are then used as input to a MASK R-CNN model that is trained on synthetically generated data to classify different types of maritime trajectories.

While these approaches have significantly advanced the field of maritime data analysis, they have limitations. One major limitation is the lack of categorization of different patterns according to the categories of different vessels. This gap can lead to less accurate predictions and analysis, as different vessels may exhibit distinct behaviors and patterns. Additionally, the computational cost of some methods remains a challenge when dealing with large-scale datasets.

As some previous works of our research, Fujino et al. (2017) reported an AIS route patterns extraction algorithm using vector quantization and topic model. Fujino et al. (2018) applied their idea to identify anomalous navigation patterns and warning anomaly events. Recently, by introducing a PQk-means algorithm of vector quantization, Fujino and Claramunt (2023) introduces a novel approach that models and extracts the patterns and provides a practical implement to gather these patterns from AIS big data.

## 3. Methodology

The proposed approach is described in this section. Beginning with the problem definition, the methodological procedure is detailed. Furthermore, the key techniques for transforming AIS data into codes are explained. Metrics used to evaluate the downstream experiments are also presented. In addition, to facilitate understanding, examples using simple synthetic data are provided at the end.

### 3.1. Problem definition

A central challenge in machine learning is effective feature representation. A trajectory is hereafter defined as follows:

**Definition 1.** A Trajectory is a sequence of points represented as:

$$ \mathcal{T} = [(\mathbf{p}_1, t_1), (\mathbf{p}_2, t_2), \dots, (\mathbf{p}_{|T|}, t_{|T|})] \quad (1) $$

where $\mathbf{p}_i = (x_{i1}, x_{i2}, \dots, x_{iM})$, M is a fixed number of dimension of point. To denote a specific geographic position, $x_{i1}$ and $x_{i2}$ typically correspond to longitude and latitude, although this is not strictly required. Also the value $|T|$ denotes the length of the trajectory, i.e., the number of data samples it contains. Importantly, $|T|$ is variable and depends on the specific trajectory. Furthermore, the timestamp is assumed to be monotonically increasing but is not required to follow a fixed sampling interval.

Since trajectory lengths are not fixed, it is challenging to apply conventional machine learning techniques that require input data in fixed-length vector form. This leads us to materialize a trajectory representation formally defined as:

**Definition 2.** A Trajectory representation maps trajectories of variable length into fixed-dimensional vector embeddings.

By transforming trajectories into uniform-length vectors, standard machine learning algorithms can be readily applied for downstream tasks such as similarity computation, clustering, and classification.

### 3.2. Methodological principles

When applying text mining techniques to AIS trajectory data, the main issues are how to give a definition of "word" and how to derive a vocabulary. In fact, an AIS data record can be considered as a vector, where the elements come from the attributes of AIS trajectory data, that is, longitude, latitude, heading, speed. Therefore, vector quantization can be applied to transform each vector to a code number, that is a "word". Then this overall giving a codebook, that is a vocabulary. However, because the most of conventional vector quantization approach is based on K-means clustering algorithm, for large-scale vector dataset, it becomes remarkable that K-means brings the problems of vast memory consumption and prohibitive runtime costs. The further improvement is to use PQk-means algorithm instead of conventional approach, and this greatly benefits to the computational cost of vector quantization. The proposed approach is made of five successive parts which are described as follows:

#### 1. Prepare vessel dataset

(a) Clean data by removing records where attribute values are unavailable. It is important not to remove the records of stopped vessels, because that the position where the vessels stopped is a significant feature of navigation.

(b) Extract longitude, latitude, heading, and speed over ground from AIS data records and consider it as a vector.

(c) Sort AIS data records according to its MMSI (identification number of vessels) and segment each AIS data records to a number of voyages by the time gap longer than 6 hours.

#### 2. Vector quantization and create a collection of code documents

(a) Apply PQk-means method from the data of all voyages of all vessels for different length of codebook.

(b) Put the code together according to its voyage and obtain a collection of code documents of voyages.

#### 3. Vector space model

(a) Calculate a TF-IDF weight as a series of feature vectors from the collection of code documents of voyages, then calculate cosine similarity between any two voyages and rank the top values to detect the most similar voyages.

(b) Merge the code documents of voyages with same MMSI to create code documents of vessels, then calculate a TF-IDF weight as a feature vector array of the collection of code documents of vessels, then calculate cosine similarity between any two vessels and rank the top values to detect the most similar vessels.
4. Clustering voyages and vessels with K-means clustering algorithm

(a) Conduct clustering to voyages with the collection of code documents to get voyages assigned by cluster number.

(b) Conduct clustering to vessels with the collection of code documents to get a dendrogram which provides a hierarchical structure of cluster of vessels.

5. Classification with support vector machine (SVM) algorithm

(a) Compose TF-IDF of each voyage as features and use vessel's MMSI of each voyage as labels to obtain a dataset for classification.

(b) Conduct classification with the dataset of TF-IDF features and MMSI labels.

(c) Conduct cross-validation to evaluate the classifier and show the result of measures of evaluation.

### 3.3. Vector quantization and PQk-means algorithm

Vector quantization is a kind of algorithm for data compression used in speech and image coding. In order to achieve efficient precision and reduce assigned codes in practical problems, vector quantization only quantizes the observed data vectors rather than the whole space expanded by each dimension of possible vector. Essentially vector quantization is implemented in two steps. The first step is to generate a codebook, which contains a finite set of code and its reference information. The second step is to quantize each vector by comparing its value with the reference information in the codebook then find its corresponding code. Many implementations of vector quantization are based on K-means clustering algorithm (Gray, 1984; Linde et al., 1980). However, when dealing with large-scale data, these conventional algorithms have some challenges of computational cost even on a up-to-date computer system.

The original idea of Product-Quantization (PQ) has been developed for source coding (Gray, 1984) and further applied to approximate nearest neighbor search by Jégou et al. (2011). In PQ search, an intermediate code is introduced to compress the original vector dataset to a lower dimension and short length dataset (Jégou et al., 2011). Based on this concept, Matsui et al. (2017) developed a billion-scale memory-efficient clustering algorithm, called PQk-means algorithm. First, assuming a dataset of D-dimension vectors $x_n = x_1, x_2, ..., x_D$ where $n \in 1, 2, ..., N$, the dataset is split into M disjoined subvectors $x_n = s_1, s_2, ..., s_M$. Then, for each D/M-dimensional vector, the closest codeword from pretrained L codewords is determined. Finally, vector $x_n$ can be expressed with a code vector, which elements is the code determined by its subvectors.

With this PQk-means algorithm, vectors in a given dataset are partitioned into K clusters and a code is assigned for each cluster. The code and centroid pair of each cluster are stored as codebook. In this way, each given vector can be expressed by the code of the cluster it belongs to. For decoding, the code can be replaced by its centroid in the codebook. As a result, one can use a code number instead of a vector with many elements and there are only a finite number of codes for a specific application.

### 3.4. Code interpretability and real-world maneuvers

To improve the interpretability of the spatial codes generated through PQk-means vector quantization, we provide examples linking specific codes to real-world vessel maneuvers. Each code corresponds to a cluster of AIS data points characterized by similar navigational attributes-longitude, latitude, heading, and speed. For instance, codes frequently associated with low speed and stable heading often represent docking or anchoring behavior, while codes with high speed and consistent directional change may indicate transit or turning maneuvers. By analyzing the distribution of codes along a trajectory, we can infer segments of navigation such as departure, cruising, or arrival phases. This interpretability enhances the semantic understanding of trajectory patterns and supports downstream tasks like anomaly detection and behavioral profiling.

<caption>**Table 1**</caption>

Confusion matrix from results of classification.

<table><thead><tr><th rowspan="2">Estimation</th><th colspan="2">Truth</th></tr><tr><th>Positive</th><th>Negative</th></tr></thead><tbody><tr><td>Positive</td><td>True Positive(TP)</td><td>False Positive(FP)</td></tr><tr><td>Negative</td><td>False Negative(FN)</td><td>True Negative(TN)</td></tr></tbody></table>

### 3.5. TF-IDF, vector space model and cosine similarity

In the domain of information retrieval and text data mining, TF-IDF is a widely used technique to evaluate the relevance or the importance of a word to a document in a collection of documents or corpus. For a given collection of documents, its TF-IDF matrix can be calculated by the following steps:

1. Term frequency is a factor of the appearance in a given document, which is the frequency of *l*-th word appeared in the *j*-th document.

$$tf_{lj} = \frac{n_{lj}}{N_j} = \frac{n_{lj}}{\sum_{l'} n_{lj'}} \quad (2)$$

where $n_{lj}$ is the number of *l*-th word appeared in *j*-th document and $N_j$ is the total number of words in the *j*-th document.

2. Inverse document frequency is a factor of the appearance in other documents, which is calculated with the following equation:

$$idf_l = \ln \frac{D}{d_l} \quad (3)$$

where $d_l$ is the count of document where the *l*-th word appeared and D is the total number of documents.

3. Multiply $tf_{lj}$ and $idf_l$ to define the weight elements.

$$w_{lj} = tf_{lj} \cdot idf_l \quad (4)$$

This gives weight vector of *j*-th documents shown as follows:

$$w_j = (w_{1j}, w_{2j}, \dots, w_{Lj}) \quad (5)$$

where the weight elements $w_{lj}$ ($l = 1, 2, \dots, L$).

Furthermore, vector space model is an algebraic model that represents documents and queries as vectors in a common space, which makes it easy to calculate the similarity between words or the relevance between a search query and document. If all of the documents are represented in weight vector $w_j$ ($j = 1, 2, \dots, J$) the similarity between any two documents can be calculated by cosine similarity as follows:

$$\cos(\mathbf{w}_i, \mathbf{w}_j) = \frac{\sum_{l=1}^{L} w_{il} w_{lj}}{\sqrt{\sum_{l=1}^{L} w_{il}^2} \sqrt{\sum_{l=1}^{L} w_{lj}^2}} \quad (6)$$

Accordingly, for a given specific document, the other documents can be ranked by its similarity and so that the most similar document can be found.

### 3.6. Performance evaluation of recognition of vessels

Recognition of vessels are implemented by classification of machine learning. When estimating from a given data record with a classifier, the result may give same value or different value with the truth. The label of truth is indicated by either "Positive" and "Negative". The estimated result of classification is also shown by either "Positive" and "Negative". Accordingly, there are four combinations to express the situation of estimated results, which are described by confusion matrix as shown in Table 1.

With the number of samples of these four combinations, several measures to evaluate the classifier are defined. Accuracy shows how many percents that the classifier estimates true from all samples. It is defined as follows:

$$Accuracy = \frac{TP + TN}{TP + TN + FP + FN} \quad (7)$$
Precision shows how many percents that the classifier estimates true positive from all estimated positive samples. It is defined as follows:

$$Precision = \frac{TP}{TP + FP} \qquad (8)$$

Recall shows how many percents that the classifier estimates true positive from all truth positive samples. It is defined as follows:

$$Recall = \frac{TP}{TP + FN} \qquad (9)$$

Furthermore, in order to consider the trade off between precision and recall, the two measures are combined to a single measure, called $F_1$ score, which is calculated by the harmonic mean of precision and recall.

$$F_1 = \frac{2}{\frac{1}{Precision} + \frac{1}{Recall}} = \frac{2 \cdot Precision \cdot Recall}{Precision + Recall} \qquad (10)$$

### 3.7. Examples of code representation, TF-IDF and cosine similarity from synthetic trajectory data

To clarify the intuition behind our method, we conducted illustrative test on a simple example of synthetic vessel trajectories. In this example, each trajectory was transformed into a sequence of spatial codes using vector quantization. Then these sequences, treated as documents, were represented using TF-IDF vectors, enabling comparison through cosine similarity.

In order to simplify the problem, the trajectories are provided with a series of samples of 2-dimension data. Suppose two synthetic trajectories are given by Trajectory 1 = [ [1.2, 1.1], [1.8, 2.3], [2.3, 3.2], [3.1, 5.5], [3.4, 6.1], [4.2, 6.3], [6.1, 5.3], [7.1, 4.2], [8.6, 4.5] ] and Trajectory 2 = [ [1.4, 0.9], [1.5, 2.4], [1.9, 2.5], [2.3, 3.6], [2.4, 3.8], [2.6, 4.1], [2.9, 4.6], [3.3, 5.5], [3.5, 5.8], [4.5, 6.1], [4.9, 5.6], [6.1, 5.3], [6.3, 5.1], [7.1, 4.2], [7.5, 4.2], [8.1, 4.3] ].

In order to demonstrate the effect for different codebook length of vector quantization, the processes of calculating cosine similarity between this two trajectories are shown in the following for the cases of codebook length equals 8 and 12 respectively. By comparing the results of this two cases, it is obvious that the less of codebook length, the bigger of the value of cosine similarity. This can be explained that when using a smaller length of codebook, more data samples are assigned to same code and this yields a bigger value of cosine similarity.

#### 3.7.1. Example 1: the case of codebook length is equal to 8

By applying vector quantization to these data, codes to each Trajectory can be obtained as shown in Fig. 1.

For this case, trajectories 1 and 2 are transformed to document of codes respectively as follows:

Document 1 = a0000 a0000 a0003 a0001 a0001 a0002 a0005 a0006 a0007

Document 2 = a0000 a0000 a0000 a0003 a0003 a0004 a0004 a0001 a0001 a0002 a0002 a0005 a0005 a0006 a0006 a0007

By denoting a list of sorted unique codes in all documents as vocabulary = [a0000, a0001, a0002, a0003, a0004, a0005, a0006, a0007], the TF-IDF of code documents can be calculated as shown in Table 2. Finally, the cosine similarity between this two trajectories becomes 0.8183 following Eq. (6).

#### 3.7.2. Example 2: the case of codebook length is equal to 12

By applying vector quantization to these data, codes to each Trajectory can be obtained as shown in Fig. 2.

For this case, trajectory 1 and 2 are transformed to document of codes respectively as follows:

Document 1 = a0004 a0000 a0005 a0001 a0001 a0008 a0009 a0010 a0003

Document 2 = a0004 a0000 a0000 a0005 a0005 a0006 a0006 a0001 a0001 a0008 a0007 a0009 a0002 a0010 a0010 a0011

By denoting a list of sorted unique codes in all documents as vocabulary = [a0000, a0001, a0002, a0003, a0004, a0005, a0006, a0007,

<figure><img src="image_2.png" /><figcaption>Fig. 1. Vector quantization of trajectory data (the number is the result of vector quantization).</figcaption></figure>

<table><caption>Table 2
TF-IDF of code documents from trajectories code distribution based.</caption><thead><tr><td>Code</td><td>Document1</td><td>Document2</td></tr></thead><tbody><tr><td>a0000</td><td>2</td><td>3</td></tr><tr><td>a0001</td><td>2</td><td>2</td></tr><tr><td>a0002</td><td>1</td><td>2</td></tr><tr><td>a0003</td><td>1</td><td>2</td></tr><tr><td>a0004</td><td>0</td><td>3.39</td></tr><tr><td>a0005</td><td>1</td><td>2</td></tr><tr><td>a0006</td><td>1</td><td>2</td></tr><tr><td>a0007</td><td>1</td><td>1</td></tr></tbody></table>

<figure><img src="image_3.png" /><figcaption>Fig. 2. Vector quantization of trajectory data (the number is the result of vector quantization).</figcaption></figure>

a0008, a0009, a0010, a0011], the TF-IDF of code documents can be calculated as shown in Table 3. Finally, the cosine similarity between this two trajectories becomes 0.5798 following Eq. (6).

### 4. Experiments and evaluations

To demonstrate the effectiveness of the proposed approach, a series of computational experiments were conducted. Starting with the
<table><caption>**Table 3**
TF-IDF of code documents from trajectories (codebook length = 12).</caption><thead><tr><td>Code</td><td>Document1</td><td>Document2</td></tr></thead><tbody><tr><td>a0000</td><td>1</td><td>2</td></tr><tr><td>a0001</td><td>2</td><td>2</td></tr><tr><td>a0002</td><td>0</td><td>1.69</td></tr><tr><td>a0003</td><td>1.69</td><td>0</td></tr><tr><td>a0004</td><td>1</td><td>1</td></tr><tr><td>a0005</td><td>1</td><td>2</td></tr><tr><td>a0006</td><td>0</td><td>3.39</td></tr><tr><td>a0007</td><td>0</td><td>1.69</td></tr><tr><td>a0008</td><td>1</td><td>1</td></tr><tr><td>a0009</td><td>1</td><td>1</td></tr><tr><td>a0010</td><td>1</td><td>2</td></tr><tr><td>a0011</td><td>0</td><td>1.69</td></tr></tbody></table>

preparation of a dataset derived from practical AIS data, the key techniques for transforming AIS data into codes were evaluated under different settings. Using these code documents, we then carried out downstream processes such as measuring similarity between voyages and vessels, clustering voyages and vessels, and vessel recognition. In addition to presenting the results of these experiments, we provide several comparisons to justify the selection of experimental parameters and algorithms. The original AIS trajectory data are distributed on https://doi.org/10.5281/zenodo.1167595 and the source codes of computational experiments are available in the repository https://github.com/IwaoFujino/AISviaTFIDF.

<table><caption>**Table 4**
Ranking vessels in terms of voyage count from preprocessed AIS data.</caption><thead><tr><td>No</td><td>MMSI</td><td>Count</td></tr></thead><tbody><tr><td>1</td><td>227002630</td><td>159</td></tr><tr><td>2</td><td>228336000</td><td>69</td></tr><tr><td>3</td><td>226318000</td><td>65</td></tr><tr><td>4</td><td>227142200</td><td>58</td></tr><tr><td>5</td><td>227318010</td><td>53</td></tr><tr><td>6</td><td>226338000</td><td>41</td></tr><tr><td>7</td><td>228208800</td><td>37</td></tr><tr><td>8</td><td>226178000</td><td>34</td></tr><tr><td>9</td><td>227008170</td><td>34</td></tr><tr><td>10</td><td>228160000</td><td>32</td></tr><tr><td>11</td><td>227577000</td><td>25</td></tr><tr><td>12</td><td>226177000</td><td>23</td></tr><tr><td>13</td><td>228183600</td><td>23</td></tr><tr><td>14</td><td>246497000</td><td>23</td></tr><tr><td>15</td><td>227016100</td><td>22</td></tr><tr><td>16</td><td>227300000</td><td>20</td></tr><tr><td>17</td><td>227392000</td><td>20</td></tr><tr><td>18</td><td>228218700</td><td>20</td></tr><tr><td>19</td><td>227391000</td><td>19</td></tr><tr><td>20</td><td>228167900</td><td>19</td></tr></tbody></table>

<table><caption>**Table 5**
Basic properties of the original dataset and three derived dataset.</caption><thead><tr><td>Item</td><td>Original</td><td>Dataset20</td><td>Dataset30</td><td>Dataset40</td></tr></thead><tbody><tr><td>Records</td><td>19,035,630</td><td>2,160,179</td><td>1,649,323</td><td>1,007,280</td></tr><tr><td>Voyages</td><td>-</td><td>758</td><td>582</td><td>445</td></tr><tr><td>Vessels</td><td>3928</td><td>18</td><td>10</td><td>6</td></tr></tbody></table>

## 4.1. Computational experiments parameters and resources

The experiments involve varying parameter settings tailored to specific tasks. For clustering, we use a fixed number of clusters $K = 6$, corresponding to the number of vessels in Dataset40. Classification experiments employ Support Vector Machines (SVM) with 4-fold cross-validation. Preprocessing includes a time gap of 6 hours and a minimum voyage length of 500 records, though these were adjusted in sensitivity analyses. The scale parameter $nn$ for vector quantization ranges from 4 to 24, resulting in codebook lengths from 256 to 331,776. Due to the diversity of experiments, parameters are described contextually rather than summarized in a single table.

All computational experiments were conducted on a desktop computer equipped with an HP OMEN 30L, featuring an Intel Core i9-10850K CPU @ 3.60GHz, 64 GB RAM, and an NVIDIA GeForce RTX 3090 GPU. The software environment included Windows 11 Pro-(version 25H2), Python 3.8.19 running in an Anaconda virtual environment, and Visual Studio Code (version 1.105.1) as the development platform.

## 4.2. Preliminary experiment: preparing dataset

The AIS trajectory dataset (Ray et al., 2018, 2019) used for our experiments has been distributed by the 2nd Maritime Big Data Workshop (MBDW) (MBDW, 2020), which is collected from the Brest bay in northwest France from October 1, 2015 to March 31, 2016. The attributes in this dataset are sourcemsi, navigationalstatus, rateof-turn, speedoverground, courseoverground, trueheading, lot(longitude), lat(latitude) and t(timestamp). This dataset contains 19,035,630 AIS records, which come from 3928 vessels. For a preliminary exploration, the dataset is first processed by the following procedures.

1. A region of interest is defined in Brest Bay and its vicinity, which gives a rectangle area of (longitude = -6.0, latitude = 49.0) and (longitude = -4.0, latitude = 47.5). Data records out of this coverage are ignored.

2. To clean the dataset, records without valid heading values are removed.

## 3. Only retain the attributes of sourcemsi, lon, lat, speedoverground, trueheading and t, others are removed.

After these procedures, the dataset shrinks to 9,495,559 records of 2973 vessels. Then AIS data records are categorized according to vessels' MMSI and segmented to voyages when the interval of its timestamp is longer than six hour. Furthermore, a minimum length of data records is introduced for avoiding very short-distance voyages. Without loss of generality, a minimum length of 500 records is experimentally chosen.

To segment AIS data into meaningful voyages, we applied a 6-hour time gap threshold between consecutive records. This rule is grounded in empirical observations from prior studies (e.g., Ray et al., 2018; Fujino et al., 2023), which suggest that such a gap typically reflects a change in navigational intent or vessel activity, such as docking or anchoring. Although vessel behavior can vary, the 6-hour threshold offers a practical balance between over-segmentation and under-segmentation, particularly in coastal regions with frequent port interactions. The dataset spans several months, covering both autumn and winter, which introduces natural variability in vessel traffic patterns. While seasonal effects were not explicitly modeled, the temporal diversity enhances the robustness of the segmentation strategy.

For the evaluation of our proposed method, a serious of dataset are generated from the original AIS trajectory data. For each voyage of a vessel, the AIS data records (longitude, latitude, heading and speed) are used as features and the MMSI of the vessel are used as labels. Additionally, to perform the training and testing steps of the machine learning algorithm, it is necessary to prepare a dataset in which each label appears a sufficient number of times. To do so, the count of vessels' voyages is checked in advance. The result of top 20 vessels is shown in Table 4.

By assigning the minimum number of the voyage count of vessels, three dataset have been generated. All data of vessels which voyage count is equal or bigger than 20, 30, 40 is called dataset20, dataset30, dataset40 respectively. The basic properties of these datasets are shown in Table 5.
<table><caption>**Table 6**
Redundancy rate and elapsed time of PQk-means algorithm for different codebook lengths.</caption><thead><tr><th rowspan="2">Scale parameter<br>nn</th><th rowspan="2">Codebook length<br>L = (nn)<sup>4</sup></th><th colspan="3">Redundancy rate</th><th colspan="3">Elapsed time</th></tr><tr><th>Dataset20</th><th>Dataset30</th><th>Dataset40</th><th>Dataset20</th><th>Dataset30</th><th>Dataset40</th></tr></thead><tbody><tr><td>4</td><td>256</td><td>0.0039</td><td>0.0039</td><td>0.0000</td><td>0:01:33.20</td><td>0:01:09.72</td><td>0:00:42.31</td></tr><tr><td>8</td><td>4096</td><td>0.1096</td><td>0.1030</td><td>0.0422</td><td>0:02:27.63</td><td>0:01:46.44</td><td>0:01:06.39</td></tr><tr><td>12</td><td>20,736</td><td>0.2020</td><td>0.2210</td><td>0.0958</td><td>0:06:21.18</td><td>0:04:52.25</td><td>0:02:52.06</td></tr><tr><td>16</td><td>65,536</td><td>0.2655</td><td>0.2549</td><td>0.1470</td><td>0:16:28.71</td><td>0:13:42.12</td><td>0:07:35.78</td></tr><tr><td>20</td><td>160,000</td><td>0.3063</td><td>0.3049</td><td>0.2146</td><td>0:37:05.87</td><td>0:30:02.75</td><td>0:19:19.18</td></tr><tr><td>24</td><td>331,776</td><td>0.3631</td><td>0.3660</td><td>0.2907</td><td>2:08:25.47</td><td>1:37:41.85</td><td>1:00:13.24</td></tr></tbody></table>

<figure><img src="image_4.png" /><figcaption>**Fig. 3.** Average count of code for different scale parameter of PQk-means vector Quantization.</figcaption></figure>

### 4.3. Experiment 1: multiscale vector quantization via PQk-means algorithm

Vector Quantization is applied to these four-dimension data records obtained from previous procedures, with the codebook length $L$ assigned in a style of $L = (nn)^4$, where $nn$ is called scale parameter, although each dimension is not equally divided into $nn$ intervals, the number $nn$ provide a rough estimation to the precision of a vector quantization setting. For applying the PQk-means algorithm of vector quantization, experiments with different scale parameter $nn = 4, 8, 12, 16, 20$ and 24 are conducted.

The redundancy rate and elapsed time for all of 4 datasets are shown in Table 6. The redundancy rate increases with larger codebooks (higher $nn$). However, this does not affect downstream tasks. The TF-IDF representation only considers codes that actually appear in documents, so unused codes do not influence similarity computation, clustering, or classification. Consequently, the performance of our proposed approach remains unaffected, and no additional computational cost is incurred in subsequent processes. This property highlights the robustness and efficiency of our method.

On the other side, these results of elapsed time show good efficiency in computational time of PQk-means algorithm, which provides a significant benefit when processing big amounts of data in a limited time. Also, comparing the values for each dataset, it is obvious that the computational time increases almost linearly when the minimum count of vessels decreases.

Then two properties of the vector quantization have been investigated. Firstly, how many data records are assigned to same code has been investigated. If a code is assigned too many data records, it means that the vector quantization cannot distinguish the data records precisely. The results of this investigation are shown in Fig. 3. From this result, it can be confirmed that the average count of code is decreased significantly from $nn = 4$ to $nn = 8$, but no remarkable changes after $nn \ge 8$.

<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Average-maximum distance between data and code centroid for different scale parameter of PQk-means vector quantization.</figcaption></figure>

Secondly, Euclidean distance between data and code centroid for different scale parameter of PQk-means vector quantization has been investigated. The measure used in this investigation is a two-step processes. Because a code may represent many data samples, the maximum distance between data sample and the centroid of its code has been picked up, which is called maximum distance of a code. Then from the list of maximum distance of all codes, the average value of maximum distance of all codes is calculated, which is called average-maximum distance. The mathematic equation average-maximum distance is shown as follows:

$$ distance(s_{ik}, \bar{c}_i) = \sqrt{\sum_{l=1}^{4} (s_{ikl} - \bar{c}_{il})^2} \qquad (11) $$

where $s_{ik}$ is data records assigned to code $i$ and $\bar{c}_i$ is the centroid of code $i$.

$$ average\-maximum\ distance = \frac{1}{N} \sum_{i=1}^{N} \left( \max_{\text{records} \in \text{code } i} distance(s_{ik}, \bar{c}_i) \right) \quad (12) $$

where $N$ is the number of codes. The results of average-maximum distance for dataset20, dataset30 and dataset40 are shown in Fig. 4. From these results, it can be confirmed that the average of maximum distance of codes for each dataset decreased as scale parameter $nn$ increases, i.e. a bigger $nn$ can make code to represent data records more precisely.

### 4.4. Experiment 2: detect similar voyages via cosine similarity

In order to detect similar trajectories, cosine similarity between any two code documents of voyages are calculated and the MMSI-timestamp and its similarity of the top three voyages are picked up. The results of dataset40 are shown in Table 7.

As an example of linear shape trajectory, trajectories on map of the first row in Table 7 are shown in Fig. 5. From these graphs, it is confirmed that the top three detected trajectories are very similar to the original trajectory, whereas their cosine similarities range from 0.76 to 0.69. Especially, it is worthwhile to pay attention that all of these four
<table><caption>**Table 7**

Detect similar voyages by cosine similarity (Dataset40).</caption><thead><tr><th>Original voyage</th><th>Fist similar voyage</th><th>Similarity</th><th>Second similar voyage</th><th>Similarity</th><th>Third similar voyage</th><th>Similarity</th></tr></thead><tbody><tr><td>226318000-1443753861</td><td>226318000-1448403207</td><td>0.7611</td><td>226318000-1452419610</td><td>0.7319</td><td>226318000-1449615162</td><td>0.6955</td></tr><tr><td>226318000-1443938387</td><td>226318000-1457852028</td><td>0.5009</td><td>226318000-1459062758</td><td>0.4952</td><td>226318000-1444165097</td><td>0.4627</td></tr><tr><td>226318000-1444165097</td><td>226318000-1451806392</td><td>0.619</td><td>226318000-1448182708</td><td>0.605</td><td>226318000-1459062758</td><td>0.5679</td></tr><tr><td>226318000-1444352023</td><td>226318000-1449196716</td><td>0.6766</td><td>226318000-1450217225</td><td>0.6469</td><td>226318000-1444768699</td><td>0.6273</td></tr><tr><td>226318000-1444650492</td><td>226318000-1445867319</td><td>0.5677</td><td>226318000-1447069734</td><td>0.5038</td><td>226318000-1453120695</td><td>0.4701</td></tr><tr><td>226318000-1444768699</td><td>226318000-1447989600</td><td>0.7774</td><td>226318000-1450217225</td><td>0.7325</td><td>226318000-1454037514</td><td>0.6983</td></tr><tr><td>226318000-1445867319</td><td>226318000-1444650492</td><td>0.5677</td><td>226318000-1450697892</td><td>0.4942</td><td>226338000-1446577714</td><td>0.492</td></tr><tr><td>226318000-1445981924</td><td>226318000-1457473100</td><td>0.7234</td><td>226318000-1448403207</td><td>0.6845</td><td>226318000-1454037514</td><td>0.6772</td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>228336000-1457935448</td><td>228336000-1444351104</td><td>0.3535</td><td>228336000-1453340035</td><td>0.3359</td><td>228336000-1453167493</td><td>0.3347</td></tr><tr><td>228336000-1458092293</td><td>228336000-1458352092</td><td>0.6575</td><td>228336000-1453167493</td><td>0.6249</td><td>228336000-1444091929</td><td>0.5683</td></tr><tr><td>228336000-1458352092</td><td>228336000-1458092293</td><td>0.6575</td><td>228336000-1453167493</td><td>0.5312</td><td>228336000-1444091929</td><td>0.4729</td></tr><tr><td>228336000-1458437900</td><td>228336000-1445648025</td><td>0.5585</td><td>228336000-1459228191</td><td>0.455</td><td>228336000-1444438418</td><td>0.4464</td></tr><tr><td>228336000-1458626979</td><td>228336000-1455851458</td><td>0.382</td><td>228336000-1448008706</td><td>0.3398</td><td>228336000-1452665307</td><td>0.2674</td></tr><tr><td>228336000-1458873603</td><td>228336000-1451362966</td><td>0.5968</td><td>228336000-1450149431</td><td>0.5591</td><td>228336000-1449626954</td><td>0.5523</td></tr><tr><td>228336000-1459228191</td><td>228336000-1445648025</td><td>0.4962</td><td>228336000-1458437900</td><td>0.455</td><td>228336000-1449539000</td><td>0.4171</td></tr><tr><td>228336000-1459312671</td><td>228336000-1448008706</td><td>0.3447</td><td>228336000-1450499096</td><td>0.3103</td><td>228336000-1450149431</td><td>0.3073</td></tr></tbody></table>

<figure><img src="image_6.png" /><figcaption>(a) Original trajectory</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>(c) Second top similar trajectory</figcaption></figure>

<figure><img src="image_8.png" /><figcaption>(b) First top similar trajectory</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>(d) Third top similar trajectory</figcaption></figure>

<caption>**Fig. 5.** Detect similar voyages via cosine similarity (Dataset40).</caption>

trajectories are in same direction. This demonstrated that our approach can distinguish the heading of vessels precisely.

Also, as an example of closed circular shape trajectory, trajectories on map of the last row in Table 7 are shown in Fig. 6. From these graphs, it is confirmed that the top three detected trajectories are similar to the original trajectory, but not as similar as in Fig. 5, because the cosine similarities range from 0.34 to 0.30, a little less than these values in Fig. 5.

In the case of closed circular trajectories, we observed that cosine similarity scores were notably lower than those for linear trajectories, despite visual similarities. However, what matters is the ranking order, not the absolute score, as our method follows an information retrieval approach. For example, in Fig. 6, trajectory (b) most closely resembles the original (a), followed by (c) and then (d), in descending order of similarity. We acknowledge this characteristic and have expanded the discussion to clarify that, while our method effectively captures

directional and structural patterns, it may underrepresent similarity in cyclic or looping trajectories.

### 4.5. Comparison experiment: detect similar voyages via similarity based on hausdorff distance

In order to give an evaluation to our approach, a comparison experiment with similarity based on Hausdorff distance has been conducted. Following definition of Hausdorff distance and similarity function provided in (Wang et al., 2021), similarity based on Hausdorff distance between any two code documents of voyages are calculated. Then the MMSI-timestamp and its similarity of the top three voyages are picked up. The results of dataset40 are shown in Table 8.

As an example of linear shape trajectory, trajectories on map of the first row in Table 8 are shown in Fig. 7. From these graphs, it is confirmed that the top three detected trajectories are relatively similar to
<figure><img src="image_10.png" /><figcaption>(a) Original trajectory</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>(c) Second top similar trajectory</figcaption></figure>

<figure><img src="image_12.png" /><figcaption>(b) First top similar trajectory</figcaption></figure>

<figure><img src="image_13.png" /><figcaption>(d) Third top similar trajectory</figcaption></figure>

<caption>**Fig. 6.** Detect similar voyages via cosine similarity (Dataset40).</caption>

<table><caption>**Table 8**
Top three similar voyages via similarity based on Hausdorff distance (Dataset40).</caption><thead><tr><th>Original voyage</th><th>Fist similar voyage</th><th>Similarity</th><th>Second similar voyage</th><th>Similarity</th><th>Third similar voyage</th><th>Similarity</th></tr></thead><tbody><tr><td>226318000-1443753861</td><td>226318000-1447989600</td><td>0.6056</td><td>226318000-1454250147</td><td>0.5455</td><td>226318000-1444768699</td><td>0.4676</td></tr><tr><td>226318000-1443938387</td><td>226318000-1457852028</td><td>0.3459</td><td>226318000-1453016929</td><td>0.3229</td><td>226318000-1456651512</td><td>0.3228</td></tr><tr><td>226318000-1444165097</td><td>226318000-1448182708</td><td>0.3985</td><td>226318000-1451806392</td><td>0.306</td><td>226318000-1456867371</td><td>0.1969</td></tr><tr><td>226318000-1444352023</td><td>226318000-1449196716</td><td>0.5268</td><td>226318000-1455846811</td><td>0.2351</td><td>226318000-1453624872</td><td>0.1837</td></tr><tr><td>226318000-1444650492</td><td>226338000-1445365243</td><td>0.6062</td><td>226338000-1446577714</td><td>0.5194</td><td>226338000-1447532064</td><td>0.479</td></tr><tr><td>226318000-1444768699</td><td>226318000-1443753861</td><td>0.4676</td><td>226318000-1454250147</td><td>0.4613</td><td>226318000-1450217225</td><td>0.3739</td></tr><tr><td>226318000-1445867319</td><td>226338000-1445365243</td><td>0.6219</td><td>226318000-1447069734</td><td>0.4861</td><td>226318000-1448283522</td><td>0.4494</td></tr><tr><td>226318000-1445981924</td><td>226318000-1447191799</td><td>0.3141</td><td>226318000-1446584919</td><td>0.2642</td><td>226318000-1457473100</td><td>0.0624</td></tr><tr><td>228336000-1457935448</td><td>228336000-1458352092</td><td>0.2774</td><td>228336000-1444438418</td><td>0.2176</td><td>227142200-1457887125</td><td>0.1644</td></tr><tr><td>228336000-1458092293</td><td>228336000-1444351104</td><td>0.1937</td><td>227318010-1456331622</td><td>0.1839</td><td>228336000-1444091929</td><td>0.1803</td></tr><tr><td>228336000-1458352092</td><td>228336000-1448008706</td><td>0.3867</td><td>228336000-1450575822</td><td>0.3611</td><td>227142200-1458059277</td><td>0.3388</td></tr><tr><td>228336000-1458437900</td><td>228336000-1453340035</td><td>0.2731</td><td>228336000-1449452292</td><td>0.2529</td><td>228336000-1449193090</td><td>0.2262</td></tr><tr><td>228336000-1458626979</td><td>227142200-1454427150</td><td>0.0448</td><td>228336000-1452918827</td><td>0.0177</td><td>228336000-1452064954</td><td>0.0114</td></tr><tr><td>228336000-1458873603</td><td>228336000-1450499096</td><td>0.4224</td><td>228336000-1452219415</td><td>0.355</td><td>228336000-1450149431</td><td>0.3396</td></tr><tr><td>228336000-1459228191</td><td>227318010-1444327138</td><td>0.2848</td><td>228336000-1443846794</td><td>0.2669</td><td>228336000-1454636003</td><td>0.2654</td></tr><tr><td>228336000-1459312671</td><td>227318010-1453302308</td><td>0.2483</td><td>227142200-1449678754</td><td>0.1853</td><td>227318010-1444327138</td><td>0.1565</td></tr></tbody></table>

the original trajectory, whereas their similarities based on Hausdorff distance range from 0.60 to 0.46. Especially, it is worthwhile to pay attention that these four trajectories are not in same direction, (a) and (c) are in bottom-top direction and (b) and (d) are in top-bottom direction. This demonstrated that similarity based on Hausdorff distance cannot distinguish the heading of vessels precisely.

Also, as an example of closed circular shape trajectory, trajectories on map of the last row in Table 8 are shown in Fig. 8. From these graphs, it is confirmed that the top three detected trajectories are relatively not similar to the original trajectory, comparing with the linear shape trajectories in Fig. 7, because the similarities based on Hausdorff distance range from 0.24 to 0.15, less than these values in Fig. 7.

For trajectory of linear shape, by comparing Fig. 5 with Fig. 7, it appears that both approaches provide good results, but our approach shows better results than the approach presented in Wang et al. (2021). For trajectory of circular shape, by comparing Fig. 6 with Fig. 8, our

approach provides similar trajectories, but the approach of Wang et al. (2021) provides some trajectories not so similar with the original one. Therefore, the results of comparison experiment demonstrated that our approach outperforms similarity based on Hausdorff distance from Wang et al. (2021). In contrast with the Hausdorff distance only one specific point to represent a trajectory, our approach use a code distribution to do so. This is the fundamental difference between the two approaches.

## 4.6. Experiment 3: cosine similarity between vessels

In order to detect vessels which have similar navigational behavior, cosine similarity between any two code documents of vessel are calculated and the MMSI and its similarity of the top vessel are picked up. Meanwhile, for comparison, different scale parameter of vector quantization are shown as well.
<figure><img src="image_14.png" /><figcaption>(a) Original trajectory</figcaption></figure>

<figure><img src="image_15.png" /><figcaption>(c) Second top similar trajectory</figcaption></figure>

<figure><img src="image_16.png" /><figcaption>(b) First top similar trajectory</figcaption></figure>

<figure><img src="image_17.png" /><figcaption>(d) Third top similar trajectory</figcaption></figure>

<figure><img src="image_18.png" /><figcaption>(a) Original trajectory</figcaption></figure>

<figure><img src="image_19.png" /><figcaption>(c) Second top similar trajectory</figcaption></figure>

<figure><img src="image_20.png" /><figcaption>(b) First top similar trajectory</figcaption></figure>

<figure><img src="image_21.png" /><figcaption>(d) Third top similar trajectory</figcaption></figure>

<caption>Fig. 8. Detect similar voyages via similarity based on Hausdorff distance (Dataset40).</caption>
<table><caption>**Table 9**
Comparison of top similar vessel among different scale parameter of vector quantization (Dataset40).</caption><thead><tr><th rowspan="2">Original Vessel</th><th colspan="4">MMSI of Top Similar Vessel (Cosine Similarity)</th></tr><tr><th>nn = 8</th><th>nn = 12</th><th>nn = 16</th><th>nn = 20</th></tr></thead><tbody><tr><td>226318000</td><td>226338000(0.6463)</td><td>226338000(0.4713)</td><td>226338000(0.3076)</td><td>226338000(0.1759)</td></tr><tr><td>226338000</td><td>226318000(0.6463)</td><td>226318000(0.4713)</td><td>226318000(0.3076)</td><td>226318000(0.1759)</td></tr><tr><td>227002630</td><td>228336000(0.0813)</td><td>227142200(0.0385)</td><td>227142200(0.0188)</td><td>227142200(0.0094)</td></tr><tr><td>227142200</td><td>227318010(0.9144)</td><td>227318010(0.8411)</td><td>227318010(0.6560)</td><td>227318010(0.4285)</td></tr><tr><td>227318010</td><td>227142200(0.9144)</td><td>227142200(0.8411)</td><td>227142200(0.6560)</td><td>227142200(0.4285)</td></tr><tr><td>228336000</td><td>227142200(0.1601)</td><td>227318010(0.1188)</td><td>227318010(0.0639)</td><td>227318010(0.0304)</td></tr></tbody></table>

<figure><img src="image_22.png" /><figcaption>**Fig. 9.** Optimal cluster number via second-order elbow curve analysis.</figcaption></figure>

The results for dataset40 are shown in Table 9. Among the six rows, four consistently identify the same vessel across all four columns. In the remaining two rows, the same vessel appears in columns with $nn = 12, 16, 20$, but differs in the column with $nn = 8$. Moreover, the similarity scores for these two rows are significantly lower compared to the other four, indicating that the results become more stable when $nn \ge 12$. Therefore, the scale parameter can generally be set to $nn = 8$, and increased beyond 8 when finer vessel distinctions are required. Additionally, vessels 227142200 and 227318010 form a pair, consistently showing identical similarity scores across all columns, suggesting they follow the same trajectory or route. Similarly, vessels 226318000 and 226338000 form another pair with the same behavior.

## 4.7. Clustering of voyages and vessels

### 4.7.1. Experiment 4: clustering voyages

The experiments for clustering voyages with K-means algorithm are conducted, where the dataset is dataset40 and the scale parameter $nn$ is set to 8, 12, 16 and 20.

Also, the number of clusters, $K = 6$, was determined by calculating the second-order derivative of the elbow curve, as shown in Fig. 9. Interestingly, this value matches the actual number of vessels in the dataset.

The result gives a label i.e. a number from (0, 1, ..., 5) for each voyage. There are 445 voyages in dataset40, due to space restrictions, it is difficult to show all of the results here. The clustering results are counted regarding to labels and vessels, as shown in Table 10.

The typical trajectories on map regarding to all labels are shown in Fig. 10, noticing that there two trajectories for label 0 and label 4 each for comparison purpose. The trajectory for different label shows different patterns (no overlap) obviously, this demonstrated that the clusters are grouped (distinguished) very well. Especially, it is worthwhile to note that trajectories in top-bottom direction from 226,318,000 and 226,338,000 are resulted in label 0, as shown in Fig. 10(a) and (b). Also, trajectories in bottom-top direction from same two vessels are resulted

<table><caption>**Table 10**
An example of classification results for dataset40 ($nn = 8$).</caption><thead><tr><th>MMSI</th><th>Label 0</th><th>Label 1</th><th>Label 2</th><th>Label 3</th><th>Label 4</th><th>Label 5</th></tr></thead><tbody><tr><td>226318000</td><td>22</td><td>1</td><td>0</td><td>0</td><td>42</td><td>0</td></tr><tr><td>226338000</td><td>16</td><td>3</td><td>0</td><td>1</td><td>22</td><td>0</td></tr><tr><td>228336000</td><td>1</td><td>68</td><td>0</td><td>0</td><td>0</td><td>0</td></tr><tr><td>227318010</td><td>1</td><td>3</td><td>0</td><td>0</td><td>2</td><td>50</td></tr><tr><td>227142200</td><td>0</td><td>9</td><td>0</td><td>0</td><td>2</td><td>49</td></tr><tr><td>227002630</td><td>0</td><td>0</td><td>131</td><td>28</td><td>0</td><td>0</td></tr></tbody></table>

in label 4, as shown in Fig. 10(f) and (g). This demonstrated that our approach can distinguish trajectories in different heading of vessels to different clusters precisely.

### 4.7.2. Experiment 5: clustering vessels

The clustering experiment regarding vessels are conducted, where the scale parameter $nn$ is set to 8, 12, 16 and 20 for dataset20, dataset30 and dataset40 respectively. Because the dendrograms of dataset20 and dataset30 are large images, it is difficult to show all of the results here. As an example, the dendrogram of dataset40 is shown in Fig. 11.

In this dendrogram, the vertical axis is label of the vessels, i.e. MMSI, and the horizontal axis is distance between clusters, which is calculated by distance = 1 - cosine similarity. In Figure 11, it can be confirmed that the subgraphs for the case of $nn = 8, 12, 16, 20$ are same shape, just the values of distance are become bigger when $nn$ increases.

On the one hand, the dendrograms for $nn = 8, 12, 16, 20$ share the same structure, indicating that the scale parameter in vector quantization does not affect the clustering results that is, the vessels assigned to each cluster remain consistent. Based on this observation, a smaller scale parameter ($nn = 8$) can be selected for clustering tasks, which significantly reduces computational cost. On the other hand, as explained in Section 3.7, cosine similarity values tend to decrease as $nn$ increases, since a more precise code representation leads to fewer AIS records being assigned to the same code. However, what matters in clustering is the order of distances, not the absolute values. As long as the relative ordering of distances remains unchanged, the clustering results will be unaffected.

In addition, let's have a fact check from Fig. 11 here. In this subgraph, the pair of most similar (smallest distance) vessels are 227142200 and 227318010, it can be found that both of them are fishing ships in Douarnenez, France. Also, the pair of second most similar (second smallest distance) vessels are 226338000 and 226318000, it can be found that both of them are passenger ship of Brittany Ferries, a French shipowner. Accordingly, this demonstrates good performance of clustering vessels with our proposed approach.

## 4.8. Experiment 6: vessel recognition

The vessel recognition experiments are implemented with support vector machine (SVM) algorithm of classification. With a labeled dataset of code document of voyage, the experiments aim to train classifier and then with the trained classifier to estimate the label (MMSI of vessel).

To ensure robust evaluation of the classification model, we applied a 4-fold cross-validation strategy across all datasets. This means that each
<figure><img src="image_23.png" /><figcaption>(a) A typical trajectory label 0</figcaption></figure>

<figure><img src="image_24.png" /><figcaption>(c) A typical trajectory of label 1</figcaption></figure>

<figure><img src="image_25.png" /><figcaption>(e) A typical trajectory of label 3</figcaption></figure>

<figure><img src="image_26.png" /><figcaption>(g) A typical trajectory of label 4</figcaption></figure>

<figure><img src="image_27.png" /><figcaption>(b) A typical trajectory of label 0</figcaption></figure>

<figure><img src="image_28.png" /><figcaption>(d) A typical trajectory of label 2</figcaption></figure>

<figure><img src="image_29.png" /><figcaption>(f) A typical trajectory of label 4</figcaption></figure>

<figure><img src="image_30.png" /><figcaption>(h) A typical trajectory of label 5</figcaption></figure>

<caption>**Fig. 10.** Examples of trajectory for each label from results of clustering.</caption>

dataset was randomly partitioned into four subsets, with three used for training and one for testing in each fold, i.e. the size of training data is 75% and the size of test data is 25% for each validation. Importantly, while the same vessel labels (MMSI) appear in both training and testing sets, the individual voyage records are distinct and non-overlapping. This setup allows the classifier to learn general navigational patterns

associated with each vessel while being tested on unseen trajectories. By maintaining label consistency without data duplication, we ensure that the reported accuracy reflects the model's ability to generalize across different voyages of the same vessel.

Table 11 shows an example of classification results with dataset20, where scale parameter *nn* = 8. In the total 758 voyages from 18 vessels,
<figure><img src="image_31.png" /><figcaption>(a) Scale parameter nn = 8</figcaption></figure>

<figure><img src="image_32.png" /><figcaption>(b) Scale parameter nn = 12</figcaption></figure>

<figure><img src="image_33.png" /><figcaption>(c) Scale parameter nn = 16</figcaption></figure>

<figure><img src="image_34.png" /><figcaption>(d) Scale parameter nn = 20</figcaption></figure>

<caption>Fig. 11. Clustering vessels via TF-IDF code documents (Dataset40).</caption>

the 589 voyages are assigned for training the classifier and the other 189 voyages are assigned for testing the classifier. The results show good performance, where the accuracy in total is 90% with 189 voyage data samples. The precision for each vessel can be found from Table 11, which gives a range from 43% to 100%.

Table 12 shows an example of classification results with dataset30, where scale parameter *nn* = 8. In the total 582 voyages from 10 vessels, the 483 voyages are assigned for training the classifier and the other 145 voyages are assigned for testing the classifier. The results show good performance, where the accuracy in total is 97% with 146 voyage data samples. The precision for each vessel can be found from Table 12, which gives a range from 94% to 100%.

Table 13 shows an example of classification results with dataset40, where *nn* = 8. In the total 445 voyages from 6 vessels, the 334 voyages are assigned for training the classifier and the other 111 voyages are assigned for testing the classifier. The results show good performance, where the accuracy in total is 99% with 111 voyage data samples. The precision for each vessel can be found from Table 13, which gives a range from 94% to 100%.

## 4.9. Statistical test across different datasets

To demonstrate the robustness of the vessel recognition results, statistical tests were conducted on three datasets: dataset20, dataset30, and
<table><caption>**Table 11**
An example of classification results for dataset20 (nn = 8).</caption><thead><tr><th>MMSI</th><th>Precision</th><th>Recall</th><th>F<sub>1</sub>-score</th><th>Voyage</th></tr></thead><tbody><tr><td>226177000</td><td>0.43</td><td>0.50</td><td>0.46</td><td>6</td></tr><tr><td>226178000</td><td>0.67</td><td>0.75</td><td>0.71</td><td>8</td></tr><tr><td>226318000</td><td>1.00</td><td>0.88</td><td>0.93</td><td>16</td></tr><tr><td>226338000</td><td>0.83</td><td>1.00</td><td>0.91</td><td>10</td></tr><tr><td>227002630</td><td>1.00</td><td>1.00</td><td>1.00</td><td>40</td></tr><tr><td>227008170</td><td>1.00</td><td>1.00</td><td>1.00</td><td>9</td></tr><tr><td>227016100</td><td>1.00</td><td>0.67</td><td>0.80</td><td>6</td></tr><tr><td>227142200</td><td>0.76</td><td>0.93</td><td>0.84</td><td>14</td></tr><tr><td>227300000</td><td>1.00</td><td>0.80</td><td>0.89</td><td>5</td></tr><tr><td>227318010</td><td>1.00</td><td>0.85</td><td>0.92</td><td>13</td></tr><tr><td>227392000</td><td>1.00</td><td>0.40</td><td>0.57</td><td>5</td></tr><tr><td>227577000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>6</td></tr><tr><td>228160000</td><td>0.75</td><td>0.75</td><td>0.75</td><td>8</td></tr><tr><td>228183600</td><td>1.00</td><td>1.00</td><td>1.00</td><td>6</td></tr><tr><td>228208800</td><td>1.00</td><td>1.00</td><td>1.00</td><td>10</td></tr><tr><td>228218700</td><td>1.00</td><td>0.80</td><td>0.89</td><td>5</td></tr><tr><td>228336000</td><td>0.81</td><td>1.00</td><td>0.89</td><td>17</td></tr><tr><td>246497000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>5</td></tr><tr><td>accuracy</td><td></td><td></td><td>0.90</td><td>189</td></tr><tr><td>macro average</td><td>0.90</td><td>0.85</td><td>0.86</td><td>189</td></tr><tr><td>weighted average</td><td>0.91</td><td>0.90</td><td>0.90</td><td>189</td></tr></tbody></table>

<table><caption>**Table 12**
An example of classification results for dataset30 (nn = 8).</caption><thead><tr><th>MMSI</th><th>Precision</th><th>Recall</th><th>F<sub>1</sub>-score</th><th>Voyage</th></tr></thead><tbody><tr><td>226178000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>8</td></tr><tr><td>226318000</td><td>0.94</td><td>1.00</td><td>0.97</td><td>16</td></tr><tr><td>226338000</td><td>1.00</td><td>0.91</td><td>0.95</td><td>11</td></tr><tr><td>227002630</td><td>1.00</td><td>1.00</td><td>1.00</td><td>40</td></tr><tr><td>227008170</td><td>1.00</td><td>1.00</td><td>1.00</td><td>9</td></tr><tr><td>227142200</td><td>0.82</td><td>1.00</td><td>0.90</td><td>14</td></tr><tr><td>227318010</td><td>1.00</td><td>0.92</td><td>0.96</td><td>13</td></tr><tr><td>228160000</td><td>1.00</td><td>0.75</td><td>0.86</td><td>8</td></tr><tr><td>228208800</td><td>1.00</td><td>1.00</td><td>1.00</td><td>10</td></tr><tr><td>228336000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>17</td></tr><tr><td>accuracy</td><td></td><td></td><td>0.97</td><td>146</td></tr><tr><td>macro average</td><td>0.98</td><td>0.96</td><td>0.96</td><td>146</td></tr><tr><td>weighted average</td><td>0.98</td><td>0.97</td><td>0.97</td><td>146</td></tr></tbody></table>

<table><caption>**Table 13**
An example of classification results for dataset40 (nn = 8).</caption><thead><tr><th>MMSI</th><th>Precision</th><th>Recall</th><th>F<sub>1</sub>-score</th><th>Voyage</th></tr></thead><tbody><tr><td>226318000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>17</td></tr><tr><td>226338000</td><td>1.00</td><td>1.00</td><td>1.00</td><td>10</td></tr><tr><td>227002630</td><td>1.00</td><td>1.00</td><td>1.00</td><td>40</td></tr><tr><td>227142200</td><td>1.00</td><td>1.00</td><td>1.00</td><td>14</td></tr><tr><td>227318010</td><td>1.00</td><td>0.92</td><td>0.96</td><td>13</td></tr><tr><td>228336000</td><td>0.94</td><td>1.00</td><td>0.97</td><td>17</td></tr><tr><td>accuracy</td><td></td><td></td><td>0.99</td><td>111</td></tr><tr><td>macro average</td><td>0.99</td><td>0.99</td><td>0.99</td><td>111</td></tr><tr><td>weighted average</td><td>0.99</td><td>0.99</td><td>0.99</td><td>111</td></tr></tbody></table>

<table><caption>**Table 14**
Statistical test of vessel recognition for different datasets (nn = 8).</caption><thead><tr><th rowspan="2">Dataset</th><th>Test</th><th rowspan="2">Mean</th><th rowspan="2">Standard deviation</th><th colspan="2">95% Confidence interval</th></tr><tr><th>numbers</th><th>Lower</th><th>Upper</th></tr></thead><tbody><tr><td>dataset20</td><td>100</td><td>0.8970</td><td>0.0202</td><td>0.8930</td><td>0.9011</td></tr><tr><td>dataset30</td><td>100</td><td>0.9622</td><td>0.0141</td><td>0.9593</td><td>0.9650</td></tr><tr><td>dataset40</td><td>100</td><td>0.9887</td><td>0.0147</td><td>0.9857</td><td>0.9916</td></tr></tbody></table>

dataset40. For each dataset, the vessel recognition process was repeated 100 times, and the resulting accuracy scores were used to compute statistical metrics. The results of these tests are summarized in Table 14. These findings confirm that the proposed approach delivers stable performance, with accuracy varying only within a very narrow range.

## Accuracy of Vessels Recognition

<figure><img src="image_35.png" /><figcaption>**Fig. 12.** Accuracy of vessel recognition for different scale parameters with each dataset.</figcaption></figure>

### 4.10. Recognition performance with different scale parameters

These experiments are conducted using dataset20, dataset30 and dataset40, where the scale parameter *nn* is set to 4, 8, 12, 16, 20, and 24 for each dataset. The results of average accuracy of cross-validation of these experiments are combined into one graph together, as is shown in Fig. 12.

By comparing these results, it can be confirmed that dataset40 achieves best performance, then dataset30 and dataset20. In fact, the dataset40 has less labels and has more data samples for each label than the others. Also, for each dataset, parameter of vector quantization *nn* = 8 achieves best performance, and when it increases, the performance get slowly worse. This result suggests that it is not necessary to increase the length of codebook for vector quantization for trajectory classification. For the case of dataset40 and *nn* = 8, the elapsed time of vector quantization is 0:01:06.39 and the elapsed time of classification with SVM algorithm (4-fold cross-validation) is 0:00:01.81. So, obviously our approach is feasible with very low cost of computational time.

Although our method does not involve deep learning, we conducted a systematic evaluation of how codebook length (determined by scale parameter) affects performance across tasks. In clustering, the results remained stable regardless of codebook size, with *nn* = 8 providing sufficient resolution and reduced computational cost. In classification, *nn* = 8 consistently achieved the highest accuracy. Larger codebooks introduced overly specific codes that acted as noise in the TF-IDF representation, similar to irrelevant terms in text mining, thereby slightly degrading performance. This suggests that moderate codebook sizes offer the best trade-off between representation richness and generalization.

### 4.11. Comparison with other classification algorithms

To provide a comparison, in addition to the previous classification experiments using the Support Vector Machine (SVM) algorithm, we conducted experiments with LightGBM, XGBoost, and Random Forest. All experiments were performed using 4-fold cross-validation on dataset40. The results, including average accuracy and elapsed time, are summarized in Table 15. These results show that the SVM algorithm outperforms the other classification methods for this dataset.

### 4.12. Comparisons with deep learning methods

In general, deep learning approaches rely on computational resources and need long training time to achieve good performance. Our framework deliberately avoids deep learning-based TRL methods, not as
<table><caption>**Table 15**
Comparison with other classification algorithm (dataset40, nn = 8).</caption><thead><tr><td>Classification Algorithm</td><td>Average Accuracy</td><td>Elapsed Time</td></tr></thead><tbody><tr><td>LightGBM</td><td>0.90</td><td>0:00:05.28</td></tr><tr><td>XGBoost</td><td>0.93</td><td>0:01:33.77</td></tr><tr><td>Random Forest</td><td>0.97</td><td>0:00:02.39</td></tr><tr><td>Support Vector Machine</td><td>0.99</td><td>0:00:01.81</td></tr></tbody></table>

<table><caption>**Table 16**
Comparison between CNN-SMMC and proposed approach.</caption><thead><tr><th rowspan="2">Item</th><th rowspan="2">CNN-SMMC</th><th colspan="3">Proposed Approach</th></tr><tr><th>Dataset20</th><th>Dataset30</th><th>Dataset40</th></tr></thead><tbody><tr><td>Number of data records</td><td>23,123</td><td>2,160,179</td><td>1,649,323</td><td>1,007,280</td></tr><tr><td>Number of class</td><td>3</td><td>18</td><td>10</td><td>6</td></tr><tr><td>Test accuracy</td><td>0.78</td><td>0.90</td><td>0.99</td><td>0.99</td></tr><tr><td>Average precision</td><td>0.92</td><td>0.90</td><td>0.99</td><td>0.99</td></tr><tr><td>Average recall</td><td>0.62</td><td>0.85</td><td>0.99</td><td>0.99</td></tr><tr><td>Average F1-score</td><td>0.76</td><td>0.86</td><td>0.99</td><td>0.99</td></tr></tbody></table>

a limitation but as a design choice. By focusing on a text-mining-inspired representation, we achieve interpretability and efficiency without the complexity and data requirements of neural models. In this subsection, rough comparisons with two deep learning methods are provided, where one deals with AIS trajectory data, but another deals with GPS trajectory data.

### 4.12.1. Comparison with CNN-SMMC algorithm

As mentioned in related work, Chen et al. (2020) reported their research for recognizing ship movement type from trajectories with a Convolutional Neural Network-Ship Movement Modes Classification (CNN-SMMC) algorithm. Although it is not same data with ours for validation experiments, both are dealing with the problem of trajectory classification. In order to give a rough comparison, the both results are summarized in Table 16. It can be confirmed that our proposed approach remarkably outperforms the CNN-SMMC algorithm.

### 4.12.2. Comparison with multilevel attention for driver identification

Also, another work mentioned previously, Li et al. (2025) presented a model to deal with GPS data of automobile trajectories via a multilevel attention mechanism and reported some experimental results for driver identification. Although it is not same data with ours for validation experiments, driver identification from GPS data of automobile trajectories can be thought as equivalent with our vessels recognition from AIS data of vessels trajectories. The results of their experiments show accuracy of 90.67 %, 85.21 %, 81.89 % and 81.27 % for driver classification of 10, 50, 150, 200 classes respectively. Here, the result of 10 classes is comparable with our experiment of dataset30, where our result gives accuracy of 97 %. When consider the case of 10 classes classification, our proposed approach shows better performance than the result of driver identification.

### 4.13. Sensitivity analysis for preprocessing parameters

In Section 4.2, two preprocessing parameters were determined empirically: (i) the time gap used to segment a trajectory into voyages, and (ii) the minimum number of data records required for a voyage to be included in the dataset. The sensitivity analysis results show performance consistent with previous findings. It can be confirmed that the average accuracy is not significantly affected by variations in these two preprocessing parameters. Details of the sensitivity analysis are provided below.

#### 4.13.1. Time gap for voyage segmentation

In this sensitivity analysis, the time gap between two voyages was set to 2 hours, 4 hours, and 6 hours, while the minimum length parameter

<table><caption>**Table 17**
Results of three derived dataset when time gap = 2 hours.</caption><thead><tr><td>Item</td><td>Dataset20</td><td>Dataset30</td><td>Dataset40</td></tr></thead><tbody><tr><td>Voyages</td><td>466</td><td>351</td><td>280</td></tr><tr><td>Vessels</td><td>12</td><td>7</td><td>5</td></tr><tr><td>Average accuracy</td><td>0.98</td><td>0.99</td><td>0.99</td></tr></tbody></table>

<table><caption>**Table 18**
Results of three derived dataset when time gap = 4 hours.</caption><thead><tr><td>Item</td><td>Dataset20</td><td>Dataset30</td><td>Dataset40</td></tr></thead><tbody><tr><td>Voyages</td><td>395</td><td>308</td><td>242</td></tr><tr><td>Vessels</td><td>10</td><td>6</td><td>4</td></tr><tr><td>Average accuracy</td><td>0.97</td><td>0.98</td><td>0.99</td></tr></tbody></table>

<figure><img src="image_36.png" /><figcaption>**Fig. 13.** Average accuracy of vessel recognition for different time gap of voyage segmentation.</figcaption></figure>

<table><caption>**Table 19**
Results of three derived dataset when minimum length = 1000.</caption><thead><tr><td>Item</td><td>Dataset20</td><td>Dataset30</td><td>Dataset40</td></tr></thead><tbody><tr><td>Voyages</td><td>512</td><td>401</td><td>332</td></tr><tr><td>Vessels</td><td>12</td><td>7</td><td>5</td></tr><tr><td>Average accuracy</td><td>0.95</td><td>0.98</td><td>0.99</td></tr></tbody></table>

<table><caption>**Table 20**
Results of three derived dataset when minimum length = 1500.</caption><thead><tr><td>Item</td><td>Dataset20</td><td>Dataset30</td><td>Dataset40</td></tr></thead><tbody><tr><td>Voyages</td><td>371</td><td>308</td><td>242</td></tr><tr><td>Vessels</td><td>9</td><td>6</td><td>4</td></tr><tr><td>Average accuracy</td><td>0.97</td><td>0.98</td><td>0.98</td></tr></tbody></table>

was fixed at 1500 records. Using these parameter settings, AIS data were preprocessed again following the procedure described in Section 4.2. Accordingly, new versions of dataset20, dataset30, and dataset40 were generated. The results for these datasets are presented in Tables 17 and 18, respectively. For performance comparison, the average accuracy of these three datasets is shown in Fig. 13.

#### 4.13.2. Minimum length of voyage

In this sensitivity analysis, the minimum length parameter, which is the minimum number of data records in a voyage, was set to 500, 1000, and 1500 records, while the time gap for voyage segmentation remained fixed at 6 hours. Using these parameter settings, AIS data were preprocessed again following the procedure described in Section 4.2. Accordingly, new versions of dataset20, dataset30, and dataset40 were
<figure><img src="image_37.png" /><figcaption>**Fig. 14.** Average accuracy of vessel recognition for different minimum length of voyage.</figcaption></figure>

generated. The results for these datasets are presented in Tables 19 and 20, respectively. For performance comparison, the average accuracy of these three datasets is shown in Fig. 14.

## 5. Conclusion and future work

This paper introduces an efficient approach to the analysis of large-scale AIS trajectory data from a novel standpoint of information retrieval and text data mining. The core idea of this approach is to introduce a code distribution-based representation for AIS trajectory data. With this code distribution-based representation, techniques established in machine learning realm, can be then applied to analysis and mine AIS trajectory data. As a result, we achieved high performance with reasonable computational cost when deal with large-scale 4-attribute AIS data. The interest and contribution of our work are as follows:

1. We introduce PQk-means algorithm of vector quantization to transform AIS trajectory big data into coded documents, then by make use of TF-IDF technique, we provide a code distribution-based representation to vessels' trajectories.

2. By leveraging the vector space model, we identify similar vessel voyages by ranking them according to cosine similarity.

3. We apply the K-means clustering algorithm to coded documents to group similar vessels and voyages, thereby capturing navigational patterns effectively.

4. We apply support vector machine (SVM) classification algorithm on coded documents to recognize vessels from AIS trajectory data.

5. With an experimental comparison across different scale parameter for vector quantization, we find that a relatively smaller scale of vector quantization gives best performance. This benefits effectively the computation cost.

The novelty of our approach lies in its integration of vector quantization and TF-IDF to construct a code distribution-based representation of AIS trajectories, bridging the gap between maritime data analysis and text mining methodologies. This framework enables efficient processing of high-dimensional AIS data and supports multiple downstream tasks, similarity detection, clustering, and classification, without relying on complex deep learning models. By treating trajectories as structured documents, our method opens new avenues for applying natural language processing techniques to maritime analytics. This conceptual shift not only enhances interpretability and scalability but also lays the groundwork for future extensions to other sensor-based movement data.

While the experiments in this study were conducted using AIS data from the Brest Bay region in northwest France, the proposed framework

is designed to be adaptable to diverse maritime environments. Its modular structure allows for application to other geographic areas, including congested ports, open sea routes, and inland waterways. Sensitivity analyses confirm robustness to preprocessing variations, supporting the method's potential for transferability to diverse maritime contexts. Future work will involve validating the approach on datasets from different regions to assess its robustness and generalizability across varying navigational contexts.

While our approach demonstrates strong performance and computational efficiency, it has limitations. First, it relies on large-scale datasets to ensure meaningful code distributions, and may not perform well on smaller datasets. Second, by ignoring the sequential order of codes, it is less suited for time-critical applications where temporal dynamics are essential. These limitations suggest directions for future refinement and application-specific adaptations.

This paper presents a novel framework for representing and analyzing AIS trajectory data using a code distribution-based approach inspired by text mining techniques. By integrating PQk-means vector quantization and TF-IDF weighting, we enable scalable and interpretable modelling of vessel movements for similarity detection, clustering, and classification. The method demonstrates strong performance across multiple datasets with low computational cost. While the framework shows promise for extension to other types of movement data, such as GPS or radar, its applicability depends on the structure and quality of the input data. Future work will focus on validating the approach in diverse maritime environments and exploring hybrid models that combine semantic and geometric features for improved trajectory representation.

## CRediT authorship contribution statement

**Iwao Fujino:** Conceptualization, Methodology, Software, Visualization, Writing - original draft, Funding acquisition; **Clément Iphar:** Data curation, Investigation, Validation; **Christophe Claramunt:** Writing - review & editing, Supervision.

## Data availability

Data will be made available on request.

## Declaration of competing interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

## Acknowledgments

This work was supported by JSPS KAKENHI Grant Number JP20K04943 of Japan and ISBlue funding of France Grant agreement number ANR-17-EURE-0015.

## References

Afflisio, E., Millefiori, L. M., Braca, P., & Guerriero, M. (2024). Maritrac: Maritime trajectory classification using object instance segmentation with model-based generated data augmentation. In *27th international conference on information fusion (fusion), Venice, Italy, 2024* (pp. 1-8). https://doi.org/10.23919/FUSION59988.2024.10706510

Chen, X., Liu, Y., Achuthan, K., & Zhang, X. (2020). A ship movement classification based on automatic identification system (ais) data using convolutional neural network. *Ocean Engineering, 218*. https://doi.org/10.1016/j.oceaneng.2020.108182

Chen, Y., Truong, Q., Shen, X., Li, J., & King, I. (2024). Shopping trajectory representation learning with pre-training for e-commerce customer understanding and recommendation, proceedings of the 30th. In *Acm sigkdd conference on knowledge discovery and data mining* (pp. 385-396). https://doi.org/10.1145/3637528.3671747

Dixon, K. R., & Khosla, P. K. (2004). Trajectory representation using sequenced linear dynamical systems. In *IEEE international conference on robotics and automation*. https://doi.org/10.1109/ROBOT.2004.1308881
Dobrkovic, A., Iacob, M. E., & Hillegersberg, J. V. (2015). Using machine learning for unsupervised maritime waypoint discovery from streaming ais data. In *Proceeding of i-know'15 (Graz, Austria, Oct. 2015)* https://doi.org/10.1145/2809563.2809573

Dobrkovic, A., Iacob, M. E., & Hillegersberg, J. V. (2018). Maritime pattern extraction and route reconstruction from incomplete (vol. 5). Springer. https://doi.org/10.1007/s41060-017-0092-8

Edlund, J., Grönkvist, M., Lingvall, A., & Sviestins, E. (2006). Rule-based situation assessment for sea surveillance. *Dasarathy, B.V. In: Proceedings of SPIE multisource information fusion: Architectures, algorithms, 6242, 624203.*

Fujino, I., & Claramunt, C. (2023). Navigation pattern extraction from ais trajectory big data via topic model. *The Journal of Navigation, 76*, 506–524. https://doi.org/10.1017/S0373463323000206

Fujino, I., Claramunt, C., & Boudraa, A. O. (2017). Extracting route patterns of vessels from ais data by using topic model. In *Proc. ieee international conference on big data (BIGDATA2017)* (pp. 4662–4664).

Fujino, I., Claramunt, C., & Boudraa, A. O. (2018). Extracting courses of vessels from ais data and real-time warning against off-course. In *Proceeding of 2nd international conference on big data research (ICBDR2018)* (pp. 62–69).

Gray, R. M. (1984). Vector quantization. *IEEE ASSP magazine* (pp. 4–29).

Jégou, H., Douze, M., & Schmid, C. (2011). Product quantization for nearest neighbor search. *IEEE Transactions on Pattern Analysis and Machine Intelligence, 33*(1), 117–128.

Jiang, J., Pan, D., Ren, H., Jiang, X., Li, C., & Wang, J. (2023). Self-supervised trajectory representation learning with temporal regularities and travel semantics. In *IEEE 39th international conference on data engineering (icde)*. https://doi.org/10.1109/ICDE55515.2023.00070

Li, M., Zhang, Y., Zhao, Y., Du, Y., & Lu, X. (2025). Trajectory representation learning with multilevel attention for driver identification *Expert Systems with Applications* (vol. 262). https://doi.org/10.1016/j.eswa.2024.125580

Linde, Y., Buzo, A., & Gray, R. (1980). An algorithm for vector quantizer design. *IEEE Transactions on Communications, 28*(1), 84–95. https://doi.org/10.1109/TCOM.1980.1094577

Liu, D., Rong, H., & Guedes Soares, C. (2023). Shipping route modelling of AIS maritime traffic data at the approach to ports, *Ocean Engineering* (vol. 289). https://doi.org/10.1016/j.oceaneng.2023.115868

Matsui, Y., Ogaki, K., Yamasaki, T., & Aizawa, K. (2017). Pqk-means: Billion-scale clustering for product-quantised codes. In *Proceeding 25th ACM international conference on multimedia* (pp. 1725–1733).

MBDW (2020). 2nd maritime big data workshop. https://sites.google.com/view/mbdw2020.

Piciarelli, C., Nicheloni, C., & Foresti, G. L. (2008). Trajectory-based anomalous event detection. *IEEE Transactions Circuits and Systems for Video Technology, 18*, 1544–1554.

Ray, C., Dréo, R., Camossi, E., & Jousselme, A.-L. (2018). Heterogeneous integrated dataset for maritime intelligence. In *Surveillance, and reconnaissance (0.1), [Dataset], Zenodo*. https://doi.org/10.5281/zenodo.1167595

Ray, C., Dréo, R., Camossi, E., Jousselme, A.-L., & Iphar, C. (2019). Heterogeneous integrated dataset for Maritime Intelligence, surveillance, and reconnaissance, *Data in Brief* (25). https://doi.org/10.1016/j.dib.2019.104141

Ray, C., Grancher, A., Thibaud, R., & Etienne, L. (2013). Spatio-temporal rule-basedanalysis of maritime traffic, *Third conference on ocean & coastal observation: Sensors and observing systems, numerical models and information (OCOSS)*. Nice, France.

Vries, G. K. D., & Someren, M. V. (2012). Machine learning for vessel trajectories using compression, alignments and domain knowledge. Elsevier. Expert Systems with Applications https://doi.org/10.1016/j.eswa.2012.05.060

Wang, C., Huang, J., Wang, Y., Lin, Z., Jin, X., & Jin, X. (2024). A deep spatiotemporal trajectory representation learning framework for clustering. *IEEE Transactions on Intelligent Transportation Systems, 25*(7), 7687–7700. https://doi.org/10.1109/TITS.2024.3350339

Wang, L., Chen, P., Chen, L., & Mou, J. (2021). Ship ais trajectory clustering: An hdbscan-based approach. *Journal of Marine Science and Engineering, 9*, 566. https://doi.org/10.3390/jmse9060566

Zhao, L., Shi, G., & Yang, J. (2017). An adaptive hierarchical clustering method for ship trajectory data based on dbscan algorithm. In *IEEE 2nd international conference on big data analysis (icbda)* (pp. 329–336). https://doi.org/10.1109/ICBDA.2017.8078834

Zhou, S., Shang, S., Chen, L., Jensen, C. S., & Kalnis, P. (2024). RED: Effective trajectory representation learning with comprehensive information *Proceedings of the VLDB Endowment 18*. (2), 80–92 https://doi.org/10.14778/3705829.3705830