# Device-Free Crowd Size Estimation Using Wireless Sensing on Subway Platforms
## 4 Materials and Methods
### Vehicle Detection  
In order to know which combination of sensor nodes and estimation model we need to use for people counting, we need to be able to detect whether a vehicle is present in the environment or not. By using the links crossing the rail bedding or close to it, we obtain a strong correlation between the presence of a rail vehicle and the measured signal strength. This allows us to perform binary classification using a logistic regression model. The advantage of using a simpler model for detection, such as a logistic regression model, is that it allows for training the model using a limited amount of data and reduces the risk of overfitting the model to specific unrelated environmental factors. However, this requires a careful selection of links, as a strong correlation needs to be present based on the user's manually selected virtual sensor network. When collecting ground-truth data, timestamps of the arrival and departure of rail vehicles were stored. The collected attenuation data within this time span are labeled as \"present\", while samples outside of the spans when no rail vehicle was present are labeled as \"not present\". This binary labeling of samples allows for the training of a binary classification model:  
\[\hat{y}=\sigma(w_{2}\mathbf{\hat{a}}^{2}+w_{1}\mathbf{\hat{a}}+b)\quad with \quad\sigma(x)=\frac{1}{1+e^{-x}} \tag{1}\]  
The model that is used is shown in Equation (1). In this mathematical representation, \(\mathbf{\hat{a}}\) is the input variable and is the arithmetic mean attenuation of the links of the virtual sensor network in dB. \(w_{2}\), \(w_{1}\), and \(b\) are the parameters of the model, namely, the curvature (or 2 nd-order weight), slope (or 1 st-order weight), and intercept (or bias), respectively. A sigmoid function \(\sigma\) is applied after the quadratic scaling of the input variable as defined, resulting in an output between 0 and 1. The output of the sigmoid function \(\hat{y}\) represents the predicted likelihood of the presence of a rail vehicle. This predicted likelihood can be rounded to the nearest integer when deployed in order to obtain the predicted label. Figure 4: This figure shows the block diagrams of our used baseline method (**a**) and our proposed method (**b**). The model was implemented using the _LogisticRegression_ and _PolynomialFeatures_ classes provided by the scikit-learn Python library [26], which provide an established implementation for the logistic regression model and polynomial feature transformation, respectively. When evaluating this model on the test set, we used two different metrics to measure the accuracy of the trained model. The first metric we used is a sample-based comparison between the labeled samples in the test set and the labels for the same samples predicted by our trained model. The second metric is an event-based comparison between the ground-truth spans (\"entering\" and \"leaving\" timestamps) and spans derived from the sample-based predictions, taking the timestamps from the first and last samples in which a vehicle was predicted. The metric comprises two values: \"false positives\" and \"misses\". In order to calculate the false positives, we compare, for every predicted span, whether there is an overlap with the ground-truth span, and if this is not the case, we increment the false positive count. When there is an overlap, we associate the ground-truth span with the predicted span. We only allow a single association per ground-truth span, so if a prediction span is broken into two spans, the false positive value will be incremented as well. In order to calculate the misses, we determine, for every ground-truth span, whether there is any overlap with a predicted span. If none of the predicted spans overlaps with the current ground-truth span, it is counted as a \"miss\". We trained the model on approximately one hour of ground-truth data containing 25 vehicles. This corresponds to 366 samples, of which 242 samples are labeled 0 and 124 samples are labeled 1.