Flexible customizable analytics functions (self-defined and customizable algorithms) covering rules-based analytics and machine learning