# 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  
Weather services provide a plethora of metrics that cover a variety of weather attributes. However, not all of these metrics affect road class in the same way. For that reason, in this work, we built a prediction model that is trained on gathered weather metrics and estimates the road status. Weather data and road condition information were gathered by cloud and Road Side Units (RSUs) and weather services for a period of one year covering various areas in the United States of America. Based on the desired location, we receive the current weather conditions at that particular location. All the values of the available weather attributes (temperature, humidity, precipitation and others) are recorded and further analyzed, as it is described in the following section. All of the gathered values are stored and form the training set \(D\) that is utilized in the experiments. In order to identify which weather parameters affect the road condition, we develop a classification tree that takes as input a set of attributes and decides in which class this input belongs to. Reducing the number of input attributes can drop the complexity of the classifier and also eliminate redundant information. In order to measure how pure are the subsets, we use _Impurity_ as a metric that quantifies how well the classes of our dataset are separated. **Example:** In order to define Impurity, we utilize the notation of \"positive\" and \"negative\" class. As an illustrative example, we consider a dataset that  
Figure 1: Overview of the proposed approach. contains two classes: one positive and one negative. The terms are conventional and the term \"positive\" corresponds to the important rare data, while \"negative\" corresponds to the non-important one. Let \(N_{pos}\) and \(N_{neg}\) denote the number of training samples that belong to the positive and negative classes at node \(x\), respectively. Moreover, \(N_{total}\) represents the total samples that belong to node \(x\). We wish to find the attribute that splits the dataset \(D\) into the purest subsets. Let  
\[p_{pos}=\frac{N_{pos}(node\_x)}{N_{total}(node\_x)},\quad p_{neg}=\frac{N_{neg }(node\_x)}{N_{total}(node\_x)} \tag{2}\]  
be the fraction of the positive and negative training samples that belong to the positive and negative class, respectively, in a given node \(x\). Thus, Impurity is a number between \([0,1]\) and it is not affected by the number of samples. Impurity takes its maximum value when the number of positive and negative samples are equal: \(N_{pos}=N_{neg}=\frac{N_{total}}{2}\implies p_{pos}=p_{neg}=0.5\). In this example, we use the metric _Entropy_ to calculate Impurity at a particular node \(x\):  
\[Entropy(node\_x)=-(p_{pos}\cdot log_{2}(p_{pos})+p_{neg}\cdot log_{2}(p_{neg} )). \tag{3}\]  
In a general case where training data can belong to any of \(j\) number of classes, we consider an attribute \(i\) that splits the set \(D\) into \(l\) subsets \(D_{1},D_{2},\cdots D_{l}\). We calculate the Impurity of the dataset \(D\) utilizing the metric _Entropy_ as follows:  
\[Entropy(D,i)=-\sum_{k=1}^{l}p(k)\cdot log_{2}p(k), \tag{4}\]  
where \(p_{k}=\frac{|D_{k}|}{|D|}\), \(k=1,2,\cdots l\), is the ratio of training examples classified as class \(j\) in each subset \(D_{k}\). We utilized different attributes to split the dataset and we observed different Impurity measures. Therefore, not all the attributes affect the estimation of the road class in the same way. In order to decide which are the most important features, we utilized the concept of _Information Gain_. Information Gain (IG) is a metric that marks how important a given attribute of the feature vectors is.