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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file hybrid_recommender-0.4.tar.gz.

File metadata

  • Download URL: hybrid_recommender-0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for hybrid_recommender-0.4.tar.gz
Algorithm Hash digest
SHA256 c32167d833f74158bc0d538297927daa981218f3a2e3e475215181ed338f5bde
MD5 5a31f586cdbaef5491bcc0abc2bd0a2a
BLAKE2b-256 55c066ea9a7abc87c2a6e025e8e82a30010003ce6326e8038b1364ff4144b946

See more details on using hashes here.

File details

Details for the file hybrid_recommender-0.4-py3-none-any.whl.

File metadata

  • Download URL: hybrid_recommender-0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for hybrid_recommender-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a630a95d457f617fec7eecde868dd58a1b982d7ec11c15bb5f336f93f81e8858
MD5 f08d4c87e0c09d824e23f7426c8fdb5a
BLAKE2b-256 ccd6f3872e05f4fe0caa743996ca769b49303156e0f0070d7ae3911068f9e994

See more details on using hashes here.

Supported by

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