Skip to content

Builtin

Builtin Datasets

builtin

Bases: object

Source code in tgx/data/builtin.py
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
class builtin(object):
    def __init__(self):
        """
        Data class for loading default (in-package) temporal datasets

        In order to use "tgb" datasets install tgb package
        for more detals visit here: https://tgb.complexdatalab.com/

        In order to use dgb datasets download and extract dataset file
        from here: https://zenodo.org/record/7213796#.Y1cO6y8r30o
        and locate them in ./data/ directory.
        """
        pass


    def read_specifications(self, 
                            data: type):
        """
        Load dataset specifications for dgb datasets
        Parameters:
            data: str, name of the dataset
        """
        self.name = data
        self.path = DataPath[data]
        # self.header = Data_specifications[data]['header']
        # self.index = Data_specifications[data]['index']
        self.discretize = Data_specifications[data]['discretize']
        self.time_scale = Data_specifications[data]['time_scale']
        return self

    def load_dgb_data(self):
        try:
            data = pd.read_csv(f"{self.root}{self.path}", index_col=0)
        except:
            self.download_file(self)
            data = pd.read_csv(f"{self.root}{self.path}", index_col=0)

        self.data =  data.iloc[:, 0:3].to_numpy()
        return self

    def download_file(self):

        print("Data missing, download recommended!")
        inp = input('Will you download the dataset(s) now? (y/N)\n').lower()
        url = f"https://zenodo.org/record/7213796/files/{self.name}.zip"
        path_download = f"./data" 
        print(path_download)
        print(url)
        if inp == 'y':
            if not os.path.exists(path_download):
                os.mkdir(path_download)
                print("Folder %s created!" % path_download)

            print(f"Downloading {self.name} dataset . . .")
            zip_path = download(url, path_download)
            with zipfile.ZipFile(zip_path, "r") as f:
                f.extractall(path_download)
            print("Download completed")

        else:
            print("Download cancelled")


    @classmethod
    def mooc(self, root=root_path):
        data = "mooc"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def uci(self, root=root_path):
        data = "uci"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod   
    def uslegis(self, root=root_path):
        data = "USLegis"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def canparl(self, root=root_path):
        data = "CanParl"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def untrade(self, root=root_path):
        data = "UNtrade"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def unvote(self, root=root_path):
        data = "UNvote"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def reddit(self, root=root_path):
        data = "reddit"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def wikipedia(self, root=root_path):
        data = "Wikipedia"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def enron(self, root=root_path):
        data = "enron"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def social_evo(self, root=root_path):
        data = "SocialEvo"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def flights(self, root=root_path):
        data = "Flights"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def lastfm(self, root=root_path):
        data = "lastfm"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

    @classmethod
    def contacts(self, root=root_path):
        data = "Contacts"
        self.root = root
        self.read_specifications(self, data)
        self.load_dgb_data(self)
        return self

__init__()

Data class for loading default (in-package) temporal datasets

In order to use "tgb" datasets install tgb package for more detals visit here: https://tgb.complexdatalab.com/

In order to use dgb datasets download and extract dataset file from here: https://zenodo.org/record/7213796#.Y1cO6y8r30o and locate them in ./data/ directory.

Source code in tgx/data/builtin.py
56
57
58
59
60
61
62
63
64
65
66
67
def __init__(self):
    """
    Data class for loading default (in-package) temporal datasets

    In order to use "tgb" datasets install tgb package
    for more detals visit here: https://tgb.complexdatalab.com/

    In order to use dgb datasets download and extract dataset file
    from here: https://zenodo.org/record/7213796#.Y1cO6y8r30o
    and locate them in ./data/ directory.
    """
    pass

read_specifications(data)

Load dataset specifications for dgb datasets Parameters: data: str, name of the dataset

Source code in tgx/data/builtin.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def read_specifications(self, 
                        data: type):
    """
    Load dataset specifications for dgb datasets
    Parameters:
        data: str, name of the dataset
    """
    self.name = data
    self.path = DataPath[data]
    # self.header = Data_specifications[data]['header']
    # self.index = Data_specifications[data]['index']
    self.discretize = Data_specifications[data]['discretize']
    self.time_scale = Data_specifications[data]['time_scale']
    return self