Jointly Learning Explainable Rules for Recommendation with Knowledge Graph

Overview

RuleRec

These are our datasets and implementation for the paper:

Weizhi Ma, Min Zhang, Yue Cao, Woojeong Jin, Chenyang Wang, Yiqun Liu, Shaoping Ma, and Xiang Ren. 2019. Jointly Learning Explainable Rules for Recommendation with Knowledge Graph. In TheWebConf'19.

Please cite our paper if you use our datasets or codes. Thanks!

@inproceedings{ma2019jointly,
  title={Jointly Learning Explainable Rules for Recommendation with Knowledge Graph},
  author={Ma, Weizhi and Zhang, Min and Cao, Yue and Jin, Woojeong and Wang, Chenyang and Liu, Yiqun and Ma, Shaoping and Ren, Xiang},
  booktitle={The World Wide Web Conference},
  pages={1210--1221},
  year={2019},
  organization={ACM}
}

If you have any problem about this work, you can contact Weizhi Ma (mawz12 AT hotmail.com).

RuleRec Datasets

The constructed datasets (two scenarios: Amazon cellphone and Amazon electronic) can be found here, which contain several parts:

Recommendation Data:

train.txt, test.txt: user-item interaction data.

Formatting: 
	user id \t item id

item_dic.txt: A python dic, key = item id in Amazon, value = item id here.

Item Attributes:

title.txt, brand.txt, description.txt: item attributes.

Formatting: 
	item id in Amazon \t the title/brand/description of this item

Item Associations:

also_buy.txt, also_view.txt, buy_after_view.txt, buy_together.txt: item associations.

Formatting:
	item id in Amazon \t items that have also\_buy/also\_view/buy\_after\_view/buy\_together association with this item, split by ' '

Entity Linking Data:

title_entities.txt, brand_entities.txt, description_entities.txt: entity linking results on freebase.

Formatting:
	item id in Amazon \t entity name \t entity id in Freebase

Path data:

KGData/*/rule_score.txt: As Freebase is an extremely large knowledge graph, only the related paths in the knowledge graph are recorded in this file. The head and tail entity of each path linked by at least one item.

training_pairs.txt and usercandidates.txt are two files sampled for rule learning and recommendation. You can replace them with other sampling results. The formatting of training_pairs.txt is 'user id : [positive item id, negative item id]'.



Besides, the original Amazon datasets (including user-item interaction history and item associations) are provided by Professor Mcauley. You can download them here.

Rule Learning Codes

If you want to use these codes, you should download RuleRec dataset and put them together first.

getItemItemDic.py: Enumerate all possible rules.

selectRules.py: Rule selection (rule features for jointly learning will also be generated in this step).

getFeatures.py: Calculate features based on the selected rules for item recommendation.

Environments: Python 3.6.3

sklearn = 0.19.1

numpy = 1.13.3

# Example:
> python getItemItemDic.py Cellphone abu
> python selectRules.py Cellphone abu 50
> python getFeatures.py Cellphone abu 50

RuleRec(BPRMF) Codes:

This implementation is based on MyMediaLiteJava. Both codes and jar file are provided.

The evaluation datasets can be downloaded from here, which is generated from RuleRec Data and contains both rule selection features and rule features.

Environments: Java, version 1.6 or later

# Example 1: Use Cellphone dataset
> java -jar BPRMF.jar --recommender=BPRMF --training-file=./RuleRecInput/Cellphone/trainingSet.txt --test-file=./RuleRecInput/Cellphone/testSet.txt --candidateFile=./RuleRecInput/Cellphone/candidates.txt --trainingPairFile=./RuleRecInput/Cellphone/trainingPairs.txt --trainingFeatures=./RuleRecInput/Cellphone/trainingFeatures.txt --testFeatures=./RuleRecInput/Cellphone/testFeatures.txt --learningRate=0.1 --usermodel=0 --iter-times=30 --rule-weight=0.005  --ruleWeightNumber=200 --resultFile=result.txt 
# output:recall@5=0.34968 recall@10=0.48024 NDCG@10=0.28287 [email protected] num_users=27840 num_items=100 num_lists=27840

# Example 2: Use Cellphone dataset with jointly learning
> java -jar BPRMF.jar --recommender=BPRMF --training-file=./RuleRecInput/Cellphone/trainingSet.txt --test-./RuleRecInput/Cellphone/testSet.txt --candidateFile=./RuleRecInput/Cellphone/candidates.txt --trainingPairFile=./RuleRecInput/Cellphone/trainingPairs.txt --trainingFeatures=./RuleRecInput/Cellphone/trainingFeatures.txt --testFeatures=./RuleRecInput/Cellphone/testFeatures.txt --learningRate=0.1 --usermodel=0 --iter-times=30 --rule-weight=0.005  --ruleWeightNumber=200 --resultFile=result.txt --trainTogether=2  --lossType=sigmoid --lossCombineRate=0.2 --ruleselectTrain=./RuleRecInput/Cellphone/ruleselect/ --ruleselectResult=./RuleRecInput/Cellphone/ruleselect/ 
# output:recall@5=0.36430 recall@10=0.49429 NDCG@10=0.29536 MRR=@10=0.23214 num_users=27840 num_items=100 num_lists=27840

# Example 3: Use Electronic dataset
> java -jar BPRMF.jar --recommender=BPRMF --training-file=./RuleRecInput/Electronic/trainingSet.txt --test-file=./RuleRecInput/Electronic/testSet.txt --candidateFile=./RuleRecInput/Electronic/candidates.txt --trainingPairFile=./RuleRecInput/Electronic/trainingPairs.txt --trainingFeatures=./RuleRecInput/Electronic/trainingFeatures.txt --testFeatures=./RuleRecInput/Electronic/testFeatures.txt --learningRate=0.05 --ruleWeightNumber=200 --usermodel=0 --iter-times=30 --rule-weight=0.01 --resultFile=result.txt 
# output:recall@5=0.20694 recall@10=0.29726 NDCG@10=0.17284 MRR=@10=0.13483 num_users=18223 num_items=100 num_lists=18223

# Example 4: Use Electronic dataset with jointly learning
> java -jar BPRMF.jar --recommender=BPRMF --training-file=./RuleRecInput/Electronic/trainingSet.txt --test-file=./RuleRecInput/Electronic/testSet.txt --candidateFile=./RuleRecInput/Electronic/candidates.txt --trainingPairFile=./RuleRecInput/Electronic/trainingPairs.txt --trainingFeatures=./RuleRecInput/Electronic/trainingFeatures.txt --testFeatures=./RuleRecInput/Electronic/testFeatures.txt --learningRate=0.05 --ruleWeightNumber=200 --usermodel=0 --iter-times=30 --rule-weight=0.01 --resultFile=result.txt --trainTogether=2  --lossType=sigmoid --lossCombineRate=0.005 --ruleselectTrain=./RuleRecInput/Electronic/ruleselect/ --ruleselectResult=./RuleRecInput/Electronic/ruleselect/ 
# output:recall@5=0.20798 recall@10=0.29979 NDCG@10=0.17407 MRR=@10=0.13570 num_users=18223 num_items=100 num_lists=18223
You might also like...
E-Commerce recommender demo with real-time data and a graph database
E-Commerce recommender demo with real-time data and a graph database

🔍 E-Commerce recommender demo 🔍 This is a simple stream setup that uses Memgraph to ingest real-time data from a simulated online store. Data is str

Code for CVPR2021 "Visualizing Adapted Knowledge in Domain Transfer". Visualization for domain adaptation. #explainable-ai

Visualizing Adapted Knowledge in Domain Transfer @inproceedings{hou2021visualizing, title={Visualizing Adapted Knowledge in Domain Transfer}, auth

Learning Intents behind Interactions with Knowledge Graph for Recommendation, WWW2021

Learning Intents behind Interactions with Knowledge Graph for Recommendation This is our PyTorch implementation for the paper: Xiang Wang, Tinglin Hua

Product-based-recommendation-system - A product based recommendation system which uses Machine learning algorithm such as KNN and cosine similarity 3DMV jointly combines RGB color and geometric information to perform 3D semantic segmentation of RGB-D scans.
3DMV jointly combines RGB color and geometric information to perform 3D semantic segmentation of RGB-D scans.

3DMV 3DMV jointly combines RGB color and geometric information to perform 3D semantic segmentation of RGB-D scans. This work is based on our ECCV'18 p

Elliot is a comprehensive recommendation framework that analyzes the recommendation problem from the researcher's perspective.
Elliot is a comprehensive recommendation framework that analyzes the recommendation problem from the researcher's perspective.

Comprehensive and Rigorous Framework for Reproducible Recommender Systems Evaluation

Recommendationsystem - Movie-recommendation - matrixfactorization colloborative filtering recommendation system user
Recommendationsystem - Movie-recommendation - matrixfactorization colloborative filtering recommendation system user

recommendationsystem matrixfactorization colloborative filtering recommendation

A framework for attentive explainable deep learning on tabular data

🧠 kendrite A framework for attentive explainable deep learning on tabular data 💨 Quick start kedro run 🧱 Built upon Technology Description Links ke

A PoC Corporation Relationship Knowledge Graph System on top of Nebula Graph.
A PoC Corporation Relationship Knowledge Graph System on top of Nebula Graph.

Corp-Rel is a PoC of Corpartion Relationship Knowledge Graph System. It's built on top of the Open Source Graph Database: Nebula Graph with a dataset

In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas
In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas

CogniPy for Pandas - In-memory Graph Database and Knowledge Graph with Natural Language Interface Whats in the box Reasoning, exploration of RDF/OWL,

Codes for SIGIR'22 Paper 'On-Device Next-Item Recommendation with Self-Supervised Knowledge Distillation'

OD-Rec Codes for SIGIR'22 Paper 'On-Device Next-Item Recommendation with Self-Supervised Knowledge Distillation' Paper, saved teacher models and Andro

A Python package implementing a new model for text classification with visualization tools for Explainable AI :octocat:
A Python package implementing a new model for text classification with visualization tools for Explainable AI :octocat:

A Python package implementing a new model for text classification with visualization tools for Explainable AI 🍣 Online live demos: http://tworld.io/s

An Explainable Leaderboard for NLP
An Explainable Leaderboard for NLP

ExplainaBoard: An Explainable Leaderboard for NLP Introduction | Website | Download | Backend | Paper | Video | Bib Introduction ExplainaBoard is an i

Repository for the COLING 2020 paper "Explainable Automated Fact-Checking: A Survey."

Explainable Fact Checking: A Survey This repository and the accompanying webpage contain resources for the paper "Explainable Fact Checking: A Survey"

PyExplainer: A Local Rule-Based Model-Agnostic Technique (Explainable AI)
PyExplainer: A Local Rule-Based Model-Agnostic Technique (Explainable AI)

PyExplainer PyExplainer is a local rule-based model-agnostic technique for generating explanations (i.e., why a commit is predicted as defective) of J

PyExplainer: A Local Rule-Based Model-Agnostic Technique (Explainable AI)
PyExplainer: A Local Rule-Based Model-Agnostic Technique (Explainable AI)

PyExplainer PyExplainer is a local rule-based model-agnostic technique for generating explanations (i.e., why a commit is predicted as defective) of J

CLASSIX is a fast and explainable clustering algorithm based on sorting
CLASSIX is a fast and explainable clustering algorithm based on sorting

CLASSIX Fast and explainable clustering based on sorting CLASSIX is a fast and explainable clustering algorithm based on sorting. Here are a few highl

machine learning with logical rules in Python
machine learning with logical rules in Python

skope-rules Skope-rules is a Python machine learning module built on top of scikit-learn and distributed under the 3-Clause BSD license. Skope-rules a

One Stop Anomaly Shop: Anomaly detection using two-phase approach: (a) pre-labeling using statistics, Natural Language Processing and static rules; (b) anomaly scoring using supervised and unsupervised machine learning.

One Stop Anomaly Shop (OSAS) Quick start guide Step 1: Get/build the docker image Option 1: Use precompiled image (might not reflect latest changes):

Owner
null
A TensorFlow recommendation algorithm and framework in Python.

TensorRec A TensorFlow recommendation algorithm and framework in Python. NOTE: TensorRec is not under active development TensorRec will not be receivi

James Kirk 1.2k Jan 4, 2023
Persine is an automated tool to study and reverse-engineer algorithmic recommendation systems.

Persine, the Persona Engine Persine is an automated tool to study and reverse-engineer algorithmic recommendation systems. It has a simple interface a

Jonathan Soma 87 Nov 29, 2022
ToR[e]cSys is a PyTorch Framework to implement recommendation system algorithms

ToR[e]cSys is a PyTorch Framework to implement recommendation system algorithms, including but not limited to click-through-rate (CTR) prediction, learning-to-ranking (LTR), and Matrix/Tensor Embedding. The project objective is to develop a ecosystem to experiment, share, reproduce, and deploy in real world in a smooth and easy way (Hope it can be done).

LI, Wai Yin 90 Oct 8, 2022
A framework for large scale recommendation algorithms.

A framework for large scale recommendation algorithms.

Alibaba Group - PAI 880 Jan 3, 2023
Recommendation System to recommend top books from the dataset

recommendersystem Recommendation System to recommend top books from the dataset Introduction The recom.py is the main program code. The dataset is als

Vishal karur 1 Nov 15, 2021
An open source movie recommendation WebApp build by movie buffs and mathematicians that uses cosine similarity on the backend.

Movie Pundit Find your next flick by asking the (almost) all-knowing Movie Pundit Jump to Project Source » View Demo · Report Bug · Request Feature Ta

Kapil Pramod Deshmukh 8 May 28, 2022
Implementation of a hadoop based movie recommendation system

Implementation-of-a-hadoop-based-movie-recommendation-system 通过编写代码,设计一个基于Hadoop的电影推荐系统,通过此推荐系统的编写,掌握在Hadoop平台上的文件操作,数据处理的技能。windows 10 hadoop 2.8.3 p

汝聪(Ricardo) 5 Oct 2, 2022
Books Recommendation With Python

Books-Recommendation Business Problem During the last few decades, with the rise

Çağrı Karadeniz 7 Mar 12, 2022
Bert4rec for news Recommendation

News-Recommendation-system-using-Bert4Rec-model Bert4rec for news Recommendation

saran pandian 2 Feb 4, 2022
Graph Neural Networks for Recommender Systems

This repository contains code to train and test GNN models for recommendation, mainly using the Deep Graph Library (DGL).

null 217 Jan 4, 2023