I am trying to predict the extent of suitability (0.5 to 3.5) for a section of non-fiction books based on a few parameters. This is for a set of subscribers that we want to predict books suitability: based on score I plan to display star ratings: most suitable(2.5 to 3.5), mildly suitable(1.5 to 2.5), not relevant (0.5 to 1.5).

Example dimensions:

  • price: continuous

  • subject: categorical (humor, adventure, mystery, sports, non-fiction)

  • hardbound: binary

  • recency of book: categorical

We initially start with a default profile for all user and after getting feedback from him (as 1, 2 or 3 stars), build a customized profile.

Given that we will initially start with small volume of user data, looking to do a k-NN to identify nearest neighbors on the dimensions, and calculate suitability score based on weighted suitability of those neighbors.

Given the categorical data, I wanted to create custom distance matrices so that I could provide the relative distance between categories. (e.g. to indicate that humor and adventure are close preferences; sports and nonfiction are far apart)

Two questions:

  1. Is my current approach valid- any feedback or pointers?
  2. What specific k-NN implementation (package) would allow me to provide my custom distance matrices?

1 Answer 1


I would personally take a look at collaborative filtering as this will take into account the information of the user itself, but also the information of similar users. If let's say, my best friend and I have the same taste in books, knowing his taste can help you guess mine! I'd recommend watching the Andrew Ng lectures on Coursera about recommender systems.

KNN might seem like a natural choice if you don't know about recommender systems (I have been there!) but please, make sure to read about them before you decide to use KNN.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.