**3.3 Discussion**

A series of steps are employed in a numerical example that, in combination, constitute a new method for speed prediction. The first step, *street segmentation*, divides an avenue in such a way that distributes different traffic elements on different segments. These elements are number of speed bumps, traffic lights, and landmarks, which in turn leads to different speed behavior on each segment. The second step, *clustering*, selects intervals which better fit the travel speed observed, resulting in three categories. Depending on the segment, most of the speed data (approximately at least 80%) is within a specific cluster (category). For example, we infer that the speed behaviors in *s*<sup>2</sup> and *s*<sup>5</sup> are similar, since most of the speeds for both fall inside cluster 1. Moreover, speed behaviors of *s*<sup>0</sup> and *s*<sup>3</sup> are dissimilar, since most of the speeds belong to different clusters (3 and 1, respectively). In the third step, *comparative analysis of histograms*, we corroborate that for each segment, the


**Table 7.** *Algorithm 2: threshold values and w*<sup>3</sup> *prediction results.* *Procedure to Prepare and Model Speed Data Considering the Traffic Infrastructure, as Part… DOI: http://dx.doi.org/10.5772/intechopen.88280*

speed behavior is related to the traffic elements involved. It was observed that the speed histograms of two segments get a low Chi-Square distance if the segments share approximately the same number of speed bumps, traffic lights, and landmarks, independent of the day of the week. A high Chi-Square distance implies the opposite situation, i.e., segments with different number of traffic elements. The fourth step, *outlier detection*, removes atypical speed behavior, e.g., a vehicle circulating slower or faster than the usual. In step five, *mathematical models*, the models explain the speed. From steps 2 and 3, it is already known that on each segment, speed behaves according to the traffic elements involved, and hence the speed data of each segment is modeled independently with a polynomial model, with time as the independent variable. The multinomial logistic model uses as independent variables the number of speed bumps, traffic lights, the time, and two weights. The weights are calculated based on the average of the measured travel speeds considering segments and days. Finally, in step 6, *connecting Intel with users*, the drivers are properly informed about the travel speed expected on the surrounding segments, helping them to continuously adjust their route.

### **4. Conclusions**

difficult to satisfy the condition *Pq*ð Þ*i* ≥*threshold*, and then the positive prediction also drops because now the set *H*2ð Þ*i* (with the limitation mentioned before) contributes more. **Table 7** shows the percentage of speed data categorized correctly

A series of steps are employed in a numerical example that, in combination, constitute a new method for speed prediction. The first step, *street segmentation*, divides an avenue in such a way that distributes different traffic elements on different segments. These elements are number of speed bumps, traffic lights, and landmarks, which in turn leads to different speed behavior on each segment. The second step, *clustering*, selects intervals which better fit the travel speed observed, resulting in three categories. Depending on the segment, most of the speed data (approximately at least 80%) is within a specific cluster (category). For example, we infer that the speed behaviors in *s*<sup>2</sup> and *s*<sup>5</sup> are similar, since most of the speeds for both fall inside cluster 1. Moreover, speed behaviors of *s*<sup>0</sup> and *s*<sup>3</sup> are dissimilar, since most of the speeds belong to different clusters (3 and 1, respectively). In the third step, *comparative analysis of histograms*, we corroborate that for each segment, the

*Threshold* **Prediction (%)** 0.75 81.69 0.80 83.10 0.85 85.62 0.90 84.24 0.95 83.97

with different threshold values.

*Sustainability in Urban Planning and Design*

*Time vs. speed: data of s*<sup>0</sup> *and w*3*.*

**3.3 Discussion**

**Figure 7.**

**Table 7.**

**118**

*Algorithm 2: threshold values and w*<sup>3</sup> *prediction results.*

The procedure presented in this chapter proposes street segmentation; on each segment, there are traffic elements that we infer may be related with the observed speed frequency. By comparing speed histograms, we found that the speed frequency of all segments is similar among weekdays, and then the speed frequency of a specific segment is similar regarding the day. Considering the speed frequency of all weekdays, and individual segments, the segments with different traffic elements (speed bumps, traffic lights, and landmarks) yield dissimilar traveling speeds. From this observation, two techniques were considered for modeling speed: (1) polynomial regression, where the data of each segment is modeled independently, using time as the independent term, and (2) logistic regression, with several independent variables—number of speed bumps and traffic lights, time, and two weights (from the observed speeds on street segments and weekdays). The models were implemented in algorithms, which use the modeled and historical data. With the polynomial model and Algorithm 1, it was possible to categorize correctly the travel speed in the range from 85.2 to 96.5%, depending on the segment. The multinomial logistic model and Algorithm 2 correctly predict the speed category in 90.09% of the evaluated cases. With these results, we conclude that the proposed procedure is suitable to prepare and model speed data and then to predict the speed category at a low computer processing cost. The procedure is useful to establish the relationship between traffic infrastructure and travel speed.

#### **4.1 Future work**

We contemplate as future work the development of the architecture to communicate the expected travel speed (obtained with the proposed procedure) with the users, as well as convert this knowledge in suggestions and decision-making.

### **Appendix A**

In Algorithm 1, if *i*≤*deep* (line 3), the modeled speed of *w*<sup>1</sup> and *w*<sup>2</sup> contributes the same (each multiplied by 0.5). The case *i* ≥*deep* þ 1 (line 6) enables the

estimation of *y i*ð Þ � 1 and *y i*ð Þ with known data from *w*3. Variables *h*<sup>1</sup> and *h*<sup>2</sup> (see lines from 9 to 14) store the average of the absolute difference between historical and modeled data, from *w*<sup>1</sup> and *w*2, respectively*. h*<sup>3</sup> (line 15) stores the absolute difference of the historical and estimated data, from *w*<sup>3</sup> and index *i-1*. The condition in line 16 verifies that the *y i*ð Þ � 3 to *y i*ð Þ � 1 speeds are nonempty, i.e., available. *h*1…*h*<sup>3</sup> are normalized and converted to weights, named *W*1…*W*3. Because *h* carries the error, a greater *h* results in a smaller *W*, and so forth. In line 18, the predicted speed is calculated using the weights, the modeled speed with *w*<sup>1</sup> and *w*2, and the estimation with previous data of *w*3. If the condition in line 16 is not true, then in line 21 the speed prediction is calculated with the modeled data and new weights, without the *w*<sup>3</sup> data.

the accurate. The number of hits of the model and the historical (for weeks 1 and 2) is stored in *score* with sub-index from *1* to *4,* for the four cases. In line 12, if the probability *P*2ð Þ*i* is greater or equal than the selected *threshold* and, if *score*<sup>2</sup> ≥ *score*1, then *S*2ð Þ*i* is the predicted speed category. In line 14, if *P*1ð Þ*i* ≥ *threshold* and, if *score*<sup>1</sup> ≥*score*2, then the predicted speed category is *S*1ð Þ*i* . If previous conditionals (line 12 and 14) are not evaluated to true, in lines from 16 to 18, the historical with

*Procedure to Prepare and Model Speed Data Considering the Traffic Infrastructure, as Part…*

the greater score, *H*<sup>2</sup> or *H*1, is the selected to predict the speed category.

*Initial conditions*: *score*<sup>1</sup> = 0; *score*<sup>2</sup> = 0; *score*<sup>3</sup> = 0; *score*<sup>4</sup> = 0;

**Algorithm 2**

2.*if i*>1

11.*end if*

19.*end if* 20.*end if* 21.*end for*

**121**

threshold ∈ [0.75,0.95];

1.*for i* ¼ 1 *to i* ¼ *N*

8.*score*<sup>3</sup> þ þ*; end if*

10.*score*<sup>4</sup> þ þ*; end if*

13.*S*3ðÞ¼ *i S*2ð Þ*i ; else*

15.*S*3ðÞ¼ *i S*1ð Þ*i ; else* 16.*if score*<sup>4</sup> ≥ *score*<sup>3</sup> 17.*S*3ðÞ¼ *i H*2ð Þ*i ; else* 18.*S*3ðÞ¼ *i H*1ð Þ*i ; end if*

3.*if H*3ð Þ ¼¼ *i* � 1 *S*1ð Þ *i* � 1 4.*score*<sup>1</sup> þ þ*; end if*

*DOI: http://dx.doi.org/10.5772/intechopen.88280*

5.*if H*3ð Þ ¼¼ *i* � 1 *S*2ð Þ *i* � 1 6.*score*<sup>2</sup> þ þ*; end if*

7.*if H*3ð Þ ¼¼ *i* � 1 *H*1ð Þ *i* � 1

9.*if H*3ð Þ ¼¼ *i* � 1 *H*2ð Þ *i* � 1

12.*if P*ð <sup>2</sup>ð Þ*i* ≥ *threshold* ∧ ð Þ *score*<sup>2</sup> ≥*score*<sup>1</sup>

14.*if P*ð <sup>1</sup>ð Þ*i* ≥*threshold* ∧ ð Þ *score*<sup>1</sup> ≥*score*<sup>2</sup>

#### **Algorithm 1**

```
Initial conditions: deep = 3;
 1.for k ¼ 0 to k ¼ 7
 2.for i ¼ 1 to i ¼ Nk
 3.if i ≤deep
 4.^y iðÞ¼ M1
            kð Þi ∗ 0:5 þ M2
                          kð Þi ∗ 0:5
 5.end if
 6.if i ≥deep þ 1
 7.y ið Þ¼ � 1 y ið Þþ � 2 ð Þ y ið Þ� � 2 y ið Þ � 3
 8.y iðÞ¼ y ið Þþ � 1 ð Þ y ið Þ� � 1 y ið Þ � 2
 9.h1 ¼ 0; h2 ¼ 0;
10.for j ¼ 1 to j ¼ deep
11.h1 ¼ h1 þ y ið Þ� � j M1
             kð Þ i � j 

12.h2 ¼ h2 þ y ið Þ� � j M2
             kð Þ i � j 

13.end for
14.h1 ¼ h1=deep ; h2 ¼ h2=deep
15.h3 ¼ j j y ið Þ� � 1 y ið Þ � 1
16.if y ið Þ � 1 ∉∅ ∧ y ið Þ � 2 ∉∅ ∧ y ið Þ � 3 ∉ ∅
17.h1 ¼ h1
        h1þh2þh3
               ; h2 ¼ h2
                      h1þh2þh3
                             ; h3 ¼ h3
                                    h1þh2þh3
                                           ; W1 ¼ 1�h1
                                                   1�h1þ1�h2þ1�h3
                                                                 ;
   W2 ¼ 1�h2
          1�h1þ1�h2þ1�h3
                       ; W3 ¼ 1�h3
                               1�h1þ1�h2þ1�h3
18.^y iðÞ¼ M1
            kð Þi ∗W1 þ M2
                          kð Þi ∗W2 þ y ið Þ ∗W3
19.else
20.h1 ¼ h1
        h1þh2
             ; h2 ¼ h2
                   h1þh2
                        ; W1 ¼ 1 � h1; W2 ¼ 1 � h2;
21.^y iðÞ¼ M1
            kð Þi ∗W1 þ M2
                          kð Þi ∗W2
22.end if
23.end if
24.end for
25.end for
```