src.fairreckitlib.evaluation.evaluation_factory

This module contains functionality to create an evaluation factory.

Constants:

KEY_EVALUATION: key that is used to identify evaluation.

Functions:

create_evaluation_factory: create factory with prediction/recommendation factories.

This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)

 1"""This module contains functionality to create an evaluation factory.
 2
 3Constants:
 4
 5    KEY_EVALUATION: key that is used to identify evaluation.
 6
 7Functions:
 8
 9    create_evaluation_factory: create factory with prediction/recommendation factories.
10
11This program has been developed by students from the bachelor Computer Science at
12Utrecht University within the Software Project course.
13© Copyright Utrecht University (Department of Information and Computing Sciences)
14"""
15
16from ..core.config.config_factories import GroupFactory
17from ..core.core_constants import TYPE_PREDICTION, TYPE_RECOMMENDATION
18from .metrics.metric_factory import \
19    create_accuracy_metric_factory, create_coverage_metric_factory, create_rating_metric_factory
20
21KEY_EVALUATION = 'evaluation'
22
23
24def create_evaluation_factory() -> GroupFactory:
25    """Create a factory with all predictor and recommender metric category factories.
26
27    All the metric category factories are shared between prediction and recommendation,
28    except for ths accuracy category which only applies to recommendation evaluation.
29
30    Returns:
31        the group factory with available predictor and recommender factories.
32    """
33    shared_categories = [create_coverage_metric_factory, create_rating_metric_factory]
34
35    prediction_factory = GroupFactory(TYPE_PREDICTION)
36
37    recommendation_factory = GroupFactory(TYPE_RECOMMENDATION)
38    recommendation_factory.add_factory(create_accuracy_metric_factory())
39
40    for func_create in shared_categories:
41        category_factory = func_create()
42        prediction_factory.add_factory(category_factory)
43        recommendation_factory.add_factory(category_factory)
44
45    evaluation_factory = GroupFactory(KEY_EVALUATION)
46    evaluation_factory.add_factory(prediction_factory)
47    evaluation_factory.add_factory(recommendation_factory)
48    return evaluation_factory
def create_evaluation_factory() -> src.fairreckitlib.core.config.config_factories.GroupFactory:
25def create_evaluation_factory() -> GroupFactory:
26    """Create a factory with all predictor and recommender metric category factories.
27
28    All the metric category factories are shared between prediction and recommendation,
29    except for ths accuracy category which only applies to recommendation evaluation.
30
31    Returns:
32        the group factory with available predictor and recommender factories.
33    """
34    shared_categories = [create_coverage_metric_factory, create_rating_metric_factory]
35
36    prediction_factory = GroupFactory(TYPE_PREDICTION)
37
38    recommendation_factory = GroupFactory(TYPE_RECOMMENDATION)
39    recommendation_factory.add_factory(create_accuracy_metric_factory())
40
41    for func_create in shared_categories:
42        category_factory = func_create()
43        prediction_factory.add_factory(category_factory)
44        recommendation_factory.add_factory(category_factory)
45
46    evaluation_factory = GroupFactory(KEY_EVALUATION)
47    evaluation_factory.add_factory(prediction_factory)
48    evaluation_factory.add_factory(recommendation_factory)
49    return evaluation_factory

Create a factory with all predictor and recommender metric category factories.

All the metric category factories are shared between prediction and recommendation, except for ths accuracy category which only applies to recommendation evaluation.

Returns: the group factory with available predictor and recommender factories.