pytorchltr2


Namepytorchltr2 JSON
Version 0.2.2.post1 PyPI version JSON
download
home_pagehttps://github.com/akreuzer/pytorchltr
SummaryLearning to Rank with PyTorch (Fork of pytorchltr)
upload_time2024-01-03 00:23:19
maintainer
docs_urlNone
authorRolf Jagerman
requires_python>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements filelock fsspec jinja2 joblib markupsafe mpmath networkx numpy scikit-learn scipy sympy threadpoolctl torch typing-extensions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyTorch Learning to Rank (LTR)

This is a library for Learning to Rank (LTR) with PyTorch.
The goal of this library is to support the infrastructure necessary for performing LTR experiments in PyTorch.

This is a fork of the original [pytorchltr](https://github.com/rjagerman/pytorchltr). It add fix and updates to allow it to work with Python >=3.10.


## Installation

In your virtualenv simply run:

    pip install pytorchltr2

Note that this library requires Python 3.10 or higher.

## Documentation

Original documentation is available [here](https://pytorchltr.readthedocs.io/).

## Example

See `examples/01-basic-usage.py` for a more complete example including evaluation

```python
import torch
from pytorchltr.datasets import Example3
from pytorchltr.loss import PairwiseHingeLoss

# Load dataset
train = Example3(split="train")
collate_fn = train.collate_fn()

# Setup model, optimizer and loss
model = torch.nn.Linear(train[0].features.shape[1], 1)
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
loss = PairwiseHingeLoss()

# Train for 3 epochs
for epoch in range(3):
    loader = torch.utils.data.DataLoader(train, batch_size=2, collate_fn=collate_fn)
    for batch in loader:
        xs, ys, n = batch.features, batch.relevance, batch.n
        l = loss(model(xs), ys, n).mean()
        optimizer.zero_grad()
        l.backward()
        optimizer.step()
```

## Dataset Disclaimer
This library provides utilities to automatically download and prepare several public LTR datasets.
We cannot vouch for the quality, correctness or usefulness of these datasets.
We do not host or distribute these datasets and it is ultimately **your responsibility** to determine whether you have permission to use each dataset under its respective license.

## Citing
If you find this software useful for your research, please cite the publication for the original pytorchltr.

    @inproceedings{jagerman2020accelerated,
        author = {Jagerman, Rolf and de Rijke, Maarten},
        title = {Accelerated Convergence for Counterfactual Learning to Rank},
        year = {2020},
        publisher = {Association for Computing Machinery},
        address = {New York, NY, USA},
        booktitle = {Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval},
        doi = {10.1145/3397271.3401069},
        series = {SIGIR’20}
    }

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/akreuzer/pytorchltr",
    "name": "pytorchltr2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "",
    "author": "Rolf Jagerman",
    "author_email": "a_kreuzer@posteo.de",
    "download_url": "https://files.pythonhosted.org/packages/74/25/ff598b7feb6216866260c95245c0c151c819dae020ce39a75ed8afe9a74f/pytorchltr2-0.2.2.post1.tar.gz",
    "platform": null,
    "description": "# PyTorch Learning to Rank (LTR)\n\nThis is a library for Learning to Rank (LTR) with PyTorch.\nThe goal of this library is to support the infrastructure necessary for performing LTR experiments in PyTorch.\n\nThis is a fork of the original [pytorchltr](https://github.com/rjagerman/pytorchltr). It add fix and updates to allow it to work with Python >=3.10.\n\n\n## Installation\n\nIn your virtualenv simply run:\n\n    pip install pytorchltr2\n\nNote that this library requires Python 3.10 or higher.\n\n## Documentation\n\nOriginal documentation is available [here](https://pytorchltr.readthedocs.io/).\n\n## Example\n\nSee `examples/01-basic-usage.py` for a more complete example including evaluation\n\n```python\nimport torch\nfrom pytorchltr.datasets import Example3\nfrom pytorchltr.loss import PairwiseHingeLoss\n\n# Load dataset\ntrain = Example3(split=\"train\")\ncollate_fn = train.collate_fn()\n\n# Setup model, optimizer and loss\nmodel = torch.nn.Linear(train[0].features.shape[1], 1)\noptimizer = torch.optim.SGD(model.parameters(), lr=0.1)\nloss = PairwiseHingeLoss()\n\n# Train for 3 epochs\nfor epoch in range(3):\n    loader = torch.utils.data.DataLoader(train, batch_size=2, collate_fn=collate_fn)\n    for batch in loader:\n        xs, ys, n = batch.features, batch.relevance, batch.n\n        l = loss(model(xs), ys, n).mean()\n        optimizer.zero_grad()\n        l.backward()\n        optimizer.step()\n```\n\n## Dataset Disclaimer\nThis library provides utilities to automatically download and prepare several public LTR datasets.\nWe cannot vouch for the quality, correctness or usefulness of these datasets.\nWe do not host or distribute these datasets and it is ultimately **your responsibility** to determine whether you have permission to use each dataset under its respective license.\n\n## Citing\nIf you find this software useful for your research, please cite the publication for the original pytorchltr.\n\n    @inproceedings{jagerman2020accelerated,\n        author = {Jagerman, Rolf and de Rijke, Maarten},\n        title = {Accelerated Convergence for Counterfactual Learning to Rank},\n        year = {2020},\n        publisher = {Association for Computing Machinery},\n        address = {New York, NY, USA},\n        booktitle = {Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval},\n        doi = {10.1145/3397271.3401069},\n        series = {SIGIR\u201920}\n    }\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Learning to Rank with PyTorch (Fork of pytorchltr)",
    "version": "0.2.2.post1",
    "project_urls": {
        "Homepage": "https://github.com/akreuzer/pytorchltr"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46b95c2924c70fda82b8ea8272cadaeaa611a51167a996ba95d66f84b21220a1",
                "md5": "c91cb584098decd16ab9ae384b1690fd",
                "sha256": "65e6b03eae29a1cd8a26ea7a44adb7aa3d4eb6ec26fe7948493aa7a300b7a3e5"
            },
            "downloads": -1,
            "filename": "pytorchltr2-0.2.2.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c91cb584098decd16ab9ae384b1690fd",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10",
            "size": 500469,
            "upload_time": "2024-01-03T00:26:07",
            "upload_time_iso_8601": "2024-01-03T00:26:07.411230Z",
            "url": "https://files.pythonhosted.org/packages/46/b9/5c2924c70fda82b8ea8272cadaeaa611a51167a996ba95d66f84b21220a1/pytorchltr2-0.2.2.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f4e7c03faf7d2676462c34c9a2961d320dd940b1f573976440bbf003f9e49e9",
                "md5": "b1dfbc33f1aa8be1aff153258d496b87",
                "sha256": "b5f46166ad739b429502ca473414f4c129ca3cddad3290cc52e3b855ab346867"
            },
            "downloads": -1,
            "filename": "pytorchltr2-0.2.2.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b1dfbc33f1aa8be1aff153258d496b87",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10",
            "size": 537161,
            "upload_time": "2024-01-03T00:27:00",
            "upload_time_iso_8601": "2024-01-03T00:27:00.508950Z",
            "url": "https://files.pythonhosted.org/packages/2f/4e/7c03faf7d2676462c34c9a2961d320dd940b1f573976440bbf003f9e49e9/pytorchltr2-0.2.2.post1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7425ff598b7feb6216866260c95245c0c151c819dae020ce39a75ed8afe9a74f",
                "md5": "8842b71429bd8ed7737ca93165da8c37",
                "sha256": "767c9ef16784df09a488368a6ab133fdf322059d94922dbde190b12216b419da"
            },
            "downloads": -1,
            "filename": "pytorchltr2-0.2.2.post1.tar.gz",
            "has_sig": false,
            "md5_digest": "8842b71429bd8ed7737ca93165da8c37",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 177021,
            "upload_time": "2024-01-03T00:23:19",
            "upload_time_iso_8601": "2024-01-03T00:23:19.984674Z",
            "url": "https://files.pythonhosted.org/packages/74/25/ff598b7feb6216866260c95245c0c151c819dae020ce39a75ed8afe9a74f/pytorchltr2-0.2.2.post1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 00:23:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "akreuzer",
    "github_project": "pytorchltr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "filelock",
            "specs": [
                [
                    "==",
                    "3.13.1"
                ]
            ]
        },
        {
            "name": "fsspec",
            "specs": [
                [
                    "==",
                    "2023.10.0"
                ]
            ]
        },
        {
            "name": "jinja2",
            "specs": [
                [
                    "==",
                    "3.1.2"
                ]
            ]
        },
        {
            "name": "joblib",
            "specs": [
                [
                    "==",
                    "1.3.2"
                ]
            ]
        },
        {
            "name": "markupsafe",
            "specs": [
                [
                    "==",
                    "2.1.3"
                ]
            ]
        },
        {
            "name": "mpmath",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "networkx",
            "specs": [
                [
                    "==",
                    "3.2.1"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    "==",
                    "1.26.1"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    "==",
                    "1.3.2"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    "==",
                    "1.11.3"
                ]
            ]
        },
        {
            "name": "sympy",
            "specs": [
                [
                    "==",
                    "1.12"
                ]
            ]
        },
        {
            "name": "threadpoolctl",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "torch",
            "specs": [
                [
                    "==",
                    "2.1.0"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.8.0"
                ]
            ]
        }
    ],
    "lcname": "pytorchltr2"
}
        
Elapsed time: 0.26810s