Previous topic

Classification MLProblems

Next topic

Learners

This Page

Ranking MLProblems

The mlproblems.ranking module contains MLProblems specifically for ranking problems.

This module contains the following classes:

  • RankingProblem: . Generates a ranking problem.
  • RankingToClassificationProblem: Generates a classification problem from a ranking problem.
  • RankingToRegressionProblem: Generates a regression problem from a ranking problem.
class mlproblems.ranking.RankingProblem(data=None, metadata={}, call_setup=True)[source]

Generates a ranking problem.

The data should be an iterator input/target/query pairs, where the target is a relevance score. When grouping query data together, is it assumed that examples from the same query are next to each other in the data (e.g. there aren’t examples from the same query at the beginning and end of the data).

The ranking examples become triplets (inputs_for_query,targets_for_query,query) where inputs_for_query and target_for_query are the lists of inputs and targets for a given query.

Required metadata:

  • 'n_queries': Number of queries (optional, will set the output of __len__(self)).
class mlproblems.ranking.RankingToClassificationProblem(data=None, metadata={}, call_setup=True, merge_document_and_query=None)[source]

Generates a classification problem from a ranking problem.

Option 'merge_document_and_query' (a function with 2 arguments) is used to generate inputs for the classification problem.

The list of possible scores must be provided as a metadata. IMPORTANT: the scores should be ordered from less to more relevant in the list. This list will be used to generate the set of targets and ‘class_to_id’ mapping.

Required_metadata:

  • 'scores': List of possible scores, ordered from less relevant to more relevant.
  • 'n_pairs': Number of document/query pairs (optional, will set the output of __len__(self)).

Defined metadata:

  • 'targets'
  • 'class_to_id'
class mlproblems.ranking.RankingToRegressionProblem(data=None, metadata={}, call_setup=True, merge_document_and_query=None)[source]

Generates a regression problem from a ranking problem.

Option 'merge_document_and_query' (a function with 2 arguments) is used to generate inputs for the classification problem.

Required_metadata:

  • 'n_pairs': Number of document/query pairs (optional, will set the output of __len__(self)).