The system begins its search for a book to suggest by randomly selecting a book, $A$, from the shelf. (This shelf begins with the books the user initially supplied, but it will grow as mBG recommends books that the user accepts.) Next, it fetches the $l$ books nearest to $A$, where $l$ is the number of books on the shelf, plus the number of known negative and neutral books, plus one. We remove all of the known books, and then submit the remaining books to the $k$-nearest neighbor algorithm for classification, exiting when we find one that the algorithm classified as belonging on the shelf (i.e., positive).
The $k$-nearest neighbor algorithm finds the $k$-nearest books with known classification. It counts the number of known positives, knows neutrals, and known negatives. These counts are used for two metrics. First, they are used for a simple vote: whichever count is highest is the class of this book. Second, a score is calculated for the book by subtracting the number of negative neighbors from the number of positive neighbors.
If the book is not classified as positive, we check the score to see if it is higher than the score of the highest scoring book we’ve found so far. If it is, we store it and its score before repeating this process.
If the system finds a book that the kNN algorithm classifies as belonging on the shelf, it suggests the book to the user. Otherwise, this process is repeated until kNN has been run on the books nearest each book at the shelf (drawn in a random order), and then the book with the highest score is suggested to the user instead.