Overview of personalised ranking and examples of algorithms and implementations.

Mathematics Machine Learning Artificial Intelligence Graph Data Algorithm Programming Digital Transformation Algorithms and Data structures Navigation of this blog

Overview of personalised ranking.

Personalised ranking is a method of ranking that provides items in the most appropriate rank for each user. While general ranking systems present items in the same rank for all users, personalised ranking takes into account the individual preferences and behaviour of the user and Personalised ranking takes into account the user’s individual preferences and behaviour and ranks items in the most appropriate order for that user.

The purpose of personalised ranking is to increase user engagement by showing items that are likely to be of interest to the user at a higher rank, increase user engagement, increase user purchases, clicks and other actions, and increase conversion rates Increased conversion rates, users being able to find the information and products they are looking for more quickly, which increases user satisfaction, which increases user satisfaction, etc.

Techniques for personalised ranking include the following. These mainly rely on the recommendation techniques described in “Recommendation techniques“.

User profiles: Information on user preferences and attributes is collected to create user profiles. This includes past behaviour history, purchase history, ratings, click history, etc.

Context: use contextual information that takes into account the user’s behaviour and situation. Examples include the user’s geographical location, device, time of day, etc.

Collaborative filtering: this method recommends items of interest to similar users based on the user’s past behaviour history.

Content-based filtering: a method for recommending items that users are likely to be interested in, based on the item’s features and attributes.

Ranking models: these use the user’s profile and contextual information as input to build a model for optimal ranking. Neural network-based models and gradient boosting are used for this.

The benefits of personalised ranking include: improved user experience, as items are more relevant to the user; improved user loyalty, as users have a more satisfying experience and are more loyal to the service, Revenue growth, which increases revenue through increased actions such as purchases and clicks, by offering items that match the interests of the user.

Personalised ranking is widely used in a variety of sectors and is an important approach to providing better experiences and services for users.

Algorithms related to personalised ranking.

Algorithms related to personalised ranking are methods for ranking items in the best possible order, taking into account the individual preferences and behaviour of users, and include the following

1. collaborative filtering: collaborative filtering is a recommendation method that makes use of similarities between users and items. It is also used in personalised ranking to recommend items of interest to similar users.

User-based collaborative filtering: predicts item ratings and ranks for each user based on the past behaviour of users with similar tastes.

Item-based collaborative filtering: recommends items of interest to users based on items with similar attributes and characteristics.

2. Content-Based Filtering: Content-based filtering is a recommendation method that uses the attributes and characteristics of users and items. It is also used in personalised ranking to provide content that matches user preferences.

TF-IDF: extracts features from text data and recommends items containing keywords that match the user’s preferences.

Image features: extracts features from images and recommends items containing images likely to be preferred by the user.

3. ranking model: the ranking model is a method that uses a neural network to perform optimal ranking using the user’s profile and context information as input.

RankNet: a neural network model that learns the order of ranked pairs and is also applied for personalised ranking.

LambdaMART: a gradient boosting algorithm for ranking, which performs well in personalised ranking.

Neural Collaborative Filtering: the model learns embedded representations of users and items and combines these features for ranking.

4. deep learning approaches: in recent years, personalised ranking algorithms using deep learning have also attracted attention.

DeepFM: a method combining deep neural networks and factorised machine learning, used for CTR prediction and personalised ranking.

Wide & Deep Learning: combines wide linear models and deep neural networks for personalised ranking.

5. evaluation metrics: rank-related metrics are commonly used to evaluate personalised ranking algorithms.

NDCG (Normalised Discounted Cumulative Gain): this is an indicator that measures how good the ranking of the correct item is for a query.

MAP (Mean Average Precision): calculates the average precision and assesses the quality of the ranking.

MRR (Mean Reciprocal Rank): assesses the quality of the ranking by taking the average of the reciprocal of the positions at which the correct answer items are ranked.

Case studies on the application of personalised ranking

Personalised ranking is widely used in various sectors to improve user experience and achieve business goals by ranking items in the most appropriate order, taking into account users’ individual preferences and behaviour. Examples of their application are described below.

1. online retailers:

Product recommendations: online retailers such as Amazon and eBay provide personalised product recommendations based on users’ past purchase and browsing history, ranking products according to user preferences and interests to encourage purchasing.

Related product suggestions: attracts customer interest by presenting items and accessories related to the product once purchased, as well as products purchased by other customers.

2. streaming services:

Video and music recommendations: streaming services such as Netflix and Spotify recommend content that matches the user’s viewing history, playlists and preferences, thereby making it easier for users to discover new movies and music.

Personalised playlists: personalised playlists are provided that are automatically generated based on a user’s preferences and activities.

3. social media:

Displaying posts and ads: social media platforms such as Facebook and Instagram display personalised posts and ads based on users’ past behaviour and interests, thereby maximising user engagement and advertising effectiveness.

4. on-demand delivery:

News and article recommendations: on-demand news services and information websites rank personalised news and articles based on user interests and preferences.

5. online advertising:

Ad personalisation: adverts displayed on search engines such as Google and Bing, or on websites, are personalised according to users’ search queries and browsing history, providing adverts tailored to their interests and increasing click and conversion rates.

6. online games:

Display of items and characters: online games display personalised items and enemy characters according to players’ preferences and playing styles.

7. travel and accommodation booking websites:

Hotel and airline ticket recommendations: travel booking websites recommend personalised hotels and airline tickets based on the user’s previous search and booking history, favourite regions and facilities.

8. educational platforms:

Provision of learning content: online learning platforms provide the best learning content based on the learner’s past learning history, interests and skill level.

Personalised ranking can increase the value of services in various areas by understanding the interests and behaviour of users and providing an optimal experience based on this.

Examples of personalised ranking implementations

The following are examples of personalised ranking implementations.

1. example implementation of collaborative filtering

User-based collaborative filtering: the following is an example of implementing user-based collaborative filtering using Python and Pandas.

import pandas as pd
from sklearn.metrics.pairwise import cosine_similarity

# User - read the item's rating matrix
ratings = pd.read_csv('ratings.csv')

# Conversion of user-item evaluation matrices to user-item matrices.
user_item_matrix = ratings.pivot_table(index='user_id', columns='item_id', values='rating')

# Calculate cosine similarity between users.
user_similarity = cosine_similarity(user_item_matrix.fillna(0))

# Predicting target user rating values.
def predict_rating(user_id, item_id):
    sim_scores = user_similarity[user_id - 1]  # User IDs start at 1, so -1 to match the index.
    item_ratings = user_item_matrix.loc[:, item_id]
    sim_scores = sim_scores[item_ratings.notna()]
    item_ratings = item_ratings[item_ratings.notna()]
    if len(sim_scores) == 0:
        return 0  # If no similar user exists, return a rating value of 0.
    else:
        return sum(sim_scores * item_ratings) / sum(sim_scores)

# Predicts the target user's evaluation of an item.
predicted_rating = predict_rating(target_user_id, target_item_id)

Item-based collaborative filtering: an example implementation of item-based collaborative filtering is similar to the user-based example above, but differs in that similarity is calculated between items.

2. implementation examples of content-based filtering

Feature-based ranking using TF-IDF: The following is an example implementation of content-based filtering, using TF-IDF to vectorise text data.

from sklearn.feature_extraction.text import TfidfVectorizer

# Sample text data
documents = [
    "This is a sample document.",
    "Another document for testing.",
    "And another one for good measure."
]

# TF-IDF vectorisation
vectorizer = TfidfVectorizer()
tfidf_matrix = vectorizer.fit_transform(documents)

# TF-IDF vectorisation of input queries.
query = "sample document"
query_vector = vectorizer.transform([query])

# Calculate and rank cosine similarity.
from sklearn.metrics.pairwise import cosine_similarity
similarities = cosine_similarity(tfidf_matrix, query_vector)

# Ranked in order of similarity
ranking = list(enumerate(similarities))
ranking = sorted(ranking, key=lambda x: x[1], reverse=True)

# Retrieve higher-level documents.
top_k = 5
top_documents = [documents[idx] for idx, _ in ranking[:top_k]]

3. implementation examples of ranking models using neural networks

Personalised ranking with neural networks: the following is an example of implementing personalised ranking with neural networks using PyTorch.

import torch
import torch.nn as nn
import torch.optim as optim

class RankNet(nn.Module):
    def __init__(self, input_size, hidden_size):
        super(RankNet, self).__init__()
        self.fc1 = nn.Linear(input_size, hidden_size)
        self.relu = nn.ReLU()
        self.fc2 = nn.Linear(hidden_size, 1)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x):
        out = self.relu(self.fc1(x))
        out = self.sigmoid(self.fc2(out))
        return out

# Model definition.
model = RankNet(input_size, hidden_size)

# Definition of loss functions and optimisation methods.
criterion = nn.BCELoss()  # binary cross entropy error
optimizer = optim.Adam(model.parameters(), lr=learning_rate)

# training loop
for epoch in range(num_epochs):
    for inputs, targets in dataloader:
        optimizer.zero_grad()
        outputs = model(inputs)
        loss = criterion(outputs, targets)
        loss.backward()
        optimizer.step()

# inference
with torch.no_grad():
    outputs = model(inputs)
Challenges and measures for personalised ranking.

Personalised ranking has many advantages, but there are also some challenges. These challenges and measures to address them are described below.

1. cold start problem:

Challenge: It is difficult to perform proper ranking for new users and new items, and personalised recommendations are difficult because user preferences and item characteristics are unclear.

Solution:
Use of demographic information: use user demographic information and information from registration to provide initial rankings.
Item popularity: rank new items based on their popularity and trends over a certain period of time.
Random recommendations: recommend a certain number of items at random and collect user feedback to learn preferences.

2. data sparseness: 

Challenge: a limited number of items are rated and purchased by users, making accurate personalised ranking difficult if the user-item rating matrix is sparse.

Solution:
Clustering items: group similar items and rank them by cluster to reduce sparsity.
Feature extensions: use user attribute information and item feature information to complement or extend the rating matrix.
Topic models: reduce sparsity by extracting potential topics and associating users with items.

3. fairness and bias:

Challenge: in personalised ranking, some users are overexposed or recommendations are biased towards users or items with certain attributes.

Solution:
Detect and correct bias: monitor for bias due to user attributes when operating the recommendation system and make appropriate adjustments.
Introduce fairness constraints: incorporate fairness constraints in algorithms and models to ensure fairness.
Promoting diversity: emphasise the diversity of recommended items and provide users with different perspectives and options.

4. handling of time-series data:

Challenge: user preferences and behaviour change over time, so it is necessary to reflect up-to-date information as well as historical data.

Solution:
Use recurrent neural networks: use models such as RNNs and LSTMs to account for time-series preferences.
Windowing: input data from a certain period of time in the past into the model in a windowed manner to take into account time-series information.
Online learning: collect user feedback in real time and update the model.

5. selection of evaluation metrics:

Challenge: it is important to select appropriate metrics to evaluate the performance of personalised ranking.

Solution:
Use rank-related metrics such as NDCG (Normalised Discounted Cumulative Gain) and MAP (Mean Average Precision).
A/B testing: evaluate performance by applying different algorithms to real users and comparing them.

Reference Information and Reference Books

For general machine learning algorithms including search algorithms, see “Algorithms and Data Structures” or “General Machine Learning and Data Analysis.

Algorithms” and other reference books are also available.

1. Recommender Systems: The Textbook

Author: Charu C. Aggarwal
Publisher: Springer, 2016

  • A comprehensive textbook covering collaborative filtering, content-based filtering, hybrid models, and evaluation metrics like NDCG and MAP.

  • 📌 Excellent for understanding the principles behind personalized ranking and recommendation system design.

2. Hands-On Recommendation Systems with Python

Author: Rounak Banik
Publisher: Packt Publishing, 2018

  • Focuses on practical implementations of recommendation algorithms such as Matrix Factorization, ALS, and Bayesian Personalized Ranking (BPR).

  • Ideal for practitioners and engineers working with Python.

3. Practical Recommender Systems

Author: Kim Falk
Publisher: Manning Publications, 2019

  • Covers building, tuning, and deploying real-world recommender systems with examples in Python.

  • Great for industry-focused readers looking to build production-ready personalized ranking systems.

4. Deep Learning for Recommender Systems

Authors: Alexandros Karatzoglou, Balázs Hidasi (various papers and tutorials)

  • Introduces cutting-edge neural recommender models such as Neural Collaborative Filtering, RNN-based ranking, and Transformer-based re-ranking (e.g., SASRec, PEAR).

  • Suitable for advanced readers interested in the latest personalized re-ranking techniques.

5. Mining of Massive Datasets

Authors: Jure Leskovec, Anand Rajaraman, Jeff Ullman
Publisher: Cambridge University Press

  • Covers scalable algorithms for mining massive data, including recommendation and ranking systems.

  • Good for those interested in the theory and large-scale implementation.

コメント

タイトルとURLをコピーしました