Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to save Dataset()? #698

Open
Lulu20220 opened this issue Aug 23, 2023 · 1 comment
Open

Is there a way to save Dataset()? #698

Lulu20220 opened this issue Aug 23, 2023 · 1 comment

Comments

@Lulu20220
Copy link

I have a trained model saved as a pickle file. My model has both user and item features.
When I load the model, I can make predictions for seen users by calling
pickled_model.predict(user_ids = [0], item_ids =[0])

But, I want to adjust it to a cold start problem, making predictions for new users. In this case, it requires to have dataset.fit_partial() , where the dataset should be fitted in the old dataset. It there a way to save and retrieve the dataset? Or we need to refit it every time before calling fit_partial()

@Saba101
Copy link

Saba101 commented Sep 14, 2023

Did you try saving the dataset as pickle? I think it should work:

import pickle
pkl_ext = '.pkl'
dataset_filename = 'lightfm_dataset_abc' + pkl_ext

# Save the dataset to the file using pickle
with open(dataset_filename, 'wb') as dataset_file:
    pickle.dump(dataset,  dataset_file)

And when you want to load dataset:

# Load the dataset from the specified file path using pickle
with open(dataset_filename, 'rb') as dataset_file:
    dataset = pickle.load(dataset_file)

# Fit more data to the loaded dataset
# For example, you can add more user-item interactions:
# dataset.fit_partial(users=new_user_ids, items=new_item_ids)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants