Compositionality And Functorial Invariants In Machine Learning