sberbank-ai-lab / RePlay

RecSys Library
https://sberbank-ai-lab.github.io/RePlay/
Apache License 2.0
68 stars 6 forks source link

Create indexer save/load functions #80

Closed Darel13712 closed 2 years ago

Darel13712 commented 2 years ago

with indexers extracted we now need separate functions to save indexer. something like

def save_index(indexer, path: str):
    self.user_type = users.schema[self.user_col].dataType
    self.item_type = items.schema[self.item_col].dataType
    indexer.user_indexer.save(join(path, "user_indexer"))
    indexer.item_indexer.save(join(path, "item_indexer"))
    indexer.inv_user_indexer.save(join(path, "inv_user_indexer"))
    indexer.inv_item_indexer.save(join(path, "inv_item_indexer"))

def load_index(path: str):
    indexer = Indexer()
    model.user_indexer = StringIndexerModel.load(join(path, "user_indexer"))
    model.item_indexer = StringIndexerModel.load(join(path, "item_indexer"))
    model.inv_user_indexer = IndexToString.load(join(path, "inv_user_indexer"))
    model.inv_item_indexer = IndexToString.load(join(path, "inv_item_indexer"))