Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +8 -0
- .idea/.gitignore +8 -0
- .idea/SimGCL-MixGCF-main.iml +12 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +7 -0
- .idea/modules.xml +8 -0
- .idea/workspace.xml +101 -0
- README.md +202 -0
- SELFRec.py +28 -0
- __pycache__/SELFRec.cpython-313.pyc +0 -0
- __pycache__/SELFRec.cpython-38.pyc +0 -0
- base/__init__.py +0 -0
- base/__pycache__/__init__.cpython-38.pyc +0 -0
- base/__pycache__/graph_recommender.cpython-38.pyc +0 -0
- base/__pycache__/recommender.cpython-38.pyc +0 -0
- base/__pycache__/torch_interface.cpython-38.pyc +0 -0
- base/graph_recommender.py +133 -0
- base/recommender.py +77 -0
- base/seq_recommender.py +0 -0
- base/ssl_interface.py +0 -0
- base/tf_interface.py +20 -0
- base/torch_interface.py +12 -0
- conf/ASReP.conf +0 -0
- conf/BERT4Rec.conf +0 -0
- conf/BUIR.conf +12 -0
- conf/CLS4Rec.conf +0 -0
- conf/CLUE.conf +0 -0
- conf/COTREC.conf +0 -0
- conf/DHCN.conf +0 -0
- conf/DirectAU.conf +12 -0
- conf/DuoRec.conf +0 -0
- conf/FRGCF.conf +17 -0
- conf/LightGCN.conf +12 -0
- conf/MF.conf +11 -0
- conf/MHCN.conf +13 -0
- conf/MixGCF.conf +12 -0
- conf/NCL.conf +12 -0
- conf/SEPT.conf +13 -0
- conf/SGL.conf +12 -0
- conf/SRMA.conf +0 -0
- conf/SSL4Rec.conf +12 -0
- conf/SelfCF.conf +12 -0
- conf/SimGCL.conf +12 -0
- conf/XSimGCL.conf +12 -0
- conf/__init__.py +0 -0
- data/__init__.py +0 -0
- data/__pycache__/__init__.cpython-313.pyc +0 -0
- data/__pycache__/__init__.cpython-38.pyc +0 -0
- data/__pycache__/data.cpython-38.pyc +0 -0
- data/__pycache__/graph.cpython-38.pyc +0 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
dataset/amazon-kindle/train.txt filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
dataset/iFashion/train.txt filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
dataset/ml-1M/ratings.dat filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
dataset/yelp2018/train.txt filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
test/MNIST/data/data/MNIST/raw/t10k-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
test/MNIST/data/data/MNIST/raw/train-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
test/MNIST/data/MNIST/raw/t10k-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
test/MNIST/data/MNIST/raw/train-images-idx3-ubyte filter=lfs diff=lfs merge=lfs -text
|
.idea/.gitignore
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 默认忽略的文件
|
| 2 |
+
/shelf/
|
| 3 |
+
/workspace.xml
|
| 4 |
+
# 基于编辑器的 HTTP 客户端请求
|
| 5 |
+
/httpRequests/
|
| 6 |
+
# Datasource local storage ignored files
|
| 7 |
+
/dataSources/
|
| 8 |
+
/dataSources.local.xml
|
.idea/SimGCL-MixGCF-main.iml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<module type="PYTHON_MODULE" version="4">
|
| 3 |
+
<component name="NewModuleRootManager">
|
| 4 |
+
<content url="file://$MODULE_DIR$" />
|
| 5 |
+
<orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
|
| 6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
| 7 |
+
</component>
|
| 8 |
+
<component name="PyDocumentationSettings">
|
| 9 |
+
<option name="format" value="PLAIN" />
|
| 10 |
+
<option name="myDocStringFormat" value="Plain" />
|
| 11 |
+
</component>
|
| 12 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<component name="InspectionProjectProfileManager">
|
| 2 |
+
<settings>
|
| 3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
| 4 |
+
<version value="1.0" />
|
| 5 |
+
</settings>
|
| 6 |
+
</component>
|
.idea/misc.xml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="Black">
|
| 4 |
+
<option name="sdkName" value="Python 3.8" />
|
| 5 |
+
</component>
|
| 6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
| 7 |
+
</project>
|
.idea/modules.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="ProjectModuleManager">
|
| 4 |
+
<modules>
|
| 5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/SimGCL-MixGCF-main.iml" filepath="$PROJECT_DIR$/.idea/SimGCL-MixGCF-main.iml" />
|
| 6 |
+
</modules>
|
| 7 |
+
</component>
|
| 8 |
+
</project>
|
.idea/workspace.xml
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<project version="4">
|
| 3 |
+
<component name="AutoImportSettings">
|
| 4 |
+
<option name="autoReloadType" value="SELECTIVE" />
|
| 5 |
+
</component>
|
| 6 |
+
<component name="ChangeListManager">
|
| 7 |
+
<list default="true" id="dd4d90c5-45d4-49da-988c-4daae03a1236" name="更改" comment="" />
|
| 8 |
+
<option name="SHOW_DIALOG" value="false" />
|
| 9 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
| 10 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
| 11 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
| 12 |
+
</component>
|
| 13 |
+
<component name="FileTemplateManagerImpl">
|
| 14 |
+
<option name="RECENT_TEMPLATES">
|
| 15 |
+
<list>
|
| 16 |
+
<option value="Python Script" />
|
| 17 |
+
</list>
|
| 18 |
+
</option>
|
| 19 |
+
</component>
|
| 20 |
+
<component name="FlaskConsoleOptions" custom-start-script="import sys; print('Python %s on %s' % (sys.version, sys.platform)); sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) from flask.cli import ScriptInfo, NoAppException for module in ["main.py", "wsgi.py", "app.py"]: try: locals().update(ScriptInfo(app_import_path=module, create_app=None).load_app().make_shell_context()); print("\nFlask App: %s" % app.import_name); break except NoAppException: pass">
|
| 21 |
+
<envs>
|
| 22 |
+
<env key="FLASK_APP" value="app" />
|
| 23 |
+
</envs>
|
| 24 |
+
<option name="myCustomStartScript" value="import sys; print('Python %s on %s' % (sys.version, sys.platform)); sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS]) from flask.cli import ScriptInfo, NoAppException for module in ["main.py", "wsgi.py", "app.py"]: try: locals().update(ScriptInfo(app_import_path=module, create_app=None).load_app().make_shell_context()); print("\nFlask App: %s" % app.import_name); break except NoAppException: pass" />
|
| 25 |
+
<option name="myEnvs">
|
| 26 |
+
<map>
|
| 27 |
+
<entry key="FLASK_APP" value="app" />
|
| 28 |
+
</map>
|
| 29 |
+
</option>
|
| 30 |
+
</component>
|
| 31 |
+
<component name="ProjectColorInfo">{
|
| 32 |
+
"associatedIndex": 1
|
| 33 |
+
}</component>
|
| 34 |
+
<component name="ProjectId" id="3B3yC7nY6R85lbJag8WZVQZNEAw" />
|
| 35 |
+
<component name="ProjectViewState">
|
| 36 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
| 37 |
+
<option name="showLibraryContents" value="true" />
|
| 38 |
+
</component>
|
| 39 |
+
<component name="PropertiesComponent">{
|
| 40 |
+
"keyToString": {
|
| 41 |
+
"Python.SimGCL.executor": "Run",
|
| 42 |
+
"Python.cifar_cnn.executor": "Run",
|
| 43 |
+
"Python.main.executor": "Run",
|
| 44 |
+
"Python.mnist_mlp.executor": "Run",
|
| 45 |
+
"Python.mnist_mlp_2.executor": "Run",
|
| 46 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
| 47 |
+
"ignore.virus.scanning.warn.message": "true",
|
| 48 |
+
"last_opened_file_path": "C:/Users/11148/Desktop/SimGCL-MixGCF-main/SimGCL-MixGCF-main",
|
| 49 |
+
"node.js.detected.package.eslint": "true",
|
| 50 |
+
"node.js.detected.package.tslint": "true",
|
| 51 |
+
"node.js.selected.package.eslint": "(autodetect)",
|
| 52 |
+
"node.js.selected.package.tslint": "(autodetect)",
|
| 53 |
+
"nodejs_package_manager_path": "npm",
|
| 54 |
+
"settings.editor.selected.configurable": "preferences.lookFeel",
|
| 55 |
+
"vue.rearranger.settings.migration": "true"
|
| 56 |
+
}
|
| 57 |
+
}</component>
|
| 58 |
+
<component name="RecentsManager">
|
| 59 |
+
<key name="MoveFile.RECENT_KEYS">
|
| 60 |
+
<recent name="C:\Users\11148\Desktop\SimGCL-MixGCF-main\SimGCL-MixGCF-main\conf" />
|
| 61 |
+
<recent name="C:\Users\11148\Desktop\SimGCL-MixGCF-main\SimGCL-MixGCF-main\test\MNIST" />
|
| 62 |
+
</key>
|
| 63 |
+
</component>
|
| 64 |
+
<component name="SharedIndexes">
|
| 65 |
+
<attachedChunks>
|
| 66 |
+
<set>
|
| 67 |
+
<option value="bundled-js-predefined-d6986cc7102b-1632447f56bf-JavaScript-PY-243.25659.43" />
|
| 68 |
+
<option value="bundled-python-sdk-181015f7ab06-4df51de95216-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-243.25659.43" />
|
| 69 |
+
</set>
|
| 70 |
+
</attachedChunks>
|
| 71 |
+
</component>
|
| 72 |
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
|
| 73 |
+
<component name="TaskManager">
|
| 74 |
+
<task active="true" id="Default" summary="默认任务">
|
| 75 |
+
<changelist id="dd4d90c5-45d4-49da-988c-4daae03a1236" name="更改" comment="" />
|
| 76 |
+
<created>1773731917154</created>
|
| 77 |
+
<option name="number" value="Default" />
|
| 78 |
+
<option name="presentableId" value="Default" />
|
| 79 |
+
<updated>1773731917154</updated>
|
| 80 |
+
<workItem from="1773731918262" duration="9273000" />
|
| 81 |
+
<workItem from="1774000776991" duration="1963000" />
|
| 82 |
+
<workItem from="1774157809494" duration="146000" />
|
| 83 |
+
<workItem from="1774158010909" duration="8352000" />
|
| 84 |
+
<workItem from="1774254714928" duration="6118000" />
|
| 85 |
+
<workItem from="1774353394872" duration="4803000" />
|
| 86 |
+
<workItem from="1774504340925" duration="15310000" />
|
| 87 |
+
<workItem from="1774540874034" duration="2491000" />
|
| 88 |
+
</task>
|
| 89 |
+
<servers />
|
| 90 |
+
</component>
|
| 91 |
+
<component name="TypeScriptGeneratedFilesManager">
|
| 92 |
+
<option name="version" value="3" />
|
| 93 |
+
</component>
|
| 94 |
+
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
| 95 |
+
<SUITE FILE_PATH="coverage/SimGCL_MixGCF_main$cifar_cnn.coverage" NAME="cifar_cnn 覆盖结果" MODIFIED="1774507964067" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/CIFAR" />
|
| 96 |
+
<SUITE FILE_PATH="coverage/SimGCL_MixGCF_main$SimGCL.coverage" NAME="SimGCL 覆盖结果" MODIFIED="1773735415079" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/model/graph" />
|
| 97 |
+
<SUITE FILE_PATH="coverage/SimGCL_MixGCF_main$mnist_mlp_2.coverage" NAME="mnist_mlp_2 覆盖结果" MODIFIED="1774255754198" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/MNIST" />
|
| 98 |
+
<SUITE FILE_PATH="coverage/SimGCL_MixGCF_main$main.coverage" NAME="main 覆盖结果" MODIFIED="1774540942117" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
| 99 |
+
<SUITE FILE_PATH="coverage/SimGCL_MixGCF_main$mnist_mlp.coverage" NAME="mnist_mlp 覆盖结果" MODIFIED="1774160686056" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test/MNIST" />
|
| 100 |
+
</component>
|
| 101 |
+
</project>
|
README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<h2>Development</h2>
|
| 2 |
+
|
| 3 |
+
<h>LightGCN_1110.py</h>
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
能够同时mixup多个samples,而且权重自适应分配。
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
<h2>Requirements</h2>
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
numba==0.53.1
|
| 25 |
+
numpy==1.20.3
|
| 26 |
+
scipy==1.6.2
|
| 27 |
+
tensorflow==1.14.0
|
| 28 |
+
torch>=1.7.0
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
<h2>Usage</h2>
|
| 32 |
+
<ol>
|
| 33 |
+
<li>Configure the xx.conf file in the directory named conf. (xx is the name of the model you want to run)</li>
|
| 34 |
+
<li>Run main.py and choose the model you want to run.</li>
|
| 35 |
+
</ol>
|
| 36 |
+
|
| 37 |
+
<h2>Implemented Models</h2>
|
| 38 |
+
|
| 39 |
+
<table class="table table-hover table-bordered">
|
| 40 |
+
<tr>
|
| 41 |
+
<th>Model</th> <th>Paper</th> <th>Type</th> <th>Code</th>
|
| 42 |
+
</tr>
|
| 43 |
+
<tr>
|
| 44 |
+
<td scope="row">XSimGCL</td>
|
| 45 |
+
<td>Yu et al. <a href="https://arxiv.org/abs/2209.02544" target="_blank">XSimGCL: Towards Extremely Simple Graph Contrastive Learning for Recommendation</a>, Submitted to TKDE.
|
| 46 |
+
</td> <td>Graph + CL</d> <td>PyTorch</d>
|
| 47 |
+
</tr>
|
| 48 |
+
<tr>
|
| 49 |
+
<td scope="row">SimGCL</td>
|
| 50 |
+
<td>Yu et al. <a href="https://arxiv.org/abs/2112.08679" target="_blank">Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for Recommendation</a>, SIGIR'22.
|
| 51 |
+
</td> <td>Graph + CL</d> <td>PyTorch</d>
|
| 52 |
+
</tr>
|
| 53 |
+
<tr>
|
| 54 |
+
<td scope="row">DirectAU</td>
|
| 55 |
+
<td>Wang et al. <a href="https://arxiv.org/abs/2206.12811" target="_blank">Towards Representation Alignment and Uniformity in Collaborative Filtering</a>, KDD'22.
|
| 56 |
+
</td> <td>Graph</d> <td>PyTorch</d>
|
| 57 |
+
</tr>
|
| 58 |
+
<tr>
|
| 59 |
+
<td scope="row">NCL</td>
|
| 60 |
+
<td>Lin et al. <a href="https://arxiv.org/abs/2202.06200" target="_blank">Improving Graph Collaborative Filtering with Neighborhood-enriched Contrastive Learning</a>, WWW'22.
|
| 61 |
+
</td> <td>Graph + CL</d> <td>PyTorch</d>
|
| 62 |
+
</tr>
|
| 63 |
+
<tr>
|
| 64 |
+
<td scope="row">MixGCF</td>
|
| 65 |
+
<td>Huang et al. <a href="https://keg.cs.tsinghua.edu.cn/jietang/publications/KDD21-Huang-et-al-MixGCF.pdf" target="_blank">MixGCF: An Improved Training Method for Graph Neural
|
| 66 |
+
Network-based Recommender Systems</a>, KDD'21.
|
| 67 |
+
</td> <td>Graph + DA</d> <td>PyTorch</d>
|
| 68 |
+
</tr>
|
| 69 |
+
<tr>
|
| 70 |
+
<td scope="row">MHCN</td>
|
| 71 |
+
<td>Yu et al. <a href="https://dl.acm.org/doi/abs/10.1145/3442381.3449844" target="_blank">Self-Supervised Multi-Channel Hypergraph Convolutional Network for Social Recommendation</a>, WWW'21.
|
| 72 |
+
</td> <td>Graph + CL</d> <td>TensorFlow</d>
|
| 73 |
+
</tr>
|
| 74 |
+
<tr>
|
| 75 |
+
<td scope="row">SGL</td>
|
| 76 |
+
<td>Wu et al. <a href="https://dl.acm.org/doi/10.1145/3404835.3462862" target="_blank">Self-supervised Graph Learning for Recommendation</a>, SIGIR'21.
|
| 77 |
+
</td> <td>Graph + CL</d> <td>TensorFlow & Torch</d>
|
| 78 |
+
</tr>
|
| 79 |
+
<tr>
|
| 80 |
+
<td scope="row">SEPT</td>
|
| 81 |
+
<td>Yu et al. <a href="https://arxiv.org/abs/2106.03569" target="_blank">Socially-Aware Self-supervised Tri-Training for Recommendation</a>, KDD'21.
|
| 82 |
+
</td> <td>Graph + CL</d> <td>TensorFlow</d>
|
| 83 |
+
</tr>
|
| 84 |
+
<tr>
|
| 85 |
+
<td scope="row">BUIR</td>
|
| 86 |
+
<td>Lee et al. <a href="https://arxiv.org/abs/2105.06323" target="_blank">Bootstrapping User and Item Representations for One-Class Collaborative Filtering</a>, SIGIR'21.
|
| 87 |
+
</td> <td>Graph + DA</d> <td>PyTorch</d>
|
| 88 |
+
</tr>
|
| 89 |
+
<tr>
|
| 90 |
+
<td scope="row">SSL4Rec</td>
|
| 91 |
+
<td>Yao et al. <a href="https://dl.acm.org/doi/abs/10.1145/3459637.3481952" target="_blank">Self-supervised Learning for Large-scale Item Recommendations</a>, CIKM'21.
|
| 92 |
+
</td> <td>Graph + CL</d> <td>PyTorch</d>
|
| 93 |
+
</tr>
|
| 94 |
+
<tr>
|
| 95 |
+
<td scope="row">SelfCF</td>
|
| 96 |
+
<td>Zhou et al. <a href="https://arxiv.org/abs/2107.03019" target="_blank">SelfCF: A Simple Framework for Self-supervised Collaborative Filtering</a>, arXiv'21.
|
| 97 |
+
</td> <td>Graph + DA</d> <td>PyTorch</d>
|
| 98 |
+
</tr>
|
| 99 |
+
<tr>
|
| 100 |
+
<td scope="row">LightGCN</td>
|
| 101 |
+
<td>He et al. <a href="https://dl.acm.org/doi/10.1145/3397271.3401063" target="_blank">LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation</a>, SIGIR'20.
|
| 102 |
+
</td> <td>Graph</d> <td>PyTorch</d>
|
| 103 |
+
</tr>
|
| 104 |
+
<tr>
|
| 105 |
+
<td scope="row">MF</td>
|
| 106 |
+
<td>Yehuda et al. <a href="https://ieeexplore.ieee.org/abstract/document/5197422" target="_blank">Matrix Factorization Techniques for Recommender Systems</a>, IEEE Computer'09.
|
| 107 |
+
</td> <td>Graph</d> <td>PyTorch</d>
|
| 108 |
+
</tr>
|
| 109 |
+
</table>
|
| 110 |
+
* CL is short for contrastive learning (including data augmentation); DA is short for data augmentation only
|
| 111 |
+
|
| 112 |
+
<h2>Leaderboard</h2>
|
| 113 |
+
The results are obtained on the dataset of <b>Yelp2018</b>. We performed grid search for the best hyperparameters. <br>
|
| 114 |
+
General hyperparameter settings are: batch_size: 2048, emb_size: 64, learning rate: 0.001, L2 reg: 0.0001. <br><br>
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
| Model | Recall@20 | NDCG@20 | Hyperparameter settings |
|
| 118 |
+
|:--------:|:-------------------:|:-------:|:----------------------------------------------------------------------------------------------------|
|
| 119 |
+
| MF | 0.0543 | 0.0445 | |
|
| 120 |
+
| LightGCN | 0.0639 | 0.0525 | layer=3 |
|
| 121 |
+
| NCL | 0.0670 | 0.0562 | layer=3, ssl_reg=1e-6, proto_reg=1e-7, tau=0.05, hyper_layers=1, alpha=1.5, num_clusters=2000 |
|
| 122 |
+
| SGL | 0.0675 | 0.0555 | λ=0.1, ρ=0.1, tau=0.2 layer=3 |
|
| 123 |
+
| MixGCF | 0.0691 | 0.0577 | layer=3, n_nes=64, layer=3 |
|
| 124 |
+
| DirectAU | 0.0695 | 0.0583 | 𝛾=2, layer=3 |
|
| 125 |
+
| SimGCL | 0.0721 | 0.0601 | λ=0.5, eps=0.1, tau=0.2, layer=3 |
|
| 126 |
+
| XSimGCL | 0.0723 | 0.0604 | λ=0.2, eps=0.2, l∗=1 tau=0.15 layer=3 |
|
| 127 |
+
|
| 128 |
+
<h2>Implement Your Model</h2>
|
| 129 |
+
|
| 130 |
+
1. Create a **.conf** file for your model in the directory named conf.
|
| 131 |
+
2. Make your model **inherit** the proper base class.
|
| 132 |
+
3. **Reimplement** the following functions.
|
| 133 |
+
+ *build*(), *train*(), *save*(), *predict*()
|
| 134 |
+
4. Register your model in **main.py**.
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
<h2>Related Datasets</h2>
|
| 139 |
+
<div>
|
| 140 |
+
<table class="table table-hover table-bordered">
|
| 141 |
+
<tr>
|
| 142 |
+
<th rowspan="2" scope="col">Data Set</th>
|
| 143 |
+
<th colspan="5" scope="col" class="text-center">Basic Meta</th>
|
| 144 |
+
<th colspan="3" scope="col" class="text-center">User Context</th>
|
| 145 |
+
</tr>
|
| 146 |
+
<tr>
|
| 147 |
+
<th class="text-center">Users</th>
|
| 148 |
+
<th class="text-center">Items</th>
|
| 149 |
+
<th colspan="2" class="text-center">Ratings (Scale)</th>
|
| 150 |
+
<th class="text-center">Density</th>
|
| 151 |
+
<th class="text-center">Users</th>
|
| 152 |
+
<th colspan="2" class="text-center">Links (Type)</th>
|
| 153 |
+
</tr>
|
| 154 |
+
<tr>
|
| 155 |
+
<td><a href="https://pan.baidu.com/s/1hrJP6rq" target="_blank"><b>Douban</b></a> </td>
|
| 156 |
+
<td>2,848</td>
|
| 157 |
+
<td>39,586</td>
|
| 158 |
+
<td width="6%">894,887</td>
|
| 159 |
+
<td width="10%">[1, 5]</td>
|
| 160 |
+
<td>0.794%</td>
|
| 161 |
+
<td width="4%">2,848</td>
|
| 162 |
+
<td width="5%">35,770</td>
|
| 163 |
+
<td>Trust</td>
|
| 164 |
+
</tr>
|
| 165 |
+
<tr>
|
| 166 |
+
<td><a href="http://files.grouplens.org/datasets/hetrec2011/hetrec2011-lastfm-2k.zip" target="_blank"><b>LastFM</b></a> </td>
|
| 167 |
+
<td>1,892</td>
|
| 168 |
+
<td>17,632</td>
|
| 169 |
+
<td width="6%">92,834</td>
|
| 170 |
+
<td width="10%">implicit</td>
|
| 171 |
+
<td>0.27%</td>
|
| 172 |
+
<td width="4%">1,892</td>
|
| 173 |
+
<td width="5%">25,434</td>
|
| 174 |
+
<td>Trust</td>
|
| 175 |
+
</tr>
|
| 176 |
+
<tr>
|
| 177 |
+
<td><a href="https://www.dropbox.com/sh/h97ymblxt80txq5/AABfSLXcTu0Beib4r8P5I5sNa?dl=0" target="_blank"><b>Yelp</b></a> </td>
|
| 178 |
+
<td>19,539</td>
|
| 179 |
+
<td>21,266</td>
|
| 180 |
+
<td width="6%">450,884</td>
|
| 181 |
+
<td width="10%">implicit</td>
|
| 182 |
+
<td>0.11%</td>
|
| 183 |
+
<td width="4%">19,539</td>
|
| 184 |
+
<td width="5%">864,157</td>
|
| 185 |
+
<td>Trust</td>
|
| 186 |
+
</tr>
|
| 187 |
+
<tr>
|
| 188 |
+
<td><a href="https://www.dropbox.com/sh/20l0xdjuw0b3lo8/AABBZbRg9hHiN42EHqBSvLpta?dl=0" target="_blank"><b>Amazon-Book</b></a> </td>
|
| 189 |
+
<td>52,463</td>
|
| 190 |
+
<td>91,599</td>
|
| 191 |
+
<td width="6%">2,984,108</td>
|
| 192 |
+
<td width="10%">implicit</td>
|
| 193 |
+
<td>0.11%</td>
|
| 194 |
+
<td width="4%">-</td>
|
| 195 |
+
<td width="5%">-</td>
|
| 196 |
+
<td>-</td>
|
| 197 |
+
</tr>
|
| 198 |
+
</table>
|
| 199 |
+
</div>
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
|
SELFRec.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from data.loader import FileIO
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class SELFRec(object):
|
| 5 |
+
def __init__(self, config):
|
| 6 |
+
self.social_data = []
|
| 7 |
+
self.feature_data = []
|
| 8 |
+
self.config = config
|
| 9 |
+
if config['model.type'] == 'sequential':
|
| 10 |
+
self.training_data, self.test_data = FileIO.load_data_set(config['sequence.data'], config['model.type'])
|
| 11 |
+
else:
|
| 12 |
+
self.training_data = FileIO.load_data_set(config['training.set'], config['model.type'])
|
| 13 |
+
self.test_data = FileIO.load_data_set(config['test.set'], config['model.type'])
|
| 14 |
+
|
| 15 |
+
self.kwargs = {}
|
| 16 |
+
if config.contain('social.data'):
|
| 17 |
+
social_data = FileIO.load_social_data(self.config['social.data'])
|
| 18 |
+
self.kwargs['social.data'] = social_data
|
| 19 |
+
# if config.contains('feature.data'):
|
| 20 |
+
# self.social_data = FileIO.loadFeature(config,self.config['feature.data'])
|
| 21 |
+
print('Reading data and preprocessing...')
|
| 22 |
+
|
| 23 |
+
def execute(self):
|
| 24 |
+
# import the model module
|
| 25 |
+
import_str = 'from model.'+ self.config['model.type'] +'.' + self.config['model.name'] + ' import ' + self.config['model.name']
|
| 26 |
+
exec(import_str)
|
| 27 |
+
recommender = self.config['model.name'] + '(self.config,self.training_data,self.test_data,**self.kwargs)'
|
| 28 |
+
eval(recommender).execute()
|
__pycache__/SELFRec.cpython-313.pyc
ADDED
|
Binary file (2.11 kB). View file
|
|
|
__pycache__/SELFRec.cpython-38.pyc
ADDED
|
Binary file (1.25 kB). View file
|
|
|
base/__init__.py
ADDED
|
File without changes
|
base/__pycache__/__init__.cpython-38.pyc
ADDED
|
Binary file (168 Bytes). View file
|
|
|
base/__pycache__/graph_recommender.cpython-38.pyc
ADDED
|
Binary file (5.63 kB). View file
|
|
|
base/__pycache__/recommender.cpython-38.pyc
ADDED
|
Binary file (3.3 kB). View file
|
|
|
base/__pycache__/torch_interface.cpython-38.pyc
ADDED
|
Binary file (844 Bytes). View file
|
|
|
base/graph_recommender.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from base.recommender import Recommender
|
| 3 |
+
from data.ui_graph import Interaction
|
| 4 |
+
from util.algorithm import find_k_largest
|
| 5 |
+
from time import strftime, localtime, time
|
| 6 |
+
from data.loader import FileIO
|
| 7 |
+
from os.path import abspath
|
| 8 |
+
from util.evaluation import ranking_evaluation
|
| 9 |
+
import sys
|
| 10 |
+
from util.conf import OptionConf
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class GraphRecommender(Recommender):
|
| 15 |
+
def __init__(self, conf, training_set, test_set, **kwargs):
|
| 16 |
+
super(GraphRecommender, self).__init__(conf, training_set, test_set, **kwargs)
|
| 17 |
+
self.data = Interaction(conf, training_set, test_set)
|
| 18 |
+
self.bestPerformance = []
|
| 19 |
+
top = self.ranking['-topN'].split(',')
|
| 20 |
+
self.topN = [int(num) for num in top]
|
| 21 |
+
self.max_N = max(self.topN)
|
| 22 |
+
|
| 23 |
+
def print_model_info(self):
|
| 24 |
+
super(GraphRecommender, self).print_model_info()
|
| 25 |
+
# # print dataset statistics
|
| 26 |
+
print('Training Set Size: (user number: %d, item number %d, interaction number: %d)' % (self.data.training_size()))
|
| 27 |
+
print('Test Set Size: (user number: %d, item number %d, interaction number: %d)' % (self.data.test_size()))
|
| 28 |
+
print('=' * 80)
|
| 29 |
+
|
| 30 |
+
def build(self):
|
| 31 |
+
pass
|
| 32 |
+
|
| 33 |
+
def train(self):
|
| 34 |
+
pass
|
| 35 |
+
|
| 36 |
+
def predict(self, u):
|
| 37 |
+
pass
|
| 38 |
+
|
| 39 |
+
def test(self):
|
| 40 |
+
def process_bar(num, total):
|
| 41 |
+
rate = float(num) / total
|
| 42 |
+
ratenum = int(50 * rate)
|
| 43 |
+
r = '\rProgress: [{}{}]{}%'.format('+' * ratenum, ' ' * (50 - ratenum), ratenum*2)
|
| 44 |
+
sys.stdout.write(r)
|
| 45 |
+
sys.stdout.flush()
|
| 46 |
+
|
| 47 |
+
# predict
|
| 48 |
+
rec_list = {}
|
| 49 |
+
user_count = len(self.data.test_set)
|
| 50 |
+
for i, user in enumerate(self.data.test_set):
|
| 51 |
+
candidates = self.predict(user)
|
| 52 |
+
# predictedItems = denormalize(predictedItems, self.data.rScale[-1], self.data.rScale[0])
|
| 53 |
+
rated_list, li = self.data.user_rated(user)
|
| 54 |
+
for item in rated_list:
|
| 55 |
+
candidates[self.data.item[item]] = -10e8
|
| 56 |
+
ids, scores = find_k_largest(self.max_N, candidates)
|
| 57 |
+
item_names = [self.data.id2item[iid] for iid in ids]
|
| 58 |
+
rec_list[user] = list(zip(item_names, scores))
|
| 59 |
+
if i % 1000 == 0:
|
| 60 |
+
process_bar(i, user_count)
|
| 61 |
+
process_bar(user_count, user_count)
|
| 62 |
+
print('')
|
| 63 |
+
return rec_list
|
| 64 |
+
|
| 65 |
+
def evaluate(self, rec_list):
|
| 66 |
+
self.recOutput.append('userId: recommendations in (itemId, ranking score) pairs, * means the item is hit.\n')
|
| 67 |
+
for user in self.data.test_set:
|
| 68 |
+
line = user + ':'
|
| 69 |
+
for item in rec_list[user]:
|
| 70 |
+
line += ' (' + item[0] + ',' + str(item[1]) + ')'
|
| 71 |
+
if item[0] in self.data.test_set[user]:
|
| 72 |
+
line += '*'
|
| 73 |
+
line += '\n'
|
| 74 |
+
self.recOutput.append(line)
|
| 75 |
+
current_time = strftime("%Y-%m-%d %H-%M-%S", localtime(time()))
|
| 76 |
+
# output prediction result
|
| 77 |
+
out_dir = self.output['-dir']
|
| 78 |
+
file_name = self.config['model.name'] + '@' + current_time + '-top-' + str(self.max_N) + 'items' + '.txt'
|
| 79 |
+
FileIO.write_file(out_dir, file_name, self.recOutput)
|
| 80 |
+
print('The result has been output to ', abspath(out_dir), '.')
|
| 81 |
+
file_name = self.config['model.name'] + '@' + current_time + '-performance' + '.txt'
|
| 82 |
+
args = OptionConf(self.config['SimGCL'])
|
| 83 |
+
self.result += ranking_evaluation(self.data.test_set, rec_list, self.topN)
|
| 84 |
+
self.model_log.add('###Evaluation Results###')
|
| 85 |
+
self.model_log.add(self.result)
|
| 86 |
+
FileIO.write_file(out_dir, file_name, self.result)
|
| 87 |
+
print('The result of %s:\n%s' % (self.model_name, ''.join(self.result)))
|
| 88 |
+
|
| 89 |
+
def fast_evaluation(self, epoch):
|
| 90 |
+
print('evaluating the model...')
|
| 91 |
+
rec_list = self.test()
|
| 92 |
+
measure = ranking_evaluation(self.data.test_set, rec_list, [self.max_N])
|
| 93 |
+
if len(self.bestPerformance) > 0:
|
| 94 |
+
count = 0
|
| 95 |
+
performance = {}
|
| 96 |
+
for m in measure[1:]:
|
| 97 |
+
k, v = m.strip().split(':')
|
| 98 |
+
performance[k] = float(v)
|
| 99 |
+
for k in self.bestPerformance[1]:
|
| 100 |
+
if self.bestPerformance[1][k] > performance[k]:
|
| 101 |
+
count += 1
|
| 102 |
+
else:
|
| 103 |
+
count -= 1
|
| 104 |
+
if count < 0:
|
| 105 |
+
self.bestPerformance[1] = performance
|
| 106 |
+
self.bestPerformance[0] = epoch + 1
|
| 107 |
+
self.save()
|
| 108 |
+
else:
|
| 109 |
+
self.bestPerformance.append(epoch + 1)
|
| 110 |
+
performance = {}
|
| 111 |
+
for m in measure[1:]:
|
| 112 |
+
k, v = m.strip().split(':')
|
| 113 |
+
performance[k] = float(v)
|
| 114 |
+
self.bestPerformance.append(performance)
|
| 115 |
+
self.save()
|
| 116 |
+
print('-' * 120)
|
| 117 |
+
print('Real-Time Ranking Performance ' + ' (Top-' + str(self.max_N) + ' Item Recommendation)')
|
| 118 |
+
measure = [m.strip() for m in measure[1:]]
|
| 119 |
+
print('*Current Performance*')
|
| 120 |
+
print('Epoch:', str(epoch + 1) + ',', ' | '.join(measure))
|
| 121 |
+
bp = ''
|
| 122 |
+
# for k in self.bestPerformance[1]:
|
| 123 |
+
# bp+=k+':'+str(self.bestPerformance[1][k])+' | '
|
| 124 |
+
bp += 'Hit Ratio' + ':' + str(self.bestPerformance[1]['Hit Ratio']) + ' | '
|
| 125 |
+
bp += 'Precision' + ':' + str(self.bestPerformance[1]['Precision']) + ' | '
|
| 126 |
+
bp += 'Recall' + ':' + str(self.bestPerformance[1]['Recall']) + ' | '
|
| 127 |
+
# bp += 'F1' + ':' + str(self.bestPerformance[1]['F1']) + ' | '
|
| 128 |
+
bp += 'MDCG' + ':' + str(self.bestPerformance[1]['NDCG'])
|
| 129 |
+
print('*Best Performance* ')
|
| 130 |
+
print('Epoch:', str(self.bestPerformance[0]) + ',', bp)
|
| 131 |
+
print('-' * 120)
|
| 132 |
+
return measure
|
| 133 |
+
|
base/recommender.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from data.data import Data
|
| 2 |
+
from util.conf import OptionConf
|
| 3 |
+
from util.logger import Log
|
| 4 |
+
from os.path import abspath
|
| 5 |
+
from time import strftime, localtime, time
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Recommender(object):
|
| 9 |
+
def __init__(self, conf, training_set, test_set, **kwargs):
|
| 10 |
+
self.config = conf
|
| 11 |
+
self.data = Data(self.config, training_set, test_set)
|
| 12 |
+
self.model_name = self.config['model.name']
|
| 13 |
+
self.ranking = OptionConf(self.config['item.ranking'])
|
| 14 |
+
self.emb_size = int(self.config['embbedding.size'])
|
| 15 |
+
self.maxEpoch = int(self.config['num.max.epoch'])
|
| 16 |
+
self.batch_size = int(self.config['batch_size'])
|
| 17 |
+
self.lRate = float(self.config['learnRate'])
|
| 18 |
+
self.reg = float(self.config['reg.lambda'])
|
| 19 |
+
self.output = OptionConf(self.config['output.setup'])
|
| 20 |
+
current_time = strftime("%Y-%m-%d %H-%M-%S", localtime(time()))
|
| 21 |
+
self.model_log = Log(self.model_name, self.model_name + ' ' + current_time)
|
| 22 |
+
self.result = []
|
| 23 |
+
self.recOutput = []
|
| 24 |
+
|
| 25 |
+
def initializing_log(self):
|
| 26 |
+
self.model_log.add('### model configuration ###')
|
| 27 |
+
for k in self.config.config:
|
| 28 |
+
self.model_log.add(k + '=' + self.config[k])
|
| 29 |
+
|
| 30 |
+
def print_model_info(self):
|
| 31 |
+
print('Model:', self.config['model.name'])
|
| 32 |
+
print('Training Set:', abspath(self.config['training.set']))
|
| 33 |
+
print('Test Set:', abspath(self.config['test.set']))
|
| 34 |
+
print('Embedding Dimension:', self.emb_size)
|
| 35 |
+
print('Maximum Epoch:', self.maxEpoch)
|
| 36 |
+
print('Learning Rate:', self.lRate)
|
| 37 |
+
print('Batch Size:', self.batch_size)
|
| 38 |
+
print('Regularization Parameter:', self.reg)
|
| 39 |
+
parStr = ''
|
| 40 |
+
if self.config.contain(self.config['model.name']):
|
| 41 |
+
args = OptionConf(self.config[self.config['model.name']])
|
| 42 |
+
for key in args.keys():
|
| 43 |
+
parStr += key[1:] + ':' + args[key] + ' '
|
| 44 |
+
print('Specific parameters:', parStr)
|
| 45 |
+
|
| 46 |
+
def build(self):
|
| 47 |
+
pass
|
| 48 |
+
|
| 49 |
+
def train(self):
|
| 50 |
+
pass
|
| 51 |
+
|
| 52 |
+
def predict(self, u):
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
def test(self):
|
| 56 |
+
pass
|
| 57 |
+
|
| 58 |
+
def save(self):
|
| 59 |
+
pass
|
| 60 |
+
|
| 61 |
+
def load(self):
|
| 62 |
+
pass
|
| 63 |
+
|
| 64 |
+
def evaluate(self, rec_list):
|
| 65 |
+
pass
|
| 66 |
+
|
| 67 |
+
def execute(self):
|
| 68 |
+
self.initializing_log()
|
| 69 |
+
self.print_model_info()
|
| 70 |
+
print('Initializing and building model...')
|
| 71 |
+
self.build()
|
| 72 |
+
print('Training Model...')
|
| 73 |
+
self.train()
|
| 74 |
+
print('Testing...')
|
| 75 |
+
rec_list = self.test()
|
| 76 |
+
print('Evaluating...')
|
| 77 |
+
self.evaluate(rec_list)
|
base/seq_recommender.py
ADDED
|
File without changes
|
base/ssl_interface.py
ADDED
|
File without changes
|
base/tf_interface.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class TFGraphInterface(object):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
pass
|
| 8 |
+
|
| 9 |
+
@staticmethod
|
| 10 |
+
def convert_sparse_mat_to_tensor(adj):
|
| 11 |
+
row, col = adj.nonzero()
|
| 12 |
+
indices = np.array(list(zip(row, col)))
|
| 13 |
+
adj_tensor = tf.SparseTensor(indices=indices, values=adj.data, dense_shape=adj.shape)
|
| 14 |
+
return adj_tensor
|
| 15 |
+
|
| 16 |
+
@staticmethod
|
| 17 |
+
def convert_sparse_mat_to_tensor_inputs(X):
|
| 18 |
+
coo = X.tocoo()
|
| 19 |
+
indices = np.mat([coo.row, coo.col]).transpose()
|
| 20 |
+
return indices, coo.data, coo.shape
|
base/torch_interface.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
|
| 3 |
+
class TorchGraphInterface(object):
|
| 4 |
+
def __init__(self):
|
| 5 |
+
pass
|
| 6 |
+
|
| 7 |
+
@staticmethod
|
| 8 |
+
def convert_sparse_mat_to_tensor(X):
|
| 9 |
+
coo = X.tocoo()
|
| 10 |
+
i = torch.LongTensor([coo.row, coo.col])
|
| 11 |
+
v = torch.from_numpy(coo.data).float()
|
| 12 |
+
return torch.sparse.FloatTensor(i, v, coo.shape)
|
conf/ASReP.conf
ADDED
|
File without changes
|
conf/BERT4Rec.conf
ADDED
|
File without changes
|
conf/BUIR.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=BUIR
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=200
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
BUIR=-n_layer 2 -tau 0.995 -drop_rate 0.2
|
| 12 |
+
output.setup=-dir ./results/
|
conf/CLS4Rec.conf
ADDED
|
File without changes
|
conf/CLUE.conf
ADDED
|
File without changes
|
conf/COTREC.conf
ADDED
|
File without changes
|
conf/DHCN.conf
ADDED
|
File without changes
|
conf/DirectAU.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=DirectAU
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=50
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
DirectAU=-gamma 2 -n_layers 3
|
| 12 |
+
output.setup=-dir ./results/
|
conf/DuoRec.conf
ADDED
|
File without changes
|
conf/FRGCF.conf
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
training.set=./dataset/douban-book/train.txt
|
| 3 |
+
test.set=./dataset/douban-book/test.txt
|
| 4 |
+
model.name=FRGCF
|
| 5 |
+
model.type=graph
|
| 6 |
+
|
| 7 |
+
evaluation.setup=-topN 20,10
|
| 8 |
+
item.ranking=-topN 20,10
|
| 9 |
+
|
| 10 |
+
embbedding.size=64
|
| 11 |
+
num.max.epoch=5
|
| 12 |
+
batch_size=2048
|
| 13 |
+
learnRate=0.001
|
| 14 |
+
reg.lambda=0.0001
|
| 15 |
+
|
| 16 |
+
output.setup=-dir ./results/
|
| 17 |
+
FRGCF=-n_layer 3 -temp 0.2 -lambda1 0.1 -lambda2 0.1 -lambda3 0.05 -mu 1.0 -cluster_num 64 -rating_threshold 4 -partition_mode douban_45_proxy -seed 2026
|
conf/LightGCN.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=LightGCN
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=500
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
LightGCN=-n_layer 2
|
| 12 |
+
output.setup=-dir ./results/
|
conf/MF.conf
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=MF
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=100
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
output.setup=-dir ./results/
|
conf/MHCN.conf
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/douban-book/train.txt
|
| 2 |
+
test.set=./dataset/douban-book/test.txt
|
| 3 |
+
social.data=./dataset/douban-book/trust.txt
|
| 4 |
+
model.name=MHCN
|
| 5 |
+
model.type=graph
|
| 6 |
+
item.ranking=-topN 10,20
|
| 7 |
+
embbedding.size=64
|
| 8 |
+
num.max.epoch=30
|
| 9 |
+
batch_size=2048
|
| 10 |
+
learnRate=0.001
|
| 11 |
+
reg.lambda=0.0001
|
| 12 |
+
MHCN=-n_layer 2 -ss_rate 0.01
|
| 13 |
+
output.setup=-dir ./results/
|
conf/MixGCF.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=MixGCF
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=500
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
MixGCF=-n_layer 3 -n_negs 64
|
| 12 |
+
output.setup=-dir ./results/
|
conf/NCL.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=NCL
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=120
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
NCL=-n_layer 3 -ssl_reg 1e-6 -proto_reg 1e-7 -tau 0.05 -hyper_layers 1 -alpha 1.5 -num_clusters 2000
|
| 12 |
+
output.setup=-dir ./results/
|
conf/SEPT.conf
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/douban-book/train.txt
|
| 2 |
+
test.set=./dataset/douban-book/test.txt
|
| 3 |
+
social.data=./dataset/douban-book/trust.txt
|
| 4 |
+
model.name=SEPT
|
| 5 |
+
model.type=graph
|
| 6 |
+
item.ranking=-topN 10,20
|
| 7 |
+
embbedding.size=64
|
| 8 |
+
num.max.epoch=30
|
| 9 |
+
batch_size=2048
|
| 10 |
+
learnRate=0.001
|
| 11 |
+
reg.lambda=0.0001
|
| 12 |
+
SEPT=-n_layer 2 -ss_rate 0.005 -drop_rate 0.3 -ins_cnt 10
|
| 13 |
+
output.setup=-dir ./results/
|
conf/SGL.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/iFashion/train.txt
|
| 2 |
+
test.set=./dataset/iFashion/test.txt
|
| 3 |
+
model.name=SGL
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=20
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
SGL=-n_layer 2 -lambda 0.1 -droprate 0.1 -augtype 1 -temp 0.2
|
| 12 |
+
output.setup=-dir ./results/
|
conf/SRMA.conf
ADDED
|
File without changes
|
conf/SSL4Rec.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/ml-1M/train.txt
|
| 2 |
+
test.set=./dataset/ml-1M/test.txt
|
| 3 |
+
model.name=SSL4Rec
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=100
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
SSL4Rec=-tau 0.07 -alpha 0.1 -drop 0.1
|
| 12 |
+
output.setup=-dir ./results/
|
conf/SelfCF.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=SelfCF
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=100
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
SelfCF=-n_layer 2 -tau 0.05
|
| 12 |
+
output.setup=-dir ./results/
|
conf/SimGCL.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/ml-1M/train.txt
|
| 2 |
+
test.set=./dataset/ml-1M/test.txt
|
| 3 |
+
model.name=SimGCL
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=120
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
SimGCL=-n_layer 3 -lambda 0.5 -eps 0.1 -cl_weight 0.01 -temp 0.2
|
| 12 |
+
output.setup=-dir ./results/
|
conf/XSimGCL.conf
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
training.set=./dataset/yelp2018/train.txt
|
| 2 |
+
test.set=./dataset/yelp2018/test.txt
|
| 3 |
+
model.name=XSimGCL
|
| 4 |
+
model.type=graph
|
| 5 |
+
item.ranking=-topN 10,20
|
| 6 |
+
embbedding.size=64
|
| 7 |
+
num.max.epoch=20
|
| 8 |
+
batch_size=2048
|
| 9 |
+
learnRate=0.001
|
| 10 |
+
reg.lambda=0.0001
|
| 11 |
+
XSimGCL=-n_layer 2 -l* 1 -lambda 0.2 -eps 0.2 -tau 0.15
|
| 12 |
+
output.setup=-dir ./results/
|
conf/__init__.py
ADDED
|
File without changes
|
data/__init__.py
ADDED
|
File without changes
|
data/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (174 Bytes). View file
|
|
|
data/__pycache__/__init__.cpython-38.pyc
ADDED
|
Binary file (168 Bytes). View file
|
|
|
data/__pycache__/data.cpython-38.pyc
ADDED
|
Binary file (525 Bytes). View file
|
|
|
data/__pycache__/graph.cpython-38.pyc
ADDED
|
Binary file (1.16 kB). View file
|
|
|