tracerec
Python package for the creation of recommendation systems based on user traces.
Inslation
With pip:
pip install tracerec
With Poetry:
poetry add tracerec
Development
For contributing to the development of this package, you can clone the repository and install the dependencies using Poetry.
# Clone the repository
git clone https://github.com/almtav08/tracerec.git
cd tracerec
# Install dev dependencies
poetry install
Usage
import torch
from tracerec.algorithms.knowledge_based.transe import TransE
from tracerec.data.triples.triples_manager import TriplesManager
from tracerec.samplers.path_based_sampler import PathBasedNegativeSampler
# Create a sample triples manager with some triples
triples = [
(1, 0, 2),
(2, 0, 3),
(3, 0, 4)
]
triples_manager = TriplesManager(triples)
train_x, train_y, test_x, test_y = triples_manager.split(train_ratio=0.8, relation_ratio=True, random_state=42, device='cpu')
# Negative sampling
all_triples = triples_manager.get_triples()
all_entities = triples_manager.get_entities()
entity_paths = triples_manager.get_entity_paths()
sampler = PathBasedNegativeSampler(all_triples, all_entities, corruption_ration=0.5, device='cpu', entity_paths=entity_paths, min_distance=1.0)
train_x_neg = sampler.sample(train_x, num_samples=1, random_state=42)
# Create and compile the TransE model
transe = TransE(num_entities=4, num_relations=1, embedding_dim=10, device='cpu', norm=1)
transe.compile(optimizer=torch.optim.Adam, criterion=torch.nn.MarginRankingLoss(margin=1.0))
# Fit the model
transe.fit(train_x, train_x_neg, train_y, num_epochs=1, batch_size=1, lr=0.001, verbose=True)
License
MIT
Release files for tracerec 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tracerec-0.4.6.tar.gz | 18.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tracerec-0.4.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.3 kB
Release files / tracerec-0.4.6.tar.gz
| Download URL | tracerec-0.4.6.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5213d6160c027c3ab75b6e628490c36a9fc34ca48ebc6fe9efe28a5842e76dfa
|
|
BLAKE2b-256 checksum How to use checksums |
37e14324aaac11c3983d4fd81b122af6b9fd9d0db5bbf1e8d0423a058f80dc9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2025.
Transparency logRelease files / tracerec-0.4.6-py3-none-any.whl
| Download URL | tracerec-0.4.6-py3-none-any.whl |
|---|---|
| Size | 32.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe8c5b89c28a875ae68214dd7074e235c59f45aa0e23149abb94bf1c35ab99b4
|
|
BLAKE2b-256 checksum How to use checksums |
ef2d002c9d6550b582867878650b69537e38c679b13a242a6547b5487ce08f89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2025.
Transparency log