# Environmental-Based Speed Recommendation for Future Smart Cars +
## 3 Proposed Approach
### Road Status Estimation Based on Weather Information
#### 3.2.1 Data Analysis for Road Condition Estimation
Assuming that \(D\) is the gathered training dataset with \(N\) attributes, the IG of splitting the dataset with the attribute \(i\) is calculated as:  
\[IG(D,i)=Entropy(D)-Entropy(D,i)=Entropy(D)-\sum_{k=1}^{l}\frac{|D_{k}|}{|D|} \cdot Entropy(D_{k}), \tag{5}\]  
where \(Entropy(D)\) is the entropy of the original dataset and \(Entropy(D,i)\) is the average entropy of the produced subsets \(D_{1},D_{2},\cdots D_{l}\). From all the available attributes, we select the one that maximizes the difference of Equation (5). It should be noted that maximizing the IG is equivalent to minimizing the average entropy, since the term \(Entropy(D)\) has the same value for all attributes. The next step is to rank the attributes and decide which of them among the given set of training feature vectors are most useful for predicting the road status among the four classes (Dry, Wet, Snow and Ice). Table 1 presents the values of \(IG\) for all the weather attributes gathered throughout the year. Specifically, Table 1 presents that the most important information is provided by temperature, whereas the least important comes from gust wind. Based on the IG values, we choose to keep the first six weather attributes. Then, we build the desired classification tree, which takes as input all the weather attributes and estimates the road class (Dry, Wet, Snow and Ice). We reduce the number of attributes that the classification tree uses based on the calculated \(IG\). In this way, we drop the complexity of the classification and training, eliminate redundant information, and avoid over-fitting. The creation of the classification tree is presented in Algorithm 1. Given the input data set \(D\) and the pruned set of attributes \(A\), the classification tree checks if the set \(D\) is homogeneous (lines 5-7). This is true if the majority of the instances of the current set belongs to a single class. If the initial data set \(D\) is not homogeneous, then, for each \(a\in A\), the original set \(D\) is split into subsets \(D_{1,2,3,..l}\). The algorithm selects the split that gives the most pure subsets, using the concept of Impurity, which is the corresponding decision boundary that terminates the recursive split of the original data set. The classification tree splits the \(k^{th}\) subset \(D_{k}\) into \(l\) sub-sets (line 10) and selects the attribute that produces the minimum Impurity (lines 11-16). This procedure is repeated recursively until the _majority_ is reached (lines 21-23), which is the minimum purity threshold that is accepted for a node. Unless this threshold is satisfied, the algorithm continues to split current set into sub sets, until the _max_depth_ is reached (lines 17-18). ```
1:Input: data D,set of attributes A, majority, max_depth
2:Output: tree T with labeled levels
3:depth \(\leftarrow\) 0
4:GrowTree(D,A,max_level,majority,max_depth)
5:if\(Homogeneous(D,majority)\)then
6:return Label(D)
7:endif
8:for each \(i\)do
9:\(I_{min}\gets 1\)
10: Split D into subsets \(D_{1},D_{2},...,D_{l}\)
11:for each \(a\in A\)do
12:if\(Impurity(\{D_{1},...,D_{l}\})<I_{min}\)then
13:\(I_{min}\gets Impurity(\{D_{1},...,D_{l}\})\)
14:\(a_{best}\gets a\)
15:endif
16:endfor
17:if\(depth>max\_depth\)then
18: break
19:else if\(D_{i}\
eq\emptyset\)then
20:\(T_{i}\gets GrowTree(D_{i}\), \(A\), majority, max_depth)
21:else
22:\(depth\gets depth+1\)
23:\(T_{i}\) is a leaf with Label(\(D\))
24:endif
25:endfor
26:endfor
27:return tree with root S and children \(T_{i}\)
```  
**Algorithm 1** Classification Tree Algorithm. \begin{table}
\begin{tabular}{c c} \hline \hline
**Attributes** & **Information Gain** \\ \hline Temperature (C) & 0.690 \\ Dew Point & 0.415 \\ Wind chill & 0.414 \\ Humidity (mm) & 0.308 \\ Elevation (m) & 0.289 \\ Precipitation (mm) & 0.283 \\ Snow & 0.147 \\ Precipitation history (mm) & 0.120 \\ Rain & 0.092 \\ Snowfall(mm) & 0.043 \\ Snow depth (mm) & 0.030 \\ Gust Wind & 0.013 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Information gain of input attributes.