{"id":21421274,"url":"https://github.com/owenliang/itemcf-php","last_synced_at":"2025-07-14T07:32:36.649Z","repository":{"id":81719481,"uuid":"127219290","full_name":"owenliang/ItemCF-php","owner":"owenliang","description":"simple itemCF algorithm in php","archived":false,"fork":false,"pushed_at":"2018-03-29T05:12:16.000Z","size":4,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T04:01:33.849Z","etag":null,"topics":["itemcf","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owenliang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-29T01:28:02.000Z","updated_at":"2023-07-29T02:20:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0cffea2-191c-4ac3-8ebe-077a2dcb8b55","html_url":"https://github.com/owenliang/ItemCF-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/owenliang/ItemCF-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owenliang%2FItemCF-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owenliang%2FItemCF-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owenliang%2FItemCF-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owenliang%2FItemCF-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owenliang","download_url":"https://codeload.github.com/owenliang/ItemCF-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owenliang%2FItemCF-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265255274,"owners_count":23735222,"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":["itemcf","php"],"created_at":"2024-11-22T20:33:07.884Z","updated_at":"2025-07-14T07:32:36.636Z","avatar_url":"https://github.com/owenliang.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ItemCF-php\n\nsimple itemCF algorithm in php\n\n# 说明\n\n一个单机版的物品协同过滤DEMO，目标是生成物品相似度矩阵。\n\n线上用户可以快速根据浏览的商品ID，从矩阵推荐若干相似商品给用户，既简单又实用。\n\n# 输入\n\n```\nA 周杰伦 5\nA 林俊杰 2\nB 蔡依林 3\nB 周杰伦 2\nB 林俊杰 4\nB 张天爱 3\nB 喜洋洋 1\nC 周杰伦 5\nC 佟丽娅 3\nC 蔡依林 5\n```\n\n# 物品相似度矩阵\n\n```\n{\n\t\"周杰伦\": {\n\t\t\"林俊杰\": 0.8164965809277261,\n\t\t\"蔡依林\": 0.8164965809277261,\n\t\t\"张天爱\": 0.5773502691896258,\n\t\t\"喜洋洋\": 0.5773502691896258,\n\t\t\"佟丽娅\": 0.5773502691896258\n\t},\n\t\"林俊杰\": {\n\t\t\"周杰伦\": 0.8164965809277261,\n\t\t\"张天爱\": 0.7071067811865475,\n\t\t\"喜洋洋\": 0.7071067811865475,\n\t\t\"蔡依林\": 0.5\n\t},\n\t\"蔡依林\": {\n\t\t\"周杰伦\": 0.8164965809277261,\n\t\t\"张天爱\": 0.7071067811865475,\n\t\t\"喜洋洋\": 0.7071067811865475,\n\t\t\"佟丽娅\": 0.7071067811865475,\n\t\t\"林俊杰\": 0.5\n\t},\n\t\"张天爱\": {\n\t\t\"喜洋洋\": 1,\n\t\t\"蔡依林\": 0.7071067811865475,\n\t\t\"林俊杰\": 0.7071067811865475,\n\t\t\"周杰伦\": 0.5773502691896258\n\t},\n\t\"喜洋洋\": {\n\t\t\"张天爱\": 1,\n\t\t\"蔡依林\": 0.7071067811865475,\n\t\t\"林俊杰\": 0.7071067811865475,\n\t\t\"周杰伦\": 0.5773502691896258\n\t},\n\t\"佟丽娅\": {\n\t\t\"蔡依林\": 0.7071067811865475,\n\t\t\"周杰伦\": 0.5773502691896258\n\t}\n}\n```\n\n# 为已知用户推荐\n\n```\n// 为已知用户A作推荐\n$recItemsA = $itemCF-\u003erecommendByUser('A');\nprint_r($recItemsA);\n\nArray\n(\n    [0] =\u003e Array\n        (\n            [iid] =\u003e 蔡依林\n            [est] =\u003e 5.0824829046386\n        )\n\n    [1] =\u003e Array\n        (\n            [iid] =\u003e 张天爱\n            [est] =\u003e 4.3009649083212\n        )\n\n    [2] =\u003e Array\n        (\n            [iid] =\u003e 喜洋洋\n            [est] =\u003e 4.3009649083212\n        )\n\n    [3] =\u003e Array\n        (\n            [iid] =\u003e 佟丽娅\n            [est] =\u003e 2.8867513459481\n        )\n\n)\n```\n\n# 为新用户推荐\n\n``` \n// 为新用户D作推荐, 我们根据最近D用户浏览行为知道D访问过张天爱的相关文章\n$recItemsD = $itemCF-\u003erecommendByUserItems('D', ['张天爱'], [5,]);\nprint_r($recItemsD);\n\nArray\n(\n    [0] =\u003e Array\n        (\n            [iid] =\u003e 喜洋洋\n            [est] =\u003e 5\n        )\n\n    [1] =\u003e Array\n        (\n            [iid] =\u003e 蔡依林\n            [est] =\u003e 3.5355339059327\n        )\n\n    [2] =\u003e Array\n        (\n            [iid] =\u003e 林俊杰\n            [est] =\u003e 3.5355339059327\n        )\n\n    [3] =\u003e Array\n        (\n            [iid] =\u003e 周杰伦\n            [est] =\u003e 2.8867513459481\n        )\n\n)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowenliang%2Fitemcf-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowenliang%2Fitemcf-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowenliang%2Fitemcf-php/lists"}