Skip to main content

This package will create recommendations based on content as well as user ratings and finally providing top recommendations based on both data points

Project description

Hybrid Recommender

This package usage multiple algorithms and parameters to accomodate different set of use cases.

Parameters:

  • item_clusters: int The number of clusters for item matrix generation. This parameter can be tuned
  • top_results: int Number of recommendations needed. Default value is 10
  • ratings_weightage: int Weightage for user ratings score. Default is 1
  • content_weightage: int Weightage for content score. Default is 1
  • null_rating_replace: str Value to be used as replacement for missing ratings. Default is 'mean', other acceptable values are 'zero','one', and 'min'

Returns:

DataFrame having top recommended results for the list of users

Approach:

  1. Create an instance of the hybrid recommender class mr = hybrid_recommender()

  2. Call fit method on the defined object by passing on ratings and content data mr.fit(ratings_df,content_df)

  3. Call the predict method recommended_df = mr.predict()


Example

Create Ratings DataFrame

item_id = [1,7,9,10,12,2,4,6,8,10,12,3,6,9,12,14,10,13,12,14,11,2,5,7,8,9,10,12]
user_id = [1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,5]
rating = [4,5,2,3,5,2,3,2,3,4,4,5,1,2,3,1,2,4,5,3,5,3,1,3,5,3,5,3]
ratings = pd.DataFrame({'user_id':user_id,'item_id':item_id,'rating':rating})

Create Content DataFrame

items = [1,2,3,4,5,6,7,8,9,10,11,12,13,14]
cols = ['col1','col2','col3','col4','col5']
feats =[[1,0,0,1,1],
       [1,1,0,0,1],
       [0,1,1,0,0],
       [0,1,1,1,0],
       [1,0,1,1,1],
       [1,1,1,0,0],
       [0,1,0,1,0],
       [0,0,0,1,0],
       [0,1,1,0,0],
       [1,1,1,0,1],
       [0,0,0,1,1],
       [0,1,0,1,0],
       [0,1,1,0,1],
       [0,0,1,1,1],]
item_df = pd.DataFrame(feats,index=items,columns=cols)

Ratings DataFrame

ratings.head()

Content DataFrame

item_df.head()

Fitting and prediction

Creating the recommender object

my_recommender = hybrid_recommenders(item_clusters=4,top_results=5)

Fitting the data

my_recommender.fit(ratings,item_df)

Recommend for few users

my_recommender.predict([1,2,3])

Recommendations for All users

my_recommender.predict()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hybrid_recommender-0.4.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

hybrid_recommender-0.4-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page