nextrec 0.1.4__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. {nextrec-0.1.4 → nextrec-0.1.7}/PKG-INFO +16 -7
  2. {nextrec-0.1.4 → nextrec-0.1.7}/docs/conf.py +10 -10
  3. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/__init__.py +4 -4
  4. nextrec-0.1.7/nextrec/__version__.py +1 -0
  5. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/activation.py +9 -10
  6. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/callback.py +0 -1
  7. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/dataloader.py +127 -168
  8. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/features.py +27 -24
  9. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/layers.py +159 -328
  10. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/loggers.py +37 -50
  11. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/metrics.py +147 -255
  12. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/model.py +462 -817
  13. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/data/__init__.py +5 -5
  14. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/data/data_utils.py +12 -16
  15. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/data/preprocessor.py +252 -276
  16. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/loss/__init__.py +12 -12
  17. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/loss/loss_utils.py +22 -30
  18. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/loss/match_losses.py +83 -116
  19. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/__init__.py +5 -5
  20. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/dssm.py +61 -70
  21. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/dssm_v2.py +51 -61
  22. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/mind.py +71 -89
  23. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/sdm.py +81 -93
  24. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/match/youtube_dnn.py +53 -62
  25. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/multi_task/esmm.py +43 -49
  26. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/multi_task/mmoe.py +56 -65
  27. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/multi_task/ple.py +65 -92
  28. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/multi_task/share_bottom.py +42 -48
  29. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/__init__.py +7 -7
  30. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/afm.py +30 -39
  31. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/autoint.py +57 -70
  32. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/dcn.py +35 -43
  33. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/deepfm.py +28 -34
  34. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/dien.py +79 -115
  35. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/din.py +60 -84
  36. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/fibinet.py +35 -51
  37. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/fm.py +26 -28
  38. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/masknet.py +31 -31
  39. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/pnn.py +31 -30
  40. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/widedeep.py +31 -36
  41. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/ranking/xdeepfm.py +39 -46
  42. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/utils/__init__.py +9 -9
  43. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/utils/embedding.py +1 -1
  44. nextrec-0.1.7/nextrec/utils/initializer.py +47 -0
  45. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/utils/optimizer.py +10 -14
  46. {nextrec-0.1.4 → nextrec-0.1.7}/pyproject.toml +22 -7
  47. nextrec-0.1.7/requirements.txt +25 -0
  48. {nextrec-0.1.4 → nextrec-0.1.7}/test/conftest.py +55 -61
  49. {nextrec-0.1.4 → nextrec-0.1.7}/test/run_tests.py +54 -44
  50. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_data_preprocessor.py +321 -316
  51. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_dataloader.py +183 -175
  52. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_layers.py +186 -159
  53. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_match_models.py +291 -330
  54. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_multitask_models.py +252 -370
  55. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_ranking_models.py +375 -516
  56. {nextrec-0.1.4 → nextrec-0.1.7}/test/test_utils.py +39 -52
  57. {nextrec-0.1.4 → nextrec-0.1.7}/tutorials/example_match_dssm.py +43 -42
  58. {nextrec-0.1.4 → nextrec-0.1.7}/tutorials/example_multitask.py +45 -35
  59. {nextrec-0.1.4 → nextrec-0.1.7}/tutorials/example_ranking_din.py +31 -30
  60. {nextrec-0.1.4 → nextrec-0.1.7}/tutorials/movielen_match_dssm.py +36 -70
  61. {nextrec-0.1.4 → nextrec-0.1.7}/tutorials/movielen_ranking_deepfm.py +17 -28
  62. nextrec-0.1.4/format_codes.sh +0 -9
  63. nextrec-0.1.4/nextrec/__version__.py +0 -1
  64. nextrec-0.1.4/nextrec/utils/initializer.py +0 -55
  65. nextrec-0.1.4/requirements.txt +0 -20
  66. {nextrec-0.1.4 → nextrec-0.1.7}/.github/workflows/publish.yml +0 -0
  67. {nextrec-0.1.4 → nextrec-0.1.7}/.github/workflows/tests.yml +0 -0
  68. {nextrec-0.1.4 → nextrec-0.1.7}/.gitignore +0 -0
  69. {nextrec-0.1.4 → nextrec-0.1.7}/.readthedocs.yaml +0 -0
  70. {nextrec-0.1.4 → nextrec-0.1.7}/CODE_OF_CONDUCT.md +0 -0
  71. {nextrec-0.1.4 → nextrec-0.1.7}/CONTRIBUTING.md +0 -0
  72. {nextrec-0.1.4 → nextrec-0.1.7}/LICENSE +0 -0
  73. {nextrec-0.1.4 → nextrec-0.1.7}/MANIFEST.in +0 -0
  74. {nextrec-0.1.4 → nextrec-0.1.7}/README.md +0 -0
  75. {nextrec-0.1.4 → nextrec-0.1.7}/README_zh.md +0 -0
  76. {nextrec-0.1.4 → nextrec-0.1.7}/dataset/match_task.csv +0 -0
  77. {nextrec-0.1.4 → nextrec-0.1.7}/dataset/movielens_100k.csv +0 -0
  78. {nextrec-0.1.4 → nextrec-0.1.7}/dataset/multitask_task.csv +0 -0
  79. {nextrec-0.1.4 → nextrec-0.1.7}/dataset/ranking_task.csv +0 -0
  80. {nextrec-0.1.4 → nextrec-0.1.7}/docs/Makefile +0 -0
  81. {nextrec-0.1.4 → nextrec-0.1.7}/docs/index.rst +0 -0
  82. {nextrec-0.1.4 → nextrec-0.1.7}/docs/make.bat +0 -0
  83. {nextrec-0.1.4 → nextrec-0.1.7}/docs/modules.rst +0 -0
  84. {nextrec-0.1.4 → nextrec-0.1.7}/docs/nextrec.basic.rst +0 -0
  85. {nextrec-0.1.4 → nextrec-0.1.7}/docs/nextrec.data.rst +0 -0
  86. {nextrec-0.1.4 → nextrec-0.1.7}/docs/nextrec.loss.rst +0 -0
  87. {nextrec-0.1.4 → nextrec-0.1.7}/docs/nextrec.rst +0 -0
  88. {nextrec-0.1.4 → nextrec-0.1.7}/docs/nextrec.utils.rst +0 -0
  89. {nextrec-0.1.4 → nextrec-0.1.7}/docs/requirements.txt +0 -0
  90. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/basic/__init__.py +0 -0
  91. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/generative/hstu.py +0 -0
  92. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/models/generative/tiger.py +0 -0
  93. {nextrec-0.1.4 → nextrec-0.1.7}/nextrec/utils/common.py +0 -0
  94. {nextrec-0.1.4 → nextrec-0.1.7}/pytest.ini +0 -0
  95. {nextrec-0.1.4 → nextrec-0.1.7}/test/__init__.py +0 -0
  96. {nextrec-0.1.4 → nextrec-0.1.7}/test_requirements.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextrec
3
- Version: 0.1.4
3
+ Version: 0.1.7
4
4
  Summary: A comprehensive recommendation library with match, ranking, and multi-task learning models
5
5
  Project-URL: Homepage, https://github.com/zerolovesea/NextRec
6
6
  Project-URL: Repository, https://github.com/zerolovesea/NextRec
@@ -19,12 +19,21 @@ Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
21
  Requires-Python: >=3.10
22
- Requires-Dist: fastparquet>=2023.4.0
23
- Requires-Dist: numpy>=1.23.0
24
- Requires-Dist: pandas<2.3.0,>=2.1.0
25
- Requires-Dist: pyarrow<15.0.0,>=12.0.0
26
- Requires-Dist: scikit-learn>=1.3.0
27
- Requires-Dist: scipy>=1.10.0
22
+ Requires-Dist: numpy<2.0,>=1.21; sys_platform == 'linux'
23
+ Requires-Dist: numpy>=1.23.0; sys_platform == 'win32'
24
+ Requires-Dist: numpy>=1.24.0; sys_platform == 'darwin'
25
+ Requires-Dist: pandas<2.0,>=1.5; sys_platform == 'linux'
26
+ Requires-Dist: pandas<2.3.0,>=2.1.0; sys_platform == 'win32'
27
+ Requires-Dist: pandas>=2.0.0; sys_platform == 'darwin'
28
+ Requires-Dist: pyarrow<13.0.0,>=10.0.0; sys_platform == 'linux'
29
+ Requires-Dist: pyarrow<15.0.0,>=12.0.0; sys_platform == 'win32'
30
+ Requires-Dist: pyarrow>=12.0.0; sys_platform == 'darwin'
31
+ Requires-Dist: scikit-learn<2.0,>=1.2; sys_platform == 'linux'
32
+ Requires-Dist: scikit-learn>=1.3.0; sys_platform == 'darwin'
33
+ Requires-Dist: scikit-learn>=1.3.0; sys_platform == 'win32'
34
+ Requires-Dist: scipy<1.12,>=1.8; sys_platform == 'linux'
35
+ Requires-Dist: scipy>=1.10.0; sys_platform == 'darwin'
36
+ Requires-Dist: scipy>=1.10.0; sys_platform == 'win32'
28
37
  Requires-Dist: torch>=2.0.0
29
38
  Requires-Dist: torchvision>=0.15.0
30
39
  Requires-Dist: tqdm>=4.65.0
@@ -7,29 +7,29 @@
7
7
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
8
  import os
9
9
  import sys
10
-
11
- sys.path.insert(0, os.path.abspath("../nextrec"))
10
+ sys.path.insert(0, os.path.abspath('../nextrec'))
12
11
 
13
12
  project = "NextRec"
14
13
  copyright = "2025, Yang Zhou"
15
14
  author = "Yang Zhou"
16
- release = "0.1.4"
15
+ release = "0.1.7"
17
16
 
18
17
  # -- General configuration ---------------------------------------------------
19
18
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20
19
 
21
20
  extensions = [
22
- "sphinx.ext.autodoc",
23
- "sphinx.ext.napoleon",
24
- "sphinx_rtd_theme",
21
+ 'sphinx.ext.autodoc',
22
+ 'sphinx.ext.napoleon',
23
+ 'sphinx_rtd_theme',
25
24
  ]
26
25
 
27
- templates_path = ["_templates"]
28
- exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
26
+ templates_path = ['_templates']
27
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
28
+
29
29
 
30
30
 
31
31
  # -- Options for HTML output -------------------------------------------------
32
32
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
33
33
 
34
- html_theme = "sphinx_rtd_theme"
35
- html_static_path = ["_static"]
34
+ html_theme = 'sphinx_rtd_theme'
35
+ html_static_path = ['_static']
@@ -12,18 +12,18 @@ Quick Start
12
12
  -----------
13
13
  >>> from nextrec.basic.features import DenseFeature, SparseFeature
14
14
  >>> from nextrec.models.ranking.deepfm import DeepFM
15
- >>>
15
+ >>>
16
16
  >>> # Define features
17
17
  >>> dense_features = [DenseFeature('age')]
18
18
  >>> sparse_features = [SparseFeature('category', vocab_size=100, embedding_dim=16)]
19
- >>>
19
+ >>>
20
20
  >>> # Build model
21
21
  >>> model = DeepFM(
22
22
  ... dense_features=dense_features,
23
23
  ... sparse_features=sparse_features,
24
24
  ... targets=['label']
25
25
  ... )
26
- >>>
26
+ >>>
27
27
  >>> # Train model
28
28
  >>> model.fit(train_data=df_train, valid_data=df_valid)
29
29
  """
@@ -31,7 +31,7 @@ Quick Start
31
31
  from nextrec.__version__ import __version__
32
32
 
33
33
  __all__ = [
34
- "__version__",
34
+ '__version__',
35
35
  ]
36
36
 
37
37
  # Package metadata
@@ -0,0 +1 @@
1
+ __version__ = "0.1.7"
@@ -14,41 +14,40 @@ class Dice(nn.Module):
14
14
  """
15
15
  Dice activation function from the paper:
16
16
  "Deep Interest Network for Click-Through Rate Prediction" (Zhou et al., 2018)
17
-
17
+
18
18
  Dice(x) = p(x) * x + (1 - p(x)) * alpha * x
19
19
  where p(x) = sigmoid((x - E[x]) / sqrt(Var[x] + epsilon))
20
20
  """
21
-
22
21
  def __init__(self, emb_size: int, epsilon: float = 1e-9):
23
22
  super(Dice, self).__init__()
24
23
  self.epsilon = epsilon
25
24
  self.alpha = nn.Parameter(torch.zeros(emb_size))
26
25
  self.bn = nn.BatchNorm1d(emb_size)
27
-
26
+
28
27
  def forward(self, x):
29
28
  # x shape: (batch_size, emb_size) or (batch_size, seq_len, emb_size)
30
29
  original_shape = x.shape
31
-
30
+
32
31
  if x.dim() == 3:
33
32
  # For 3D input (batch_size, seq_len, emb_size), reshape to 2D
34
33
  batch_size, seq_len, emb_size = x.shape
35
34
  x = x.view(-1, emb_size)
36
-
35
+
37
36
  x_norm = self.bn(x)
38
37
  p = torch.sigmoid(x_norm)
39
38
  output = p * x + (1 - p) * self.alpha * x
40
-
39
+
41
40
  if len(original_shape) == 3:
42
41
  output = output.view(original_shape)
43
-
42
+
44
43
  return output
45
44
 
46
45
 
47
46
  def activation_layer(activation: str, emb_size: int | None = None):
48
47
  """Create an activation layer based on the given activation name."""
49
-
48
+
50
49
  activation = activation.lower()
51
-
50
+
52
51
  if activation == "dice":
53
52
  if emb_size is None:
54
53
  raise ValueError("emb_size is required for Dice activation")
@@ -90,4 +89,4 @@ def activation_layer(activation: str, emb_size: int | None = None):
90
89
  elif activation in ["none", "linear", "identity"]:
91
90
  return nn.Identity()
92
91
  else:
93
- raise ValueError(f"Unsupported activation function: {activation}")
92
+ raise ValueError(f"Unsupported activation function: {activation}")
@@ -8,7 +8,6 @@ Author:
8
8
 
9
9
  import copy
10
10
 
11
-
12
11
  class EarlyStopper(object):
13
12
  def __init__(self, patience: int = 20, mode: str = "max"):
14
13
  self.patience = patience