src.fairreckitlib.data.data_transition

This module contains a data transition definition.

Classes:

DataTransition: data descriptions to be used between pipelines.

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 a data transition definition.
 2
 3Classes:
 4
 5    DataTransition: data descriptions to be used between pipelines.
 6
 7This program has been developed by students from the bachelor Computer Science at
 8Utrecht University within the Software Project course.
 9© Copyright Utrecht University (Department of Information and Computing Sciences)
10"""
11
12from typing import Tuple
13
14from dataclasses import dataclass
15
16from .ratings.convert_constants import RATING_TYPE_THRESHOLD
17from .set.dataset import Dataset
18from .set.dataset_config import DATASET_RATINGS_EXPLICIT, DATASET_RATINGS_IMPLICIT
19
20
21@dataclass
22class DataTransition:
23    """Data Transition to transfer pipeline data.
24
25    dataset: the dataset that was used for the data transition.
26    matrix_name: the dataset matrix name that was used for the data transition.
27    output_dir: the output directory of the data transition.
28    train_set_path: the train set path in the output directory.
29    test_set_path: the test set path in the output directory.
30    rating_scale: the minimum and maximum rating in the train and test set combined.
31    """
32
33    dataset : Dataset
34    matrix_name: str
35    output_dir: str
36    train_set_path: str
37    test_set_path: str
38    rating_scale: Tuple[float, float]
39
40    def get_rating_type(self) -> str:
41        """Get the rating type of the data transition.
42
43        Returns:
44            the rating type (either 'explicit' or 'implicit').
45        """
46        return DATASET_RATINGS_IMPLICIT \
47            if self.rating_scale[1] > RATING_TYPE_THRESHOLD else DATASET_RATINGS_EXPLICIT
@dataclass
class DataTransition:
22@dataclass
23class DataTransition:
24    """Data Transition to transfer pipeline data.
25
26    dataset: the dataset that was used for the data transition.
27    matrix_name: the dataset matrix name that was used for the data transition.
28    output_dir: the output directory of the data transition.
29    train_set_path: the train set path in the output directory.
30    test_set_path: the test set path in the output directory.
31    rating_scale: the minimum and maximum rating in the train and test set combined.
32    """
33
34    dataset : Dataset
35    matrix_name: str
36    output_dir: str
37    train_set_path: str
38    test_set_path: str
39    rating_scale: Tuple[float, float]
40
41    def get_rating_type(self) -> str:
42        """Get the rating type of the data transition.
43
44        Returns:
45            the rating type (either 'explicit' or 'implicit').
46        """
47        return DATASET_RATINGS_IMPLICIT \
48            if self.rating_scale[1] > RATING_TYPE_THRESHOLD else DATASET_RATINGS_EXPLICIT

Data Transition to transfer pipeline data.

dataset: the dataset that was used for the data transition. matrix_name: the dataset matrix name that was used for the data transition. output_dir: the output directory of the data transition. train_set_path: the train set path in the output directory. test_set_path: the test set path in the output directory. rating_scale: the minimum and maximum rating in the train and test set combined.

DataTransition( dataset: src.fairreckitlib.data.set.dataset.Dataset, matrix_name: str, output_dir: str, train_set_path: str, test_set_path: str, rating_scale: Tuple[float, float])
def get_rating_type(self) -> str:
41    def get_rating_type(self) -> str:
42        """Get the rating type of the data transition.
43
44        Returns:
45            the rating type (either 'explicit' or 'implicit').
46        """
47        return DATASET_RATINGS_IMPLICIT \
48            if self.rating_scale[1] > RATING_TYPE_THRESHOLD else DATASET_RATINGS_EXPLICIT

Get the rating type of the data transition.

Returns: the rating type (either 'explicit' or 'implicit').