Coding Hygiene

Fewer models, fewer variables

  • One data frame for each unit of analysis. E.g.
    • Customer
    • Transaction
    • Item
  • One model for each considered dependent variable and features' set
    • Use the model that performs and suits the best
    • Leave only the model with the features' space that was finally used
  • Use longer pipes to avoid partial data.frames

We do not filter results until the very end

  • It’s hard to track results from the end till the beginning - leave filter statement to the very late end of modeling
  • Last filter statement is very useful as the introduction to the reporting stage

Use saved / intermediate results sparingly

  • Follow the How we name saved files at Gradient instructions
  • Always store raw, main and final results
  • For partial results try to store only those that require a lot of time to reproduce

Keep track of observations

  • Always be able to determine the filters applied to the considered data.frame
  • Keep track of the number of rows after filtering
  • Keep track of the number of rows after applying a join operation
  • Consider assertr and assertive packages to add verifications steps for above 2 points or use data verification functions in our g6tr package.

Everything should be contributing to a deliverable

  • Don’t merge branches that do not contribute to the final result
  • Alone model is not always enough - apply coefficients in convenient way to read with tables and plots that can be used

Code formatting