-
Notifications
You must be signed in to change notification settings - Fork 148
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
[BUG] Hyperparameter tuning for next item recommenders #643
Comments
@lthoang is it something that we can try to address? |
@tqtg Up to the current release @logrkn You can apply the following snippet to iterate through your candidate list of parameters: import cornac
from cornac.data import Reader
from cornac.datasets import yoochoose
from cornac.eval_methods import NextItemEvaluation
from cornac.metrics import NDCG
from cornac.models import GRU4Rec
from cornac.hyperopt import Discrete, Continuous
from cornac.hyperopt import RandomSearch
buy_data = yoochoose.load_buy(reader=Reader(min_sequence_size=2, num_top_freq_item=30000))
item_set = set([tup[1] for tup in buy_data])
test_data = yoochoose.load_test(reader=Reader(min_sequence_size=2, item_set=item_set))
next_item_eval = NextItemEvaluation.from_splits(
train_data=buy_data[:10000],
test_data=test_data[:10000],
exclude_unknowns=True,
verbose=False,
fmt="SITJson",
)
models = [
GRU4Rec(
name="GRU4Rec_layer_{}".format(layer),
layers=[layer],
loss="bpr-max",
n_sample=2048,
n_epochs=5,
seed=123,
verbose=False
)
for layer in [64, 128, 256]
]
cornac.Experiment(eval_method=next_item_eval,
models=models,
metrics=[NDCG(20)],
show_validation=False).run() |
Thank you, I'll try that. I would be great to get hyperparameter tuning included for NextItemRecommender models in the future though as ideally I'd like to test more combinations than in this simple example. |
I'm trying to do hyperparameter tuning for a next item recommender using yoochoose data (code below) but get the following error:
ValueError: model must be a NextItemRecommender but '<class 'cornac.hyperopt.RandomSearch'>' is provided
What is the correct approach for tuning next item recommenders?
The text was updated successfully, but these errors were encountered: