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

rectools.metrics.calc_metrics method does not work #42

Open
OmarovSayan opened this issue Jul 18, 2023 · 1 comment
Open

rectools.metrics.calc_metrics method does not work #42

OmarovSayan opened this issue Jul 18, 2023 · 1 comment

Comments

@OmarovSayan
Copy link

OmarovSayan commented Jul 18, 2023

rectools.metrics.calc_metrics method does not work when trying to run it i got empty result.

code that i tried to run :

from rectools import Columns
from rectools.metrics import Accuracy, NDCG
reco = pd.DataFrame(
{
Columns.User: [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4],
Columns.Item: [7, 8, 1, 2, 1, 2, 3, 4, 1, 2, 3],
Columns.Rank: [1, 2, 1, 2, 1, 2, 3, 4, 1, 2, 3],
}
)
interactions = pd.DataFrame(
{
Columns.User: [1, 1, 2, 3, 3, 3, 4, 4, 4],
Columns.Item: [1, 2, 1, 1, 3, 4, 1, 2, 3],
Columns.Datetime: [1, 1, 1, 1, 1, 2, 2, 2, 2],
}
)
split_dt = 2
df_train = interactions.loc[interactions[Columns.Datetime] < split_dt]
df_test = interactions.loc[interactions[Columns.Datetime] >= split_dt]
metrics = {
'ndcg@1': NDCG(k=1),
'accuracy@1': Accuracy(k=1)
}
calc_metrics(
metrics,
reco=reco,
interactions=df_test,
prev_interactions=df_train,
catalog=df_train[Columns.Item].unique()
)

Output:
{}

@feldlime
Copy link
Collaborator

Hi @OmarovSayan, I reproduced your code (added only missed imports from rectools.metrics import calc_metrics and import pandas as pd. It works for me

Can you please say your OS, Python version and packages (pandas and rectools) versions?

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