Exemple #1
0
    def __init__(self, config):
        """Init GroceryData Class.

        Args:
            config:
        """
        self.config = config
        self.n_users = 0
        self.n_items = 0
        self.sub_set = 0
        self.random_dim = 512
        # subset of the dataset. use a small set of users and items if >0, otherwise use full dataset
        if "sub_set" in config:
            self.sub_set = config["dataset"]["sub_set"]
        if "random_dim" in config:
            self.random_dim = config["model"]["random_dim"]
        # data preprocessing for training and test data
        # To be replaced with new data method
        train, valid, test = load_split_dataset(config)
        self.train = self._intersect_train_test(train, test[0])
        self.n_train = len(self.train.index)
        self.valid = self._reindex_list(valid)
        self.test = self._reindex_list(test)
        self.item_sampler = AliasTable(
            self.train[DEFAULT_ITEM_COL].value_counts().to_dict())
        self.user_sampler = AliasTable(
            self.train[DEFAULT_USER_COL].value_counts().to_dict())
        if ("item_fea_type" in self.config["dataset"]
                or "user_fea_type" in self.config["dataset"]):
            self.init_item_fea()
            self.init_user_fea()
Exemple #2
0
 def load_dataset(self):
     """Load dataset."""
     self.data = BaseData(load_split_dataset(self.config))
     self.config["model"]["n_users"] = self.data.n_users
     self.config["model"]["n_items"] = self.data.n_items
 def load_dataset(self):
     """Load dataset."""
     split_data = load_split_dataset(self.config)
     self.data = GroceryData(split_dataset=split_data, config=self.config)
     self.config["model"]["n_users"] = self.data.n_users
     self.config["model"]["n_items"] = self.data.n_items