This is much more complicated than needed. Following the Hacker’s Diet [0] is simple to understand and sufficient, and yes, heed common-sense things like good sleep, some basic exercise, stress reduction, and eating healthy food.
One graph I have that I don't see on there is average-calories-per-day on the X axis and weight-change-per-week on the Y axis (scatter plot). Sticking a linear regression on top told me all those online estimators for how many calories you burn in a day are just wrong, at least for me.