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:
-
Create an instance of the hybrid recommender class mr = hybrid_recommender()
-
Call fit method on the defined object by passing on ratings and content data mr.fit(ratings_df,content_df)
-
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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for hybrid_recommender-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a630a95d457f617fec7eecde868dd58a1b982d7ec11c15bb5f336f93f81e8858 |
|
MD5 | f08d4c87e0c09d824e23f7426c8fdb5a |
|
BLAKE2b-256 | ccd6f3872e05f4fe0caa743996ca769b49303156e0f0070d7ae3911068f9e994 |