Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cornac/datasets/gowalla.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
# ============================================================================
"""
This data is built based on the Ta Feng Grocery Dataset that contains
a Chinese grocery store transaction data from November 2000 to February 2001.
Accessed at https://www.kaggle.com/datasets/chiranjivdas09/ta-feng-grocery-dataset
Source: https://snap.stanford.edu/data/loc-gowalla.html
"""

from ..utils import cache
Expand All @@ -38,10 +36,9 @@ def load_checkins(fmt="USITJson", reader: Reader = None) -> List:
Location information is stored in `json` format
"""
fpath = cache(
url="https://static.preferred.ai/datasets/gowalla/check-ins.zip",
url="https://static.preferred.ai/cornac/datasets/gowalla/check-ins.zip",
unzip=True,
relative_path="gowalla/check-ins.txt",
)
reader = Reader() if reader is None else reader
return reader.read(fpath, fmt=fmt, sep="\t")

4 changes: 2 additions & 2 deletions cornac/datasets/tafeng.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
# ============================================================================
"""
This data is built based on the Ta Feng Grocery Dataset that contains
This data is built based on the Ta Feng Grocery Dataset that contains
a Chinese grocery store transaction data from November 2000 to February 2001.
Accessed at https://www.kaggle.com/datasets/chiranjivdas09/ta-feng-grocery-dataset
"""
Expand All @@ -37,7 +37,7 @@ def load_basket(fmt="UBITJson", reader: Reader = None) -> List:
Data in the form of a list of tuples (user, basket, item, timestamp, json).
"""
fpath = cache(
url="https://static.preferred.ai/hieudo/basket.zip",
url="https://static.preferred.ai/cornac/datasets/tafeng/basket.zip",
unzip=True,
relative_path="tafeng/basket.txt",
)
Expand Down
10 changes: 4 additions & 6 deletions cornac/datasets/yoochoose.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
# limitations under the License.
# ============================================================================
"""
This data is built based on the Ta Feng Grocery Dataset that contains
a Chinese grocery store transaction data from November 2000 to February 2001.
Accessed at https://www.kaggle.com/datasets/chiranjivdas09/ta-feng-grocery-dataset
Yoochoose Dataset is originally from the RecSys Challenge 2015.
"""

from typing import List
Expand All @@ -39,7 +37,7 @@ def load_buy(fmt="SITJson", reader: Reader = None) -> List:
Location information is stored in `json` format
"""
fpath = cache(
url="https://static.preferred.ai/datasets/yoochoose/buy.zip",
url="https://static.preferred.ai/cornac/datasets/yoochoose/buy.zip",
unzip=True,
relative_path="yoochoose/buy.txt",
)
Expand All @@ -62,7 +60,7 @@ def load_click(fmt="SITJson", reader: Reader = None) -> List:
Location information is stored in `json` format
"""
fpath = cache(
url="https://static.preferred.ai/datasets/yoochoose/click.zip",
url="https://static.preferred.ai/cornac/datasets/yoochoose/click.zip",
unzip=True,
relative_path="yoochoose/click.txt",
)
Expand All @@ -85,7 +83,7 @@ def load_test(fmt="SITJson", reader: Reader = None) -> List:
Location information is stored in `json` format
"""
fpath = cache(
url="https://static.preferred.ai/datasets/yoochoose/test.zip",
url="https://static.preferred.ai/cornac/datasets/yoochoose/test.zip",
unzip=True,
relative_path="yoochoose/test.txt",
)
Expand Down
33 changes: 33 additions & 0 deletions tests/cornac/datasets/test_gowalla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The Cornac Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

import random
import time
import unittest

from cornac.datasets import gowalla


class TestGowalla(unittest.TestCase):

def test_load_checkins(self):
random.seed(time.time())
if random.random() > 0.8:
checkins = gowalla.load_checkins()
self.assertEqual(len(checkins), 6442892)


if __name__ == "__main__":
unittest.main()
33 changes: 33 additions & 0 deletions tests/cornac/datasets/test_tafeng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 The Cornac Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

import random
import time
import unittest

from cornac.datasets import tafeng


class TestTafeng(unittest.TestCase):

def test_load_basket(self):
random.seed(time.time())
if random.random() > 0.8:
baskets = tafeng.load_basket()
self.assertEqual(len(baskets), 817741)


if __name__ == "__main__":
unittest.main()
38 changes: 38 additions & 0 deletions tests/cornac/datasets/test_yoochoose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 The Cornac Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

import random
import time
import unittest

from cornac.datasets import yoochoose


class TestYooChoose(unittest.TestCase):

def test_load_buy_click_test(self):
random.seed(time.time())
if random.random() > 0.8:
buy = yoochoose.load_buy()
click = yoochoose.load_click()
test = yoochoose.load_test()

self.assertEqual(len(buy), 1150753)
self.assertEqual(len(click), 33003944)
self.assertEqual(len(test), 8251791)


if __name__ == "__main__":
unittest.main()
Loading