def __init__(self, num_popular_ids): super().__init__() self.num_popular_ids = num_popular_ids checks.check_types(self.num_popular_ids, int, var_name="num_popular_ids") checks.check_value(self.num_popular_ids, 0, 100, True, False, var_name="num_popular_ids") self.orders = dict() self.most_popular_goods = dict() self.most_popular_good_ids = list() self.max_good_id = 0
def __init__(self, existing_parsed_json_dict=None, config_filename="ml_config.json"): """ Constructor which opens config file and parses it. :param existing_parsed_json_dict: dict, optional (default=None). If config file was parsed, you can pass it to this class. :param config_filename: str, optional(default="ml_config.json"). Name of the json file with configuration. """ if existing_parsed_json_dict is None: checks.check_types(config_filename, str, var_name="config_filename") with open(config_filename, "r") as f: self._parsed_json = json.loads(f.read()) else: checks.check_types(existing_parsed_json_dict, dict, var_name="existing_parsed_json_dict") self._parsed_json = copy.deepcopy(existing_parsed_json_dict)
def __init__(self, proportion=0.7, raw_date=True, n_rows=None, num_popular_ids=5, debug=False): self._train_samples_num = 0 self._list_of_instances = [] self._list_of_labels = [] self._list_of_samples = [] self._help_data = dict() self._chknums = list() self._most_popular_good_ids = list() self._answers_for_train = list() self._proportion = proportion checks.check_types(self._proportion, float, var_name="proportion") checks.check_value(self._proportion, 0.0, 1.0, True, False, var_name="proportion") self._raw_date = raw_date checks.check_types(self._raw_date, bool, var_name="raw_date") self._n_rows = n_rows checks.check_types(self._n_rows, type(None), int, var_name="n_rows") if self._n_rows is not None: checks.check_value(self._n_rows, 0, None, var_name="n_rows") self._num_popular_ids = num_popular_ids checks.check_types(self._num_popular_ids, int, var_name="num_popular_ids") self._debug = debug checks.check_types(self._debug, bool, var_name="debug")