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

Recommendations intersection metric #95

Closed
blondered opened this issue Feb 21, 2024 · 0 comments · Fixed by #148
Closed

Recommendations intersection metric #95

blondered opened this issue Feb 21, 2024 · 0 comments · Fixed by #148
Labels
enhancement New feature or request

Comments

@blondered
Copy link
Collaborator

Feature Description

Metric to measure intersection in user-item (or item-item) pairs between recommendation lists.

Why this feature?

It helps for both candidate-generators selection in pipelines, and for popularity bias measurement.

Additional context


intersecton = Intersection(k=10)

# one metric
intersecton_value = intersecton.calc(reco=recos, ref_recos=ref_recos)
intersecton_per_user = precision.calc_per_user(reco=recos, ref_recos=ref_recos)

# calc_metrics
calc_metrics(
    metrics = {"precision": precision, "intersection": intersecton},
    reco=recos,
    interactions=df_test,
    ref_recos: Union[pd.Datafame, Dict[Hashable, pd.DataFrame]]=ref_recos
)

We can keep ref_recos a simple pd.DataFrame to calculate intersections with one algorithm.
For multiple intersection calculations we can pass multiple models recommendations in a dict:
ref_recos = {"one": ref_recos_one, "two": ref_recos_two}
Result dict from calc_metrics will have intersection_one and intersection_two keys if ref_recos is a dict (merging keys from metrics and ref_recos.

# cross_validate
cv_results = cross_validate(
    dataset=dataset,
    splitter=splitter,
    models=models,
    metrics=metrics,
    k=10,
    filter_viewed=True,
    ref_models=["one", "two"], # here we just select keys from `models` argument
    validate_ref_models=False  # optionally exclude ref_models from other metrics calculation
)
@blondered blondered added the enhancement New feature or request label Feb 21, 2024
@blondered blondered changed the title Recommendations intersection measurement Recommendations intersection metric Feb 21, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 21, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 22, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 22, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 22, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 22, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 22, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 29, 2024
azatnv added a commit to azatnv/RecTools that referenced this issue May 31, 2024
blondered pushed a commit that referenced this issue May 31, 2024
Added intersection metric
Closes #95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant