**Appendix B**

From Algorithm 2, in lines 3 to 10 it is compared the modeled and historical speed category (from *w*<sup>1</sup> and *w*2), with the historical from *w*3, to determine which is *Procedure to Prepare and Model Speed Data Considering the Traffic Infrastructure, as Part… DOI: http://dx.doi.org/10.5772/intechopen.88280*

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 the greater score, *H*<sup>2</sup> or *H*1, is the selected to predict the speed category.
