<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/nyc-buses-cubist-regression-with-more-predictors/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datascienceplus.com/nyc-buses-cubist-regression-with-more-predictors/"> R Programming – DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<ul></ul>
<p><strong>
<p>Categories</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/category/advanced-modeling/" title="Permanent Link toAdvanced Modeling" target="_blank">Advanced Modeling</a></li>
</ol>
<p><strong>
<p>Tags</p>
<p></p></strong>
<ol>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/data-management/" title="Permanent Link toData Management" target="_blank">Data Management</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/linear-regression/" title="Permanent Link toLinear Regression" target="_blank">Linear Regression</a></li>
<li><a rel="nofollow" href="https://datascienceplus.com/tag/rstats/" title="Permanent Link toR Programming" target="_blank">R Programming</a></li>
</ol>
<p>We have previously <a rel="nofollow" href="https://datascienceplus.com/nyc-buses-company-level-predictors-with-r/" target="_blank"> added a set of company identity-agnostic predictors</a>, such as the number of drivers a company employs, or the number of vehicles in the fleet with a hydraulic lift, and so on. we took this approach, rather than having each company as a unique predictor, so that the addition of a new contractor would not (necessarily) confuse our model. </p>
<p>I understand that this means company history, specific vehicle history, and so on, are not included. Nevertheless, we want to see how much information is in the new predictors.</p>
<h2>Data exploration</h2>
<pre><code>in_csv &lt;- &quot;../output/intermediate/ii_times.csv&quot;
ii_times &lt;- read_csv(in_csv) %>%
  filter(reported_before_resolved == 1) %>% #we kept these flags for exploration, but they are troublesome for our real prediction. If we know a case has already been resolved, our model looks better than it is at predicting delays.
  mutate(reported_before_resolved = NULL)

#first we look at the correlation of the predictors with the time_delayed:
corrr_analysis &lt;- ii_times %>%
  select(-Busbreakdown_ID) %>%
  correlate() %>%
  focus(time_delayed) %>%
  rename(feature = rowname) %>%
  arrange(desc(abs(time_delayed))) %>%
  mutate(feature = as_factor(feature)) 
corrr_analysis %>% print(n=61)</code>
<em>## # A tibble: 45 x 2
## feature time_delayed
## </em></pre>