<p>Many data scientists (and even statisticians) often suffer under one of the following misapprehensions:</p>
<ul>
<li>They believe a technique doesn’t work in their current situation (when in fact it does), leading to useless precautions and missed opportunities.</li>
<li>They believe a technique does work in their current situation (when in fact it does not), leading to failed experiments or incorrect results.</li>
</ul>
<p>I feel this happens less often if you are working with observable and composable tools of the proper scale. Somewhere between monolithic all in one systems, and ad-hoc one-off coding is a <a rel="nofollow" href="https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two" target="_blank">cognitive sweet spot</a> where great work can be done.</p>
<p><span></span></p>
<p>For a whole system to be correct our modeling problem and data must match all the assumptions of all of the pieces simultaneously. In a monolithic system if one component can’t handle co-linear variables or imbalanced classes, then the whole system cannot work in such cases. In a modular system one can change the objective function (say introduce regularization) and the optimizer independent of the model specification to fix such issues.</p>
<p>We also do not want the opposite situation of an explosion of unmaintained hand-rolled ad-hoc or “from scratch” systems. In this case projects keep repeating (like the movie Groundhog Day) and you are continually using re-invented, un-documented, and untested wheels.</p>
<p>We should prefer re-usable components of appropriate scope and scale that we can inspect, substitute, and re-compose as we like. Some examples:</p>
<ul>
<li>Model optimality conditions should be separated from the model optimizer/solver/fitter: so we that we can substitute in high power optimizers. Many models (such as logistic regression) have <a rel="nofollow" href="http://www.win-vector.com/blog/2011/09/the-simpler-derivation-of-logistic-regression/" target="_blank">beautiful mathematical structure</a>, but often come locked in with their own optimizer (such as Newton’s method or iteratively re-weighted least squares in the case of logistic regression). This prevents us from substituting out other optimizers and extending such models to allow regularization or coefficient non-negativity constraints. It also prevents easily changing to optimizers that may be appropriate for large data (such as stochastic gradient methods).</li>
<li>Model evaluation and fit stability/significance evaluation should not be locked into the solver. In <a rel="nofollow" href="https://cran.r-project.org/" target="_blank">R</a> the <code>lm</code> and <code>glm</code> fitters return detailed summaries including fit quality, (sometimes) model significance, and variable significance. It would actually be much better if we used a standard method to evaluate all of these so we would have the same set of tests as we switched modeling methods, or could switch to tests that are more appropriate to our problem domain. This is why in our book (<a rel="nofollow" href="http://www.practicaldatascience.com/" target="_blank">Practical Data Science with R</a>) we spend significant time showing how to re-compute these summaries from the predictions alone, after modeling. We have productionized and packaged many of the methods in the R package <a rel="nofollow" href="https://winvector.github.io/sigr/" target="_blank">sigr</a>. Systems like <a rel="nofollow" href="http://arxiv.org/abs/1602.04938" target="_blank">LIME</a> (also <a rel="nofollow" href="https://cran.r-project.org/web/packages/lime/index.html" target="_blank">available in R</a>) represent attempts to generate explanations and variable importances independent of the model.</li>
<li>Variable preperation and treatment should be packaged (as we document and promote in the R <a rel="nofollow" href="https://cran.r-project.org/package=vtreat" target="_blank">vtreat package</a>). Automating the important mechanical steps (dealing with missing values and high cardinality categorical variables) leaves more time for important domain specific data inspection and preparation steps. Also using <a rel="nofollow" href="https://arxiv.org/abs/1611.09477" target="_blank">well documented</a> tools for these steps can greatly shorten your own paper’s methods section.</li>
<li>Visualization should be packaged in re-usable teachable graphical schemes (as we promote in the R <a rel="nofollow" href="https://github.com/WinVector/WVPlots" target="_blank">WVPlots package</a>). All visualizations have to be taught before they are understood, so it makes sense to start re-using them.</li>
</ul>
<p>Basically we want to be playing with a moderate number of powerful blocks.</p>
	<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/t_uqRyOraA4" height="1">