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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tracerec-0.3.0.tar.gz.
File metadata
- Download URL: tracerec-0.3.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f946727c6ed645e40fe73f3dbe5055a4fa07dcb12867ada60aa24839742e4c54
|
|
| MD5 |
647e5de90f03a7ee5431702656ad7177
|
|
| BLAKE2b-256 |
d21c9c832adbbad2ce78d4f3f2e85c49b9948b211cf9d5da9c1b058e20ba3b5b
|
Provenance
The following attestation bundles were made for tracerec-0.3.0.tar.gz:
Publisher:
python-publish.yml on almtav08/tracerec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracerec-0.3.0.tar.gz -
Subject digest:
f946727c6ed645e40fe73f3dbe5055a4fa07dcb12867ada60aa24839742e4c54 - Sigstore transparency entry: 412435103
- Sigstore integration time:
-
Permalink:
almtav08/tracerec@48417957e5429cfecc74faf364b2f4ee88179aec -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/almtav08
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@48417957e5429cfecc74faf364b2f4ee88179aec -
Trigger Event:
push
-
Statement type:
File details
Details for the file tracerec-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tracerec-0.3.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1731fc3888579508744c848bbf2aa65c011662a19df314ab6cf4f02f641e82bb
|
|
| MD5 |
b6350c95ee1b09de7cbf65148c6e6007
|
|
| BLAKE2b-256 |
cf6da2ccc9243cf1107e562cc632f76bd77ce053c51544461f209058c1a50bd6
|
Provenance
The following attestation bundles were made for tracerec-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on almtav08/tracerec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tracerec-0.3.0-py3-none-any.whl -
Subject digest:
1731fc3888579508744c848bbf2aa65c011662a19df314ab6cf4f02f641e82bb - Sigstore transparency entry: 412435114
- Sigstore integration time:
-
Permalink:
almtav08/tracerec@48417957e5429cfecc74faf364b2f4ee88179aec -
Branch / Tag:
refs/tags/0.3.0 - Owner: https://github.com/almtav08
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@48417957e5429cfecc74faf364b2f4ee88179aec -
Trigger Event:
push
-
Statement type: