## 7 Design of an Artificial Neural Network Classifier for Mode Detection  
The characteristics of GPS data streams vary depending on the transportation mode in which the smartphones are located. In this paper, a pattern classification approach is adopted to identify the mode based on the characteristics of data streams from various sensors and mode availability layer. In its most general form, a typical neural network (NN) consists of multiple layers of neurons, connection weights among neurons, and associated nonlinear transfer functions within neurons. Multi-layer perceptrons (MLP) [27] have been used in the proposed ANNs. More specifically, one-hidden-layer MLP ANNs with McCulloch-Pitts (M-P) (Marsalli, M., McCulloch-Pitts Neurons, [[http://www.mind.ilstu.edu/curriculum/modOverview.php?modGUI=212](http://www.mind.ilstu.edu/curriculum/modOverview.php?modGUI=212)]([http://www.mind.ilstu.edu/curriculum/modOverview.php?modGUI=212](http://www.mind.ilstu.edu/curriculum/modOverview.php?modGUI=212))) processing elements are used. The MLP is the most common supervised learning ANN. Supervised learning refers to the case where there are input and output pairs of data for training the network. For the mode identification, the input of GPS data used include speed, acceleration, and the average number of satellites in view, while the output includes the corresponding mode of transportation. If the mobile device or the server can store (and transmit) both current and a few recent GPS readings, the additional past speed and acceleration values can also be the input to the ANN to possibly improve the detection accuracy. The ANN maps each set of input data to the most probable mode. The training process adjusts connection weights between neurons as an entire set of training input data, also known as an epoch, is repeatedly passed through the network. All ANNs used in this paper consist of three layers of neurons connected in a feed-forward fashion, trained with the well-established, error-back-propagation algorithm. Depending on the specifics of each scenario, the number of inputs ranges from six (DL with two pings) to 220 (MAGIS with 20 pings) and the number of output classes is either seven (auto, bus, truck, tram, walk, bike, boat) or two (auto or non-auto). Seven output classes are used for classifying individual modes; i.e., auto, bus, truck, tram, walk, or bike. Two output classes are used when the classification is for auto vs. non-auto modes. As shown in Figure 5, the number of input variables varies depending on the monitoring duration and number of pings (\(n\)) per unit of time (as indicated as \"Ping \(n\)\" in Figure 5) in each scenario. For example, if the monitoring duration is 10 min and the number of pings or queries is 10 in that duration (one ping per minute), there are 10 speed values, 10 acceleration values, and 10 values for the number of satellites in view. Hyperbolic tangent functions are used as the nonlinear transfer functions in the M-P PEs (McCulloch-Pitts processing elements). The number of neurons (nodes) in the hidden layer is varied as 5, 10, 20, and 30. For different scenarios, different numbers of hidden nodes have been used, depending on the number of input variables and output classes. As a rule of thumb, having too many hidden nodes forces the NN to memorize the input-output training data, and leads to poorer generalization. Having too few hidden nodes, on the other hand, gives the NN difficulties in identifying and isolating the different classes. Therefore, it is desirable to keep the number of hidden nodes to a minimum without sacrificing the discriminating power. From the 110 h of collected data, for each scenario of data logger (DL), smartphone (SP), and smartphone with mode availability GIS (MAGIS), the entire set of data are shuffled randomly first. Then, 60% of the data are used to train the network and the remaining 40% are used for the validation process as unseen data.