Marketers use machine learning to find patterns in user activities on a website or on a mobile application. This helps them predict the further behavior of users and quickly optimize advertising offers. In this paper, we present a novel algorithm based on Machine Learning used in the Information System for optimizing advertising services, attracting customers, growing sales, adapting the promotional offers that correspond to the hobbies of users, and for setting up a spam filter in the email or the Facebook service. Our framework demonstrates the feasibility of the approach to manage advertising campaigns to produce better results.