Some source code from Josh Gordon's Machine Learning Recipes playlist (https://www.youtube.com/playlist?list=PLOU2XLYxmsIIuiBfYad6rFYQU_jL2ryal) More generally it's my playing with ml.