Skip to main content

Recommender System using Python


Recommender systems are everywhere. Amazon recommends buys we like, google recommends searches, Youtube recommends systems and Facebook recommends people.
All of these implementations describe Recommender Systems.

There are 2 types of Recommender Systems.

Collaborative Systems - Systems that recommend information based on what you like and what the others like.

Content Based Systems- Based on what you have viewed









This is a simple ML based recommender System in python. It uses the LightFM library as the dataset


import numpy as np
from lightfm import LightFM
from fetch_lastfm import fetch_lastfm
data = fetch_lastfm()
model = LightFM(loss='warp')
model.fit(data['matrix'], epochs=30, num_threads=2)
# Get recommendationns function
def get_recommendations(model, coo_mtrx, users_ids):
n_items = coo_mtrx.shape[1]
for user in users_ids:
# TODO create known positives
# Artists the model predicts they will like
scores = model.predict(user, np.arange(n_items))
top_scores = np.argsort(-scores)[:3]
print 'Recomendations for user %s:' % user
for x in top_scores.tolist():
for artist, values in data['artists'].iteritems():
if int(x) == values['id']:
print ' - %s' % values['name']
print '\n' # Get it pretty
user_1 = raw_input('Select user_1 (0 to %s): ' % data['users'])
user_2 = raw_input('Select user_2 (0 to %s): ' % data['users'])
user_3 = raw_input('Select user_3 (0 to %s): ' % data['users'])
print '\n' # Get it pretty
get_recommendations(model, data['matrix'], [user_1, user_2, user_3])

Comments

  1. Replies
    1. Thanks ... please subscribe and share this ... stay tuned for future posts :)

      Delete
  2. We make it easier for businesses to achieve their KPI’s with personalized recommendations. We deliver highly personal, automated, and contextual insights to improve your customers’ experience and business results.https://divedeep.ai/recommendation-systems-services-and-solutions

    ReplyDelete
  3. The blog was really helpful, thanks for such quality content
    customer survey satisfaction

    ReplyDelete

Post a Comment

Popular posts from this blog

Impact of Chatbots on Human Driven sectors of business

Chatbots are Machine Learning and Deep Learning powered programs that can conduct meaningful conversations. Most of them use technical attributes like Natural Language Processing and Context Analysis to converse with a human or another chatbot. The bot is programmed to self-learn as it is introduced to supplementary dialogues and words. In consequence, as a chatbot receives new voice or textual dialogues, the number of inquiries that it can reply and the accuracy of each response it gives increases. A Chabot can converse with the user through self-embedded messaging platforms like Facebook Messenger or through various flagship Assistants such as Google Assistant, Siri or Amazon Alexa. Nowadays, chatbots are being deployed in fields where their use clearly seemed to be obvious. Firms engaging in Financial Planning, Investment Management and Expense Tracking could reap a wide array of benefits when they make use of this technology. They can have a lasting impact on human-driven sec...

Making AI Play Games

The Artificial Intelligence era has started only a while ago and it is drastically augmenting and amplifying our lives But in this sphere of development, the developers have had a big problem to test their AI. This is where great minds like Elon Musk step in and create adroit and efficient resources to test the Intelligence that we create. His vision and aspiration led to the start of OpenAI, a free open source library and a company specializing in research. They create toolkits for Deep Learning developers like us to deploy models and make AI play games. This helps us to analyze the power of the intelligence by simulating game environments.  OpenAI provides enthusiasts with 2 toolkits to work with Gym - Toolkit for comparing and developing deep reinforcement learning algorithms... Universe - A collection of gym environments to train and measure an AI's general intelligence... Today we are going to write a simple script in python to help build a ...

I'm gonna be gone for a while ...

Hey Everyone, I'm sorry for keeping this blog dry for the 2 past two months, I'm a class 10 student in the CBSE Board here in India, so naturally, all my time is devoted to mundane academic preparation. This blog will not see another post till April, but before I sign off, I wanted to tell everyone my goals and plans for 2020:- Start a podcast ( most probably ), which will mainly revolve around economics, business and tech with some tidbits and updates from my life. Launch my first ever web-product called Nadia. It's already under development. Will share a snapshot of the UI :) I'm hoping to blog a lot more, hopefully, 3 posts a month Read at least 25-30 books Sketch a lot more :P Nadia in its nascent stages Will improve on this surely ...