We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 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: {}
The text was updated successfully, but these errors were encountered:
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
from rectools.metrics import calc_metrics
import pandas as pd
Can you please say your OS, Python version and packages (pandas and rectools) versions?
Sorry, something went wrong.
No branches or pull requests
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:
{}
The text was updated successfully, but these errors were encountered: