# Reducing GPS Error for Smart Collars Based on Animal's Behavior
## 2 Materials and Methods
### Behavior Based Algorithm
#### 2.3.1 Physical Activity Classification  
The physical activity classification is one of the essential techniques of the current study. The previous research classification method is used for the current study. Table 1 shows the five classified goat activity behaviors from our previous study. For an individual goat, 10-dimensional raw data acquired from the smart collar, including six-dimensional data of the accelerometer sensor: accelerometer data: \(x_{accx}(t)\), \(x_{accy}(t)\), \(x_{accz}(t)\), gyro data: \(x_{gyrox}(t)\), \(x_{gyrox}(t)\), \(x_{gyrox}(t)\), a and the four-dimensional quaternion raw data [28]: \(x_{quatx}(t)\), \(x_{quaty}(t)\), \(x_{quatz}(t)\), \(x_{quatx}(t)\) (they are x, y, z-axis and w-rotation amount). The quaternion plays the most crucial role in distinguishing between the five considered goat behaviors. The four-dimensional quaternion calculation supported by the I2 Cdevelib Arduino library [29]; (as shown in Equation (1)). \begin{table}
\begin{tabular}{c c} \hline \hline
**Class** & **Description** \\ \hline Standing & A goat is normally standing \\ Walking & A moving goat taking steps with head in an upright position \\ Running & A faster-moving goat with frequent body shakes \\  & The goat’s head is tilted downward and positioned near the ground. \\ Grazing & The goat is either eating or searching for pasture \\  & A goat laying down \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Activity classes: the five goat activities described in this study were, standing, walking, running, grazing, and laying. Figure 2: The proposed algorithm of the algorithm for reducing GPS error. Research data analysis is accompanied by receiving raw data stage to classify the activities of the goat. Animal behavior is classified using the real-time SVM prediction model. Finally, the method decides to create a new correct position. The 10-time series were combined for classification:  
\[X(t)=\left[x_{accr}(t),\ x_{accr}(t),\ x_{accz}(t),x_{gyrax}(t),\ x_{gyray}(t),\ x_{gyraz}(t),x_{gyraz}(t),x_{guitar}(t),\ x_{gauty}(t),\ x_{gutaz}(t),\ x_{gututu}(t)\right] \tag{1}\]  
where \(X(t)\) is an array of the 10-time series at a particular time sample index \(t\). A machine learning algorithm called the SVM classifier was used to classify goat's activity in real-time. SVM-classification was used because it copes well with small and unbalanced data. SVM is a classifier used for classification and regression analysis tasks. It belongs to the family of linear classifiers and can also be considered as a special case [30; 31]. As a result, the liner classification algorithm can be written as shown in Equation (2):  
\[\mathrm{d}(\mathrm{w},\ \mathrm{x},\ \mathrm{b})=\ <w\cdot x>+b=\sum_{i=1}^{S}w_{i} \cdot x_{i}+b, \tag{2}\]  
where \(S\) is the number of the Support Vector, \(x\) is an object space of feature vector, \(w\) is a normal vector to the separating hyperplane, \(b\) is an auxiliary parameter. The linear classifier tends to show high performance if the feature vector is classified as linear. However, our classification data is multidimensional. It can be better classified using nonlinear classification methods. In this case, the Kernel Trick technique was used to classify goat behavior using multidimensional data. So, in our previous study, we used the RBF kernel to classify the activities of goats [22; 25]. Using the Radial Basis Function (RBF) kernel-based SVM classification, we could obtain sufficiently good results in the previous study.