## 2 Materials and Methods
### Encoding Data and Building the Classification Model  
Encoding the features in a dataset is as important as choosing the amount of HD-levels. Additionally, for the numerical values representation of the observations, every feature must be encoded in the HD space by randomly generating unique hypervectors. Both the HD-levels and the feature hypervectors are essential to build the classification model, which is composed of a single hypervector for each class in a dataset and is built by collapsing all the HD representation of the classes observations. These last hypervectors are created by iterating over the values, one-by-one for each feature, and rotating the HD-level vector related to the current value by \(n\) positions, where \(n\) is the position of the feature among the whole list of features. Thus, the rotated HD-level vector must be summed element-wise to the HD representation of the feature. This procedure has been previously described in [27; 28] with the name Ngram-based encoder. It consists of differentiating the feature positions through the assignment of unique hypervectors that result from the permutation of the feature HD representations, as described by Equation (2). \[O_{n}^{i}=v_{1}+\rho^{1}(v_{2})+...+\rho^{m-1}(v_{m}) \tag{2}\]  
Figure 1: Flow chart of the whole procedure for building and testing the HD classification model. First, the definition of the set of HD-levels is required (1). It is a mandatory step toward the encoding of all the observations in the training subset (2) and the definition of the classes HD vector representations by combining the observations which belong to the same class (3). The same encoding procedure is then applied to the observations in the test subset (4). Every HD representation of the test observations is finally compared with the set of class HD vectors by computing the inner product (5). The class of the most closest vector is finally assigned to the observation. If a wrong class is assigned during the test phase, a retraining of the HD classification model must be performed multiple times (6) until the accuracy achieved in an iteration will not change as compared to the previous one. Equation (2) describes how a observation \(n\), which belongs to the class \(i\), is encoded in the HD space. The \(\rho\) operator represents the rotation that must be applied \(k\) times, with \(k\) equaling to the position of the feature, while \(v\) is the HD-level vector associated to a particular value. Finally, all of the resulting HD vector representations of the observations are summed together composing the HD representation of the class, as described with Equation (3). \[C^{i}=O_{1}^{i}+O_{2}^{i}+...+O_{n}^{i} \tag{3}\]  
In this equation, \(C^{i}\) is the HD representation of the class \(i\), which is composed by applying the element-wise sum of all HD vector representations of the observations assigned to the class \(i\). The same procedure is applied by grouping the observations assigned to different classes and can be generalised with the pseudocode in Algorithm 1. ```
1:define \(iter\) as the maximum number of retraining iterations
2:Dataset is the input dataset
3:initialise Classes with the list of classes in Dataset
4:forClass in Classesdo
5:vector \(\leftarrow\)\([0\ldots 0]\)
6:forObs in Classdo
7:for\(i=0,1,\ldots,m-1\) in Obsdo
8:\(l\leftarrow\) get the level vector according to the Obs value in the \(i\)-th position
9: Rotate \(l\) by \(i\) positions
10: Element-wise sum \(l\) and vector
11:endfor
12:endfor
13: yield vector as the HD representation of Class
14:endfor
15:for\(i=0,...,iter\)do
16: retrain the classes vectors until the accuracy will not change
17:endfor
```  
**Algorithm 1** Encoding observations to class hypervectors  
By performing the element wise sum of the vectors, the final HD representation of a class will be very different from the single HD representation of the observations of that class. As described below, the classification process works on computing the distance between the vectors.