Skip to Content
Python Machine Learning Cookbook
book

Python Machine Learning Cookbook

by Prateek Joshi, Vahid Mirjalili
June 2016
Beginner to intermediate
304 pages
6h 24m
English
Packt Publishing
Content preview from Python Machine Learning Cookbook

Finding similar users in the dataset

One of the most important tasks in building a recommendation engine is finding users that are similar. This guides in creating the recommendations that will be provided to these users. Let's see how to build this.

How to do it…

  1. Create a new Python file, and import the following packages:
    import json
    import numpy as np
    
    from pearson_score import pearson_score
  2. Let's define a function to find similar users to the input user. It takes three input arguments: the database, input user, and the number of similar users that we are looking for. Our first step is to check whether the user is present in the database. If the user exists, we need to compute the Pearson correlation score between this user and all the other users ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Machine Learning Cookbook - Second Edition

Python Machine Learning Cookbook - Second Edition

Giuseppe Ciaburro, Prateek Joshi
Python: Real World Machine Learning

Python: Real World Machine Learning

Prateek Joshi, John Hearty, Bastiaan Sjardin, Luca Massaron, Alberto Boschetti

Publisher Resources

ISBN: 9781786464477Supplemental Content