src.fairreckitlib.data.split.split_config
This module contains the split configuration.
Classes:
SplitConfig: split configuration.
Functions:
create_default_split_config: create the default split configuration.
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 the split configuration. 2 3Classes: 4 5 SplitConfig: split configuration. 6 7Functions: 8 9 create_default_split_config: create the default split configuration. 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 dataclasses import dataclass 17from typing import Any, Dict 18 19from ...core.core_constants import KEY_RANDOM_SEED 20from ...core.config.config_object import ObjectConfig 21from .split_constants import DEFAULT_SPLIT_NAME, DEFAULT_SPLIT_TEST_RATIO, KEY_SPLIT_TEST_RATIO 22 23 24@dataclass 25class SplitConfig(ObjectConfig): 26 """Dataset Splitting Configuration. 27 28 name: the name of the splitter. 29 params: the parameters of the splitter. 30 test_ratio: the test ratio used by the splitter. 31 """ 32 33 test_ratio: float 34 35 def get_split_ratio_string(self) -> str: 36 """Get the split ratio percentages formatted as a string. 37 38 Returns: 39 a string containing the split ratio in percentages. 40 """ 41 test_perc = int(self.test_ratio * 100.0) 42 return str(100 - test_perc) + '/' + str(test_perc) 43 44 def to_yml_format(self) -> Dict[str, Any]: 45 """Format splitting configuration to a yml compatible dictionary. 46 47 Returns: 48 a dictionary containing the splitting configuration. 49 """ 50 yml_format = ObjectConfig.to_yml_format(self) 51 yml_format[KEY_SPLIT_TEST_RATIO] = self.test_ratio 52 return yml_format 53 54 55def create_default_split_config() -> SplitConfig: 56 """Create the default split configuration. 57 58 Returns: 59 the default configuration of splitting. 60 """ 61 return SplitConfig(DEFAULT_SPLIT_NAME, {KEY_RANDOM_SEED: None}, DEFAULT_SPLIT_TEST_RATIO)
25@dataclass 26class SplitConfig(ObjectConfig): 27 """Dataset Splitting Configuration. 28 29 name: the name of the splitter. 30 params: the parameters of the splitter. 31 test_ratio: the test ratio used by the splitter. 32 """ 33 34 test_ratio: float 35 36 def get_split_ratio_string(self) -> str: 37 """Get the split ratio percentages formatted as a string. 38 39 Returns: 40 a string containing the split ratio in percentages. 41 """ 42 test_perc = int(self.test_ratio * 100.0) 43 return str(100 - test_perc) + '/' + str(test_perc) 44 45 def to_yml_format(self) -> Dict[str, Any]: 46 """Format splitting configuration to a yml compatible dictionary. 47 48 Returns: 49 a dictionary containing the splitting configuration. 50 """ 51 yml_format = ObjectConfig.to_yml_format(self) 52 yml_format[KEY_SPLIT_TEST_RATIO] = self.test_ratio 53 return yml_format
Dataset Splitting Configuration.
name: the name of the splitter. params: the parameters of the splitter. test_ratio: the test ratio used by the splitter.
36 def get_split_ratio_string(self) -> str: 37 """Get the split ratio percentages formatted as a string. 38 39 Returns: 40 a string containing the split ratio in percentages. 41 """ 42 test_perc = int(self.test_ratio * 100.0) 43 return str(100 - test_perc) + '/' + str(test_perc)
Get the split ratio percentages formatted as a string.
Returns: a string containing the split ratio in percentages.
45 def to_yml_format(self) -> Dict[str, Any]: 46 """Format splitting configuration to a yml compatible dictionary. 47 48 Returns: 49 a dictionary containing the splitting configuration. 50 """ 51 yml_format = ObjectConfig.to_yml_format(self) 52 yml_format[KEY_SPLIT_TEST_RATIO] = self.test_ratio 53 return yml_format
Format splitting configuration to a yml compatible dictionary.
Returns: a dictionary containing the splitting configuration.
56def create_default_split_config() -> SplitConfig: 57 """Create the default split configuration. 58 59 Returns: 60 the default configuration of splitting. 61 """ 62 return SplitConfig(DEFAULT_SPLIT_NAME, {KEY_RANDOM_SEED: None}, DEFAULT_SPLIT_TEST_RATIO)
Create the default split configuration.
Returns: the default configuration of splitting.