Discrete approach to machine learning