Optimal Invariant Bases for Atomistic Machine Learning