NicolasHug / Surprise

A Python scikit for building and analyzing recommender systems
http://surpriselib.com
BSD 3-Clause "New" or "Revised" License
6.34k stars 1.01k forks source link

Is there a way to add custom similarity metrics? #410

Open agb2k opened 2 years ago

agb2k commented 2 years ago

I was planning on implementing a k-Furthest Neighbours algorithm which is the inverse of the existing kNN but with an inverse similarity metric. How would I implement this? Is there a way to add custom metrics?

NicolasHug commented 2 years ago

Hi @agb2k, the entry-point for similarity metrics is this function

https://github.com/NicolasHug/Surprise/blob/3414ad931c1ef4630fdaf2a0ca6b8cd3cd1cbc1b/surprise/prediction_algorithms/algo_base.py#L205

Take a look at the internals. You might want to implement your function in Cython to speed it up.