replay-rec 0.18.0__py3-none-any.whl → 0.18.0rc0__py3-none-any.whl
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.
- replay/__init__.py +1 -1
- replay/experimental/__init__.py +0 -0
- replay/experimental/metrics/__init__.py +62 -0
- replay/experimental/metrics/base_metric.py +602 -0
- replay/experimental/metrics/coverage.py +97 -0
- replay/experimental/metrics/experiment.py +175 -0
- replay/experimental/metrics/hitrate.py +26 -0
- replay/experimental/metrics/map.py +30 -0
- replay/experimental/metrics/mrr.py +18 -0
- replay/experimental/metrics/ncis_precision.py +31 -0
- replay/experimental/metrics/ndcg.py +49 -0
- replay/experimental/metrics/precision.py +22 -0
- replay/experimental/metrics/recall.py +25 -0
- replay/experimental/metrics/rocauc.py +49 -0
- replay/experimental/metrics/surprisal.py +90 -0
- replay/experimental/metrics/unexpectedness.py +76 -0
- replay/experimental/models/__init__.py +10 -0
- replay/experimental/models/admm_slim.py +205 -0
- replay/experimental/models/base_neighbour_rec.py +204 -0
- replay/experimental/models/base_rec.py +1271 -0
- replay/experimental/models/base_torch_rec.py +234 -0
- replay/experimental/models/cql.py +454 -0
- replay/experimental/models/ddpg.py +923 -0
- replay/experimental/models/dt4rec/__init__.py +0 -0
- replay/experimental/models/dt4rec/dt4rec.py +189 -0
- replay/experimental/models/dt4rec/gpt1.py +401 -0
- replay/experimental/models/dt4rec/trainer.py +127 -0
- replay/experimental/models/dt4rec/utils.py +265 -0
- replay/experimental/models/extensions/spark_custom_models/__init__.py +0 -0
- replay/experimental/models/extensions/spark_custom_models/als_extension.py +792 -0
- replay/experimental/models/implicit_wrap.py +131 -0
- replay/experimental/models/lightfm_wrap.py +302 -0
- replay/experimental/models/mult_vae.py +332 -0
- replay/experimental/models/neuromf.py +406 -0
- replay/experimental/models/scala_als.py +296 -0
- replay/experimental/nn/data/__init__.py +1 -0
- replay/experimental/nn/data/schema_builder.py +55 -0
- replay/experimental/preprocessing/__init__.py +3 -0
- replay/experimental/preprocessing/data_preparator.py +839 -0
- replay/experimental/preprocessing/padder.py +229 -0
- replay/experimental/preprocessing/sequence_generator.py +208 -0
- replay/experimental/scenarios/__init__.py +1 -0
- replay/experimental/scenarios/obp_wrapper/__init__.py +8 -0
- replay/experimental/scenarios/obp_wrapper/obp_optuna_objective.py +74 -0
- replay/experimental/scenarios/obp_wrapper/replay_offline.py +248 -0
- replay/experimental/scenarios/obp_wrapper/utils.py +87 -0
- replay/experimental/scenarios/two_stages/__init__.py +0 -0
- replay/experimental/scenarios/two_stages/reranker.py +117 -0
- replay/experimental/scenarios/two_stages/two_stages_scenario.py +757 -0
- replay/experimental/utils/__init__.py +0 -0
- replay/experimental/utils/logger.py +24 -0
- replay/experimental/utils/model_handler.py +186 -0
- replay/experimental/utils/session_handler.py +44 -0
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.0rc0.dist-info}/METADATA +11 -3
- replay_rec-0.18.0rc0.dist-info/NOTICE +41 -0
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.0rc0.dist-info}/RECORD +58 -5
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.0rc0.dist-info}/WHEEL +1 -1
- {replay_rec-0.18.0.dist-info → replay_rec-0.18.0rc0.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from typing import Dict, List, Optional
|
|
2
|
+
|
|
3
|
+
from replay.data import FeatureHint, FeatureType
|
|
4
|
+
from replay.data.nn.schema import TensorFeatureInfo, TensorFeatureSource, TensorSchema
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TensorSchemaBuilder:
|
|
8
|
+
"""
|
|
9
|
+
Builder that simplifies creating tensor schema
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self) -> None:
|
|
13
|
+
self._tensor_schema: Dict[str, TensorFeatureInfo] = {}
|
|
14
|
+
|
|
15
|
+
def categorical(
|
|
16
|
+
self,
|
|
17
|
+
name: str,
|
|
18
|
+
cardinality: int,
|
|
19
|
+
is_seq: bool = False,
|
|
20
|
+
feature_source: Optional[TensorFeatureSource] = None,
|
|
21
|
+
feature_hint: Optional[FeatureHint] = None,
|
|
22
|
+
embedding_dim: Optional[int] = None,
|
|
23
|
+
) -> "TensorSchemaBuilder":
|
|
24
|
+
source = [feature_source] if feature_source else None
|
|
25
|
+
self._tensor_schema[name] = TensorFeatureInfo(
|
|
26
|
+
name=name,
|
|
27
|
+
feature_type=FeatureType.CATEGORICAL,
|
|
28
|
+
is_seq=is_seq,
|
|
29
|
+
feature_sources=source,
|
|
30
|
+
feature_hint=feature_hint,
|
|
31
|
+
cardinality=cardinality,
|
|
32
|
+
embedding_dim=embedding_dim,
|
|
33
|
+
)
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
def numerical(
|
|
37
|
+
self,
|
|
38
|
+
name: str,
|
|
39
|
+
tensor_dim: int,
|
|
40
|
+
is_seq: bool = False,
|
|
41
|
+
feature_sources: Optional[List[TensorFeatureSource]] = None,
|
|
42
|
+
feature_hint: Optional[FeatureHint] = None,
|
|
43
|
+
) -> "TensorSchemaBuilder":
|
|
44
|
+
self._tensor_schema[name] = TensorFeatureInfo(
|
|
45
|
+
name=name,
|
|
46
|
+
feature_type=FeatureType.NUMERICAL,
|
|
47
|
+
is_seq=is_seq,
|
|
48
|
+
feature_sources=feature_sources,
|
|
49
|
+
feature_hint=feature_hint,
|
|
50
|
+
tensor_dim=tensor_dim,
|
|
51
|
+
)
|
|
52
|
+
return self
|
|
53
|
+
|
|
54
|
+
def build(self) -> TensorSchema:
|
|
55
|
+
return TensorSchema(list(self._tensor_schema.values()))
|