- Advanced Modeling
Tags
- Data Manipulation
- Machine Learning
- R Programming
- Tips & Tricks
We continue on from our previously loaded data of NYC bus delays. Although we are fairly sure that our target variable (time_delayed) is not accurate, it is all we have. We can thank the bus drivers of New York that we have anything at all, I suppose, but the inaccuracy of this variable is probably one of the reasons not very many people have touched this data set.
Data preparation
Some data preparation first. We have initially included the variable ‘time_diff_report’ in the ii main data set. This is the time between the incident and when the incident is called in to operations. The difficult with this number is that it is obviously included in the time estimate given for the breakdown. The time difference is only ever less than the breakdown time for cases which are reported after they are resolved. Obviously, this number can be used as a strong predictor, while also providing no useful predictive information for our real problem: working out how much longer the bus will be delayed. We correct all of this by subtracting this value from the delayed time, so that ‘time_delayed’ becomes the amount of time from after operations is called that the bus is delayed. We also remove cases which are resolved before they are reported.
1 |
|
Cross fold validation testing
Since I am running all of this locally on a laptop which ‘benchmarkme’ tells me is the slowest system to have been benchmarked in 2018, I build data set ‘ii_small’ to do cross-fold validation testing, with root mean square error as my target. During my run, I test different numbers of committees and rules. The numbers presented here are what I ended up with. Neighbours always degrade the solution in this case are fixed to zero. We can see the full rule set of the model by calling ‘summary’, but this results in a lot of spam. A more succinct presentation is available by looking at the ‘finalModel’ components of the derived model. ‘splits’ gives a list of the derived rules, where multiple entries per rule indicates an ‘AND’ condition (both conditions satisfied). ‘coefficients’ gives the resulting slope and intercept of the application of that rule. Finally, we can get a full listing of how many times a predictor appears in the ruleset and the coefficient set by looking at ‘usage’: this is somewhat equivalent to a variable importance call.
1 |
|
We can see that we haven’t done a very good job. We are mis-predicting pretty much everything. But that is fine, since we know that we have more predictors available that we have not yet joined to the data set: company and route level metadata. We also do not know whether a regression approach is really going to be useful with this data, and indeed, later on we will switch over to a two class classification problem, and simply look at whether a delay will be greater or less than a cut off time.
Related Post
- Visualization of NYC bus delays with R
- Explaining Black-Box Machine Learning Models – Code Part 2: Text classification with LIME
- Image clustering with Keras and k-Means
- ‘How do neural nets learn?’ A step by step explanation using the H2O Deep Learning algorithm.
- Machine learning: Logistic regression and decision trees for healthcare in R
Related