Skip to main content

Python package for the creation of recommendation systems based on user traces.

Project description

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

from tracerec.algorithms.knowledge_based.transe import TransE
from tracerec.data.triples.triples_manager import TriplesManager
from tracerec.samplers.negative_triple_sampler import NegativeTripleSampler

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')

# Test negative sampling
sampler = NegativeTripleSampler(train_x, triples_manager, strategy='random', device='cpu')
train_x_neg = sampler.sample(num_samples=1, random_state=42)

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))

transe.fit(train_x, train_x_neg, train_y, num_epochs=1, batch_size=1, lr=0.001, verbose=True)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tracerec-0.1.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tracerec-0.1.2-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file tracerec-0.1.2.tar.gz.

File metadata

  • Download URL: tracerec-0.1.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tracerec-0.1.2.tar.gz
Algorithm Hash digest
SHA256 80c81aebdf9b72187c6c1e45c683b7cb9ef1a6525433b7a5d82e77b3026f0e74
MD5 505f07031d2a1abb24040d5433263639
BLAKE2b-256 1e421f19a41705ca94bbad7078970bfc1e766c504190e05a7f85280b9f9a7fe9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tracerec-0.1.2.tar.gz:

Publisher: python-publish.yml on almtav08/tracerec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tracerec-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tracerec-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for tracerec-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c4b13fb80a01f733f8f4bacec2ee953a2af0b40ded973d44e36b0341cb06463
MD5 14309f9d7578e970d812f24fb1e2db36
BLAKE2b-256 ec2ab5e3ebc3591f89ed8b99a65c2ed0d45b23d1f46982ec2710b2a3fbac4e90

See more details on using hashes here.

Provenance

The following attestation bundles were made for tracerec-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on almtav08/tracerec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page