Skip to content

Semantic Models

SemanticModels

SemanticModels Class

This class implements semantic models for graph-based recommendation systems. Semantic models enhance traditional graph-based methods by incorporating semantic information, such as item content or user profiles, into the recommendation process.

Attributes:

Name Type Description
semantic_graph Graph

The graph structure enriched with semantic information.

embedding_dim int

Dimensionality of semantic embeddings.

similarity_threshold float

Threshold for determining similarity between nodes.

max_iterations int

Maximum number of iterations for convergence in semantic algorithms.

Methods:

Name Description
build_semantic_graph

Constructs a semantic graph by integrating semantic information into the existing graph structure, enhancing node representations.

compute_semantic_similarity

Computes similarity scores between nodes using semantic information, improving recommendation accuracy.

recommend

Generates top-N recommendations for a given user by analyzing the semantic graph structure and node similarities.

update_semantic_info

Updates the semantic information in the graph, allowing for dynamic and context-aware recommendations.

Source code in engines/contentFilterEngine/graph_based_algorithms/semantic_models.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class SemanticModels:
    """
    SemanticModels Class

    This class implements semantic models for graph-based recommendation systems.
    Semantic models enhance traditional graph-based methods by incorporating semantic
    information, such as item content or user profiles, into the recommendation process.

    Attributes:
        semantic_graph (Graph): The graph structure enriched with semantic information.
        embedding_dim (int): Dimensionality of semantic embeddings.
        similarity_threshold (float): Threshold for determining similarity between nodes.
        max_iterations (int): Maximum number of iterations for convergence in semantic algorithms.

    Methods:
        build_semantic_graph(data, semantic_info):
            Constructs a semantic graph by integrating semantic information into the
            existing graph structure, enhancing node representations.

        compute_semantic_similarity():
            Computes similarity scores between nodes using semantic information, improving
            recommendation accuracy.

        recommend(user_id, top_n=10):
            Generates top-N recommendations for a given user by analyzing the semantic
            graph structure and node similarities.

        update_semantic_info(new_semantic_data):
            Updates the semantic information in the graph, allowing for dynamic and
            context-aware recommendations.
    """
    def __init__(self):
        self.graph = []

    def set_graph(self, graph):
        """
        Set the graph for semantic models.
        """
        self.graph = graph

    def find_optimal_path(self, start_city):
        """
        Find the optimal path using the run_optimal_path function.
        """
        run_optimal_path(self.graph, start_city)

find_optimal_path(start_city)

Find the optimal path using the run_optimal_path function.

Source code in engines/contentFilterEngine/graph_based_algorithms/semantic_models.py
43
44
45
46
47
def find_optimal_path(self, start_city):
    """
    Find the optimal path using the run_optimal_path function.
    """
    run_optimal_path(self.graph, start_city)

set_graph(graph)

Set the graph for semantic models.

Source code in engines/contentFilterEngine/graph_based_algorithms/semantic_models.py
37
38
39
40
41
def set_graph(self, graph):
    """
    Set the graph for semantic models.
    """
    self.graph = graph