## 3 Materials and Methods
### SVM Training and Test  
Once the dataset was prepared, the training and optimization of the SVMs began. The chosen approach was \"one-vs-one\", where an SVM is trained for each possible pair of grasping postures (with each grasping posture corresponding to a class). For \(k\) classes, the number of binary classifiers (\(NBC\)) required is:  
\[NBC(k)=\frac{k(k-1)}{2}. \tag{1}\]  
\(NBC\) covers all possible grasping posture combinations. In this case, there are 9 grasp types, so the multi-class model consists of 36 binary SVMs.  
Before training, the data were standardized, and the selected kernel was a Radial Basis Function (RBF).  
The SVMs were optimized using 10-fold cross-validation and a Bayesian optimization process. Bayesian optimization is a technique used to fine-tune the model's hyperparameters, which is a critical step since the model's accuracy heavily depends on selecting the correct hyperparameters. This iterative algorithm minimizes an objective function by creating a probability model, also known as a _surrogate function_, which is easier to optimize than the original target function. At each iteration, the next point to evaluate is selected based on previous evaluations of the surrogate function, limiting the exploration of unpromising hyperparameters and reducing the search space. In this case, the target function to be optimized is the cross-validation error (\(CVE\)) of the SVM, with the goal of finding the best set of hyperparameters that minimize error and maximize accuracy. Given \(y_{i}\) as the true label and \(\hat{y}_{i}\) as the label estimated by the classifier, the \(CVE\) is formulated as follows:  
\[CVE=\frac{1}{N}\sum_{i=0}^{N}L(y_{i},\hat{y}_{i})\ \ \textit{where}\ \ \ L(y_{i},\hat{y}_{i})=\begin{cases}0,&if\ y_{i}=\hat{y}_{i}\\ 1,&\textit{otherwise}\end{cases} \tag{2}\]  
Let \(p\) represent the set of hyperparameters to tune in the SVM, and denote the \(CVE\) as a function of these hyperparameters, \(CVE(p)\). In Bayesian optimization, a Gaussian process is initialized as the surrogate function for the \(CVE\). The final component required for this process is the acquisition function, (\(p\)), which is used to select the hyperparameter values to evaluate at each iteration of the optimization. The chosen acquisition function is the Expected Improvement (\(EI\)), meaning that the next hyperparameter values to be evaluated are those that are expected to improve the target function the most. Letting \(f^{*}(p)\) denote the surrogate function, (\(p\)) the objective function, \(p\) the hyperparameters at the current iteration, and \(p_{-}\) the hyperparameters from the previous step, the \(EI\) is formulated as follows:  
\[a(p)=EI(p)=E[\max(0,f^{*}(p)-f(p_{-}))], \tag{3}\]  
where \(E[x]\) is the expectation operation.  
The workflow of the Bayesian optimization algorithm is depicted in Figure 3.  
Once all the binary SVMs were trained and optimized, they were combined into a single model for multi-class classification. In this phase, the model was tested using the test set. For this type of model, classification works as follows: when a new, unknown observation is presented to the model, it is classified by all 36 binary classifiers, and the final class is determined using a majority vote technique. Each classifier votes for a class, and the class that receives the most votes is selected as the output by the multi-class model (Figure 4).  
Figure 3: Workflow of the Bayesian optimization algorithm.