This is a simple model for Recommender System pased on sql server as a datasource.
-
Posts Table (dbo.Posts): Contains information about each post.
- Id: Unique identifier for each post.
- Title: The title of the post.
- Category: The category to which the post belongs (e.g., "programming").
-
PostViews Table (dbo.PostViews): Tracks user interactions with posts.
- **UserId: **Foreign key linking to the Users table, identifying the user.
- PostId: Foreign key linking to the Posts table, identifying the post.
- Interest: A column indicating the level of interest a user has shown in a post, possibly represented as an integer score.
-
Users Table (dbo.Users): Contains user information.
- Id: Unique identifier for each user.
- FullName: Full name of the user.
- Gender: Gender of the user.
1- Data Collection:
- The recommender system uses the PostViews table to gather data on user interactions with posts. Each entry in PostViews represents a specific interaction where a user (identified by UserId) viewed or engaged with a post (identified by PostId).
- The Interest column records the level of engagement or preference. Higher values might indicate greater interest or more positive feedback, while lower values could suggest less interest.
2- User-Post Interaction Matrix:
- The recommender model builds a user-post interaction matrix where each row represents a user and each column represents a post.
- The values in this matrix are derived from the Interest column in PostViews. For instance, if a user showed a high level of interest in a post, the corresponding cell in the matrix will have a higher value.
3- Generating Recommendations:
The model utilizes this matrix to make recommendations. Common approaches include:
- Collaborative Filtering: Recommends posts that similar users (with similar interest patterns) have liked.
- The other approaches will be implemented soon
4-Prediction of Interest Scores:
The model predicts which posts a user might be interested in by estimating the Interest score for unseen posts. Posts with higher predicted scores are more likely to be recommended to the user.
- Create A Database Called :
[post-reccomendation-model]
- Execute the Script in the File
DataBase.sql
- Fix the Connection string with your own server info at the
post-reccomendation-model.py
Important
Make Sure you have c++ installed.
-
After closing the project, Open the base directory containing the file
requirements.txt
-
Run this Command To create Virtual Environment
python -m venv env
-
Activate the Virtual Environment using the command
./env/scripts/activate
-
Now in your terminal you should see this means the Virtual Environment is active.
-
Now Run to install the packages related to the project
pip install -r requirements.txt
-
Done! you can run your Project Now, Here is what the Result looks like :
The following exmplains the result of the predection
- Post Title
- The distance between the user and the post (positive correlation)
- Post Id at the Database
- Post Category at the database (this one is not yet used in the model yet, for now we are focusing only on users not content)
- Recommended based on user based on what user the this recommendation has been generated
Metric | Fold 1 | Fold 2 | Fold 3 | Fold 4 | Fold 5 | Mean | Std |
---|---|---|---|---|---|---|---|
RMSE (testset) | 0.9258 | 0.9153 | 0.9219 | 0.9209 | 0.9213 | 0.9211 | 0.0034 |
MAE (testset) | 0.7175 | 0.7114 | 0.7172 | 0.7116 | 0.7141 | 0.7144 | 0.0026 |
Fit time (s) | 21.63 | 22.19 | 22.65 | 22.73 | 21.42 | 22.12 | 0.53 |
Test time (s) | 0.13 | 0.11 | 0.11 | 0.14 | 0.11 | 0.12 | 0.01 |