## 2 Real-Time Intelligent Embedded Learning System
### Knowledge Processing Unit  
The first step in the knowledge processing unit (KPU) involves data cleaning. Multiple datasets are combined; hence an associated noise is present in the dataset, which is removed before data analysis has proceeded. The predictive models were developed through deep learning with neural network classifiers. The final input data was randomly divided into three categories of training, validation, and testing, in the ratio of 6.5:3.0:0.5. For the network to develop accurate prediction properties, this is the recommended division [29]. Such division guarantees adequate data for the network to learn correctly, evaluate the trained model, and apply the generated models to untrained circumstances. Bernoulli distribution was utilised to ensure that the data were divided randomly. Two different models (each for male and female) were constructed using the following input infrastructure variables (Table 1). The output variables of the model are described in Table 2.  
The following network structure was used to construct the model (Table 3). The following four-step iterative learning process mapping input with the output variables was used. Figure 1: Real-time intelligent embedded learning system. \begin{table}
\begin{tabular}{c c c} \hline \hline
**No.** & **Input Variable** & **Values** \\ \hline (a) & Type of road & Dual carriageway, one-way street, roundabout, single carriageway, slip road \\ (b) & Speed limit & 20–70 \\ (c) & RC 1 & A, B, C, E, U \\ (d) & R\({}_{\rm HL}\) & 0–4 \\ (e) & R\({}_{\rm HLD}\) & \(-4\) to 4 \\ (f) & Junction Detail & Crossroad, mini roundabout, multiple junction, straight road, roundabout, slip road, T or staggered, private drive \\ (g) & Junction Control & No control, traffic signal, give way or uncontrolled, stop sign \\ (h) & RC 2 & A, B, C, E, U \\ (i) & Vehicle Manoeuvre & Changing lanes, going ahead, moving off, overtaking, parked, reversing, slowing/stopping, turning, U-turn, waiting to go ahead, waiting to turn \\ (j) & Vehicle Junction Location & Approaching junction or waiting/parked at junction exit, cleared junction or waiting/parked at junction exit, entering, leaving, mid junction, straight road (not at or within 20 m of the junction) \\ (k) & Road Location of vehicle & Bus lane, busway, cycle lane, cycleway, footpath, on layby or hard shoulder, main carriageway, tram/light rail track \\ (l) & Skidding and Overturning & No skidding or overturning or jack-knifing, overturned, skidded, overturned and skidded \\ \hline \multicolumn{3}{c}{**Output Variable**} & **Risk gender and Age Group** \\ \hline \multicolumn{3}{c}{where RC = road class, R\({}_{\rm HL}\) = road hierarchy level, and R\({}_{\rm HLD}\) = road hierarchy level and direction change.} \\ \end{tabular}
\end{table} 
Table 1: Input variable for the proposed model. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline  & \multicolumn{8}{c}{**Output Variable**} \\ \hline
0–16 F & 17–20 F & 21–29 F & 30–39 F & 40–49 F & 50–59 F & 60–69 F & 70+ F \\ \hline \hline \end{tabular} where M = male, and F = female.  
\end{table} 
Table 2: Output variable. Figure 2: The overview of the (a) cyclist flow cameras and (b) motor vehicle cameras in the study area. **Step 1:** Random weights and activation. Firstly, between each connection, i.e., input and hidden, within hidden layers, and hidden and output layer, random weights were assigned. For signal transmission between the synaptic cleft activation function 'Hyperbolic tangent' Equation (1) for hidden layers and 'Softmax' Equation (2) for the output layers were used. \[F_{\in}=\tanh(A_{\in})=\frac{e^{A_{\in}}-e^{-A_{\in}}}{e^{A_{\in}}+e^{-A_{\in}}} \tag{1}\]  
\[\overline{F}_{\in}=\sigma(\overline{A}_{\in})=\frac{e^{\overline{A}_{\in}}}{ \sum_{l=1}^{j}\,e^{\overline{A}_{l}}} \tag{2}\]  
where \(F_{\in}\) is the activation of the \(\in\)_th_ output neuron, \(j\) is the number of output neurons. **Step 2:** Error modelling. Cross entropy error function was used to model the error between the output obtained and the desired output.