资源简介

基于知识图谱的推荐系统项目完整代码
数据集在data文件夹下
数据集为txt模式,分为训练集、验证集以及测试集

资源截图

代码片段和文件信息

import os
import pandas as pd
import numpy as np
import random


class KnowledgeGraph:
    def __init__(self data_dir):
        self.data_dir = data_dir
        self.entity_dict = {}
        self.entities = []
        self.relation_dict = {}
        self.n_entity = 0
        self.n_relation = 0
        self.training_triples = []  # list of triples in the form of (h t r)
        self.neg_triples = []
        self.validation_triples = []
        self.test_triples = []
        self.n_training_triple = 0
        self.n_validation_triple = 0
        self.n_test_triple = 0
        self.posloss=0
        self.negloss=0
        ‘‘‘load dicts and triples‘‘‘
        self.load_dicts()
        self.load_triples()
        ‘‘‘construct pools after loading‘‘‘
        self.training_triple_pool = set(se

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-03-11 16:44  Recommendation-system-based-on-knowledge-graph-embedding-master\
     目录           0  2020-03-19 11:00  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\
     文件          63  2020-03-10 16:40  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\.name
     文件         159  2020-03-10 16:40  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\encodings.xml
     文件         687  2020-03-18 23:29  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\misc.xml
     文件         378  2020-03-10 16:40  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\modules.xml
     文件         459  2020-03-18 23:29  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\Recommendation-system-based-on-knowledge-graph-embedding-master.iml
     文件       31153  2020-03-19 11:00  Recommendation-system-based-on-knowledge-graph-embedding-master\.idea\workspace.xml
     目录           0  2020-03-18 23:16  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\
     目录           0  2020-03-18 12:37  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\
     文件        5162  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\dataset.cpython-35.pyc
     文件        4709  2020-03-10 16:41  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\dataset.cpython-36.pyc
     文件        4713  2020-03-18 12:36  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\dataset.cpython-37.pyc
     文件       53778  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\model.cpython-35.pyc
     文件       15989  2020-03-10 16:41  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\model.cpython-36.pyc
     文件       15968  2020-03-18 12:37  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\__pycache__\model.cpython-37.pyc
     目录           0  2020-03-11 16:44  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\
     文件      242298  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\buy_data.txt
     文件           7  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\entites.txt
     文件       10070  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\entities.txt
     文件     1273141  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\neg.txt
     文件           7  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\relations.txt
     文件       41181  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\test.txt
     文件      164678  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\train.txt
     文件       41181  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\data\valid.txt
     文件        5473  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\dataset.py
     文件        4707  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\dataset.pyc
     文件         843  2020-03-18 23:12  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\generate_data.py
     文件        2289  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\main.py
     文件       30207  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\model.py
     文件      344412  2019-12-23 18:14  Recommendation-system-based-on-knowledge-graph-embedding-master\knowledge graph embedding的商品推荐系统\negposscore.npy
............此处省略10个文件信息

评论

共有 条评论