RuleEvaluation module

Module performs evaluation of association rule-based recommendations for a given ruleset stored in a MySQL/MariaDB database.

class RuleEvaluation.RuleEvaluation(recommender)

Bases: object

Class performs evaluation of association rule-based recommendations for a given ruleset stored in a MySQL/MariaDB database.

compute_mean_reciprocal_rank(recommended_properties, removed_properties)

Function computes the mean reciprocal rank for the given list of recommendations and the ground truth data provided (i.e., previously removed properties).

Parameters:
  • recommended_properties (list) – list of computed recommendations.
  • removed_properties (list) – list of previously removed properties (ground truth).
Returns:

mean reciprocal rank

Return type:

float

Function computes evaluation metrics for given recommendations and previously removed properties (ground truth). Evaluation metrics include recall, precision and mean reciprocal rank.

Parameters:
  • recommended_properties (list) – list of computed recommendations.
  • removed_properties (list) – list of previously removed properties
  • maximum_number_recommendations (int) – maximum number of recommendations computed
Returns:

dict containing recall, precision and reciprocal rank results.

Return type:

dict

perform_evaluation(no_evaluated_subjects=1000)

Function triggers actual evaluation of subjects.

Parameters:no_evaluated_subjects (int .) – number of subjects to be evaluated
Returns:results of the overall evaluation run.
Return type:dict
perform_evaluation_on_subject(input_properties, removed_properties)

Function performs the actual recommendation and evaluation steps. Takes set of properties as input and computes recommendations for these properties. If at least one of the recommendations matches, we accept it and add it to the set of propreties on the subject and repeat this evaluation iteratively (while evaluating the recommendation performance at each step).

Parameters:input_properties – initial properties to be used as input for the first

recommendation computation. :param removed_properties: ground truth data that should be reconstructed during evaluation process. :return: computed results/statistics for evaluation on given subject :rtype: dict

process_subject(subject_id)

Function processes evaluation for a single given subject. This includes randomly choosing properties used as input for recommendation evaluation, filtering for classifying properties and calling the actual evaluation.

Param:subject_id: the id of the subject to be evaluated