How to implement the recommendation system

Levi9 Serbia
levi niners articles
10 min readDec 19, 2023

You’re in the mood for a movie night, so naturally you open your favorite streaming service. What to watch? An eternal question. But then, like magic, a tailor-made selection of movie suggestions is waiting just for you.

Most of the content we see is offered to us with particular reason and carefully calculated before it is shown. How is this tailor-made content generated? Is it magic? The main suspect is the recommendation system, which significantly impacts our online experience.

Powered by machine learning, these systems analyze our online traces to suggest products, services, or content that might interest us. It’s like having a friend who knows us so well; they always recommend the good stuff before we even know we want it. That creates digital trust comparable to the comfort and reliability we find in advice from a trusted friend, adding a sense of assurance to the options offered. The influence of recommendation systems goes beyond their technological framework, significantly affecting both the sociological and psychological aspects of user experience. This technology represents a sophisticated mix of digital innovation and human psychology.

In today’s world, where we are overwhelmed by choices, recommendation systems provide valuable guidance by reducing the stress and uncertainty of decision-making. This is particularly true for choices involving significant emotional or financial commitment, where the stakes are higher and the need for assurance is greater. Consequently, recommendation systems do more than just streamline the selection process — they provide a psychological safety net, simplifying complex decisions and enhancing the overall user experience in a diverse digital landscape.

Essentially, recommendation systems are based on algorithms designed to predict the preferences of users. As a mix of data science and machine learning they analyze vast datasets that we, as online beings, constantly generate — our browsing history, purchases, likes, age, location, gender, but also characteristics of the items themselves. Using all that data our patterns and preferences are identified. Based on that, recommendation systems suggest items liked by other users with similar tastes. This capability is not just about selling products but about creating personalized experiences that we all love. But what’s more important is that these systems evolve. Through ongoing learning from user interactions, they constantly improve the accuracy of their predictions.

And now, let’s start with the process of building a recommendation system!

Recommendation systems goals — what do we want to achieve?

Creating an effective recommendation system begins with a clear definition of its goals. The purpose of the system needs to be well-defined and aligned with the organization’s broader objectives. This could involve several targets, such as increasing the number of users or enhancing user engagement focusing on how they interact with the app and ensuring that they find value and relevance in its offerings. By defining these objectives, the recommendation system can be created to address these specific areas, whether it’s more users, improving user satisfaction, or both. The clarity in the system’s goals will not only guide the technical development but also ensure that the end product resonates with the intended users and meets the business expectations.

Understanding user needs and current app usage patterns is another important aspect of building a recommendation system. This involves a deep dive into the user experience such as how users currently engage with the app, what they value, and whether there is a room for improvement. A key part of this process is benchmarking against competitors to identify what can be done better. The goal is to enhance the system to meaningfully improve the user experience, leading to increased engagement and loyalty. This requires not just understanding the functional aspects of how users interact with the app but also gaining insights into their preferences, behaviors, and pain points. By aligning the recommendation system with these user insights, it can deliver a personalized and enjoyable experience more effectively, thereby fostering a stronger connection between the user and the app.

The success of a recommendation system heavily relies on the quality of the data it utilizes. This involves thoughtful consideration of data types essential for the system to function effectively. Key data types include user behavior data, such as search history, views, and other interactions within the app. Additionally, user characteristics like age, gender, and location provide valuable context. Understanding the content attributes being offered is equally important, as it helps in aligning recommendations with what is available. By carefully selecting and utilizing the right data, the recommendation system can be fine-tuned to meet user needs effectively, ensuring that the recommendations are relevant, timely, and contextually appropriate.

Data is everything

Once we have a clear understanding of the data requirements, we need to start the process of gathering and preparing the data. We collect data from various sources within the organization which we then prepare for analysis and use. Data of interest to us includes user interactions within the app and user information from databases or some customer relationship management (CRM) systems. If the required data isn’t already available, it needs to be collected. For instance, user interaction events on a website or app could be tracked. Other than that, we could collect user demographic and behavioral data, if available, from third-party systems.

Once the necessary data is collected, the next step is transforming it into a form suitable for our recommendation system. This transformation process involves several key tasks. Firstly, irrelevant data must be identified and filtered out. The recommendation system will perform best if it has only the necessary data for calculations. Next, we need to transform everything into the proper format for analysis. Finally, when all the data is prepared, it must be uploaded to a designated central repository. That repository becomes the core location from which the recommendation system’s machine learning algorithms access and utilize data to generate user-specific recommendations. Extract, transform, load (ETL) jobs can help us in this phase.

These processes ensure that all values are uniform, making it easier for the recommendation algorithms to process and analyze them effectively.

Recommendation system design — which approach should be used?

There are several common approaches to designing recommendation systems. Each approach has its strengths and is suitable for different scenarios. There is no golden rule to choose the right one. Remember when we talked about the importance of a clear definition of our recommendation system’s goals? We have to keep that in mind while choosing the best approach for us. Once the approach is selected, the next step is to choose specific algorithms that best fit the chosen method. For example, in collaborative filtering, a popular choice is matrix factorization, an algorithm effective in uncovering hidden user-item interactions. The selection of the approach and algorithm needs to be aligned with business objectives. But first, let’s cover those common approaches.

Content-Based Filtering

Content-based filtering in recommendation systems revolves around the properties and characteristics of items and user interactions. It builds detailed profiles for both.

User profiles — are shaped by their past interactions with items and by the user’s attributes. For example, a user who frequently listens to rock music would have a profile highlighting a preference for this genre.

Item profiles — are created based on attributes like category, features, and other relevant characteristics. For music, this could include its genre, album release date, and similar. The system then matches these profiles, recommending items to users based on how closely the item’s attributes align with the user’s preferences.

This approach has the advantage of being effective even with a small amount of data, as it doesn’t rely on having a large user base or extensive user interactions. However, a limitation of content-based filtering is that it often leads to recommending items that are too similar, without diversity in suggestions, and potentially limiting user exposure to a wider range of options. Despite this, content-based filtering remains a valuable tool in creating recommendations to individual user tastes.

Collaborative Filtering

Collaborative filtering, a cornerstone technique in recommendation systems, operates primarily through two approaches:

User-Based Collaborative Filtering — this principle can be explained with an example of a music service, if John and Sarah both liked similar albums, the system predicts that some new album liked by John would also be interesting to Sarah.

Item-Based Collaborative Filtering — focuses on the similarity between items. If a large group of users has liked both “Stairway to Heaven” by Led Zeppelin and “Hey You” by Pink Floyd, the system infers a high similarity between these songs, recommending “Hey You” to users who liked “Stairway to Heaven” but haven’t yet heard “Hey You”. This approach makes detailed recommendations by understanding the complex connections between different items.

However, these methods have its limitations. They require more user data to function effectively, making them less efficient for new users or items (“cold start”). For instance, a newly released song might struggle to be recommended because it hasn’t been rated or linked enough to establish its position in the network of preferences. Despite these challenges, collaborative filtering remains a popular and powerful tool in crafting personalized experiences, especially in domains like music streaming, where user preferences are diverse and dynamic.

Hybrid Approach

The hybrid approach combines and takes the best from different approaches. For example, in an online shopping platform offering deals, a hybrid system could use collaborative filtering to analyze user views and preferences, suggesting deals similar users have shown interest in. At the same time, it uses content-based filtering to examine the characteristics of products that a user has shown interest in, like brand, price range, or specific product features, to offer more personalized deals.

The usage of two approaches offers us the possibility to avoid the weak points of both approaches. One notable issue it addresses is the cold start problem with new products or users. Additionally, its adaptable nature makes it particularly well-suited for the dynamic and varied inventory of online shopping platforms.

Some of the hybrid types are: weighted, switching, mixed, feature combination, cascade, meta-level, and social.

Other Approaches

We have a variety of approaches at our disposal, extending beyond the initial three methods. They use different advanced techniques to customize recommendations for each user. Rule-based systems rely on explicit rules for recommendations, such as suggesting seasonal products. Context-aware recommendations offer insights based on time or location. In Deep Learning — Neural Networks, Autoencoders, and Recurrent Neural Networks (RNNs) play pivotal roles by learning from complex data patterns. Clustering methods group similar users or items, enhancing recommendation relevance. Each approach offers unique strengths, contributing to the dynamic and evolving field of recommendation systems.

Development and Monitoring of a Recommendation System

Now that we have chosen our path, we need to start with the actual development and therefore the appropriate tech stack needs to be decided on. This includes picking programming languages, frameworks, and tools that are best suited for implementing the chosen recommendation algorithm, be it content-based filtering, collaborative filtering, or a hybrid approach. Once the tech stack is decided, the next step is to develop the recommendation system. This involves programming the algorithm and fine-tuning it to align with the defined objectives. After the model is developed, it undergoes training with a prepared training dataset. The model uses a dataset to learn about user behavior. The training process is iterative and requires adjustment from time to time to ensure the model accurately captures the variation of user-item interactions.

When the model is completed and trained, its performance must be evaluated using a separate testing dataset. This evaluation is crucial for assessing the model’s precision in making recommendations. Once the model passes this evaluation phase, it is integrated into the existing app. After integration, the system still needs to work seamlessly with the app’s existing features and user interface. To ensure that the system is performant, we need to monitor and constantly improve it. This involves regularly updating the model with new data and retraining it to adapt to changing user preferences and behaviors.

Finally, gathering and analyzing user feedback becomes an integral part of the process, providing insights into how well the recommendations are being received by the users. User feedback helps identify areas for improvement, ensuring that the recommendation system continually evolves to better meet the needs and expectations of its users.

Synergy of technology, psychology, and sociology

Ethical concerns surrounding recommendation systems are increasingly significant. These include issues of privacy, where the handling and use of personal data must be considered carefully to protect user confidentiality. Bias is an important problem, as it can sometimes worsen existing biases or affect results because of how their algorithms work. Additionally, there’s a growing concern that these systems might limit individual decision-making and critical thinking, as users increasingly rely on automated suggestions. Therefore, it’s essential to strike a balance in using recommendation systems, ensuring they serve as helpful tools without overriding personal choice and autonomy. This balance is key to harnessing the benefits of these systems while mitigating their potential downsides.

Recommendation systems represent a fascinating synergy of technology, psychology, and sociology. They illustrate how AI and machine learning are not just reshaping our digital interactions but also influencing our real-world experiences and behaviors. The choices we make online, in the end, affect our real-life decisions, from the food we eat to the clothes we wear. They shape our preferences and our identities. As these systems become more sophisticated, understanding their impact on individual psychology and social dynamics becomes increasingly important. They are more than just algorithms; they are digital mirrors reflecting our desires, insecurities, and quest for belonging in an increasingly connected world.

Created by:
Nemanja Romanić
Java Tech Lead @ Levi9 Serbia

--

--