{"id":13774799,"url":"https://github.com/hexiangnan/neural_collaborative_filtering","last_synced_at":"2025-05-15T17:07:23.574Z","repository":{"id":39380264,"uuid":"80687858","full_name":"hexiangnan/neural_collaborative_filtering","owner":"hexiangnan","description":"Neural Collaborative Filtering","archived":false,"fork":false,"pushed_at":"2022-08-27T06:26:07.000Z","size":24377,"stargazers_count":1833,"open_issues_count":55,"forks_count":658,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-04-08T01:34:27.397Z","etag":null,"topics":["collaborative-filtering","deep-learning","recommender-system"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexiangnan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-02T02:55:58.000Z","updated_at":"2025-04-07T13:19:58.000Z","dependencies_parsed_at":"2022-07-12T17:53:31.360Z","dependency_job_id":null,"html_url":"https://github.com/hexiangnan/neural_collaborative_filtering","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexiangnan%2Fneural_collaborative_filtering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexiangnan%2Fneural_collaborative_filtering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexiangnan%2Fneural_collaborative_filtering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexiangnan%2Fneural_collaborative_filtering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexiangnan","download_url":"https://codeload.github.com/hexiangnan/neural_collaborative_filtering/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-filtering","deep-learning","recommender-system"],"created_at":"2024-08-03T17:01:30.467Z","updated_at":"2025-05-15T17:07:18.557Z","avatar_url":"https://github.com/hexiangnan.png","language":"Python","funding_links":[],"categories":["Recommender Systems"],"sub_categories":[],"readme":"# Neural Collaborative Filtering\n\nThis is our implementation for the paper:\n\nXiangnan He, Lizi Liao, Hanwang Zhang, Liqiang Nie, Xia Hu and Tat-Seng Chua (2017). [Neural Collaborative Filtering.](http://dl.acm.org/citation.cfm?id=3052569) In Proceedings of WWW '17, Perth, Australia, April 03-07, 2017.\n\nThree collaborative filtering models: Generalized Matrix Factorization (GMF), Multi-Layer Perceptron (MLP), and Neural Matrix Factorization (NeuMF). To target the models for implicit feedback and ranking task, we optimize them using log loss with negative sampling. \n\n**Please cite our WWW'17 paper if you use our codes. Thanks!** \n\nAuthor: Dr. Xiangnan He (http://www.comp.nus.edu.sg/~xiangnan/)\n\n## Environment Settings\nWe use Keras with Theano as the backend. \n- Keras version:  '1.0.7'\n- Theano version: '0.8.0'\n\n## Example to run the codes.\nThe instruction of commands has been clearly stated in the codes (see the  parse_args function). \n\nRun GMF:\n```\npython GMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --regs [0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun MLP:\n```\npython MLP.py --dataset ml-1m --epochs 20 --batch_size 256 --layers [64,32,16,8] --reg_layers [0,0,0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun NeuMF (without pre-training): \n```\npython NeuMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --layers [64,32,16,8] --reg_mf 0 --reg_layers [0,0,0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun NeuMF (with pre-training):\n```\npython NeuMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --layers [64,32,16,8] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1 --mf_pretrain Pretrain/ml-1m_GMF_8_1501651698.h5 --mlp_pretrain Pretrain/ml-1m_MLP_[64,32,16,8]_1501652038.h5\n```\n\nNote on tuning NeuMF: our experience is that for small predictive factors, running NeuMF without pre-training can achieve better performance than GMF and MLP. For large predictive factors, pre-training NeuMF can yield better performance (may need tune regularization for GMF and MLP). \n\n## Docker Quickstart\nDocker quickstart guide can be used for evaluating models quickly.\n\nInstall Docker Engine\n- [Ubuntu Installation](https://docs.docker.com/engine/installation/linux/ubuntu/)\n- [Mac OSX Installation](https://docs.docker.com/docker-for-mac/install/)\n- [Windows Installation](https://docs.docker.com/docker-for-windows/install/)\n\nBuild a keras-theano docker image \n```\ndocker build --no-cache=true -t ncf-keras-theano .\n```\n\n### Example to run the codes with Docker.\nRun the docker image with a volume (Run GMF):\n```\ndocker run --volume=$(pwd):/home ncf-keras-theano python GMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --regs [0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun the docker image with a volume (Run MLP):\n```\ndocker run --volume=$(pwd):/home ncf-keras-theano python MLP.py --dataset ml-1m --epochs 20 --batch_size 256 --layers [64,32,16,8] --reg_layers [0,0,0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun the docker image with a volume (Run NeuMF -without pre-training): \n```\ndocker run --volume=$(pwd):/home ncf-keras-theano python NeuMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --layers [64,32,16,8] --reg_mf 0 --reg_layers [0,0,0,0] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1\n```\n\nRun the docker image with a volume (Run NeuMF -with pre-training):\n```\ndocker run --volume=$(pwd):/home ncf-keras-theano python NeuMF.py --dataset ml-1m --epochs 20 --batch_size 256 --num_factors 8 --layers [64,32,16,8] --num_neg 4 --lr 0.001 --learner adam --verbose 1 --out 1 --mf_pretrain Pretrain/ml-1m_GMF_8_1501651698.h5 --mlp_pretrain Pretrain/ml-1m_MLP_[64,32,16,8]_1501652038.h5\n```\n* **Note**: If you are using `zsh` and get an error like `zsh: no matches found: [64,32,16,8]`, should use `single quotation marks` for array parameters like `--layers '[64,32,16,8]'`.\n\n### Dataset\nWe provide two processed datasets: MovieLens 1 Million (ml-1m) and Pinterest (pinterest-20). \n\ntrain.rating: \n- Train file.\n- Each Line is a training instance: userID\\t itemID\\t rating\\t timestamp (if have)\n\ntest.rating:\n- Test file (positive instances). \n- Each Line is a testing instance: userID\\t itemID\\t rating\\t timestamp (if have)\n\ntest.negative\n- Test file (negative instances).\n- Each line corresponds to the line of test.rating, containing 99 negative samples.  \n- Each line is in the format: (userID,itemID)\\t negativeItemID1\\t negativeItemID2 ...\n\nLast Update Date: December 23, 2018\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexiangnan%2Fneural_collaborative_filtering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexiangnan%2Fneural_collaborative_filtering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexiangnan%2Fneural_collaborative_filtering/lists"}