tsampling


Nametsampling JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/dianasargsyan/tsampling.git
SummaryA package that implements the Thompson Sampling approach for a Multi-Armed Bandit.
upload_time2022-12-15 15:05:51
maintainer
docs_urlNone
authorDiana Sargsyan
requires_python>=3.6
licenseMIT license
keywords tsampling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tsampling
Thompson Sampling Multi-Armed Bandit for Python

A package that implements the Thompson Sampling approach for a Multi-Armed Bandit.
The purpose of this project is to help people simply create and maintain Thompson Sampling experiments that have Bernoulli and Poisson distributions.

## Usage

### Setting up the experiment:

The following method will instantiate the experiment with the default priors.
```python
from tsampling.bernoulli import BernoulliExperiment

experiment = BernoulliExperiment(arms=2)
```

You can also set your custom priors by using the Priors module:
```python

from tsampling.bernoulli import BernoulliExperiment
from tsampling.priors import BetaPrior

pr = BetaPrior()
pr.add_one(mean=0.5, variance=0.2, effective_size=10, label="option1")
pr.add_one(mean=0.6, variance=0.3, effective_size=30, label="option2")
experiment = BernoulliExperiment(priors=pr)
```

### Performing an action:
You can randomly choos which arm to "pull" in the multi-armed bandit:
```python
experiment.choose_arm()
```

### Updating reward:
You can update the different arms information by adding reward information:

```python
rewards = [{"label":"option1", "reward":1}, {"label":"option2", "reward":0}]
experiment.add_rewards(rewards)
```

### Plotting Posterior Distribution:
You can plot the posterior distribution 

```python
experiment.plot_posterior()
```

## Installation

### Pip 
```
pip install tsampling
```

## License
 Free software: MIT license

## Credits

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

_Cookiecutter: https://github.com/audreyr/cookiecutter
`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dianasargsyan/tsampling.git",
    "name": "tsampling",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "tsampling",
    "author": "Diana Sargsyan",
    "author_email": "diana_sargsyan2@edu.aua.am",
    "download_url": "https://files.pythonhosted.org/packages/50/61/c1eb27aa96fa58a20589b081bc09b75b2b07b1a8da94d7f8d5c4e2d3c649/tsampling-0.0.1.tar.gz",
    "platform": null,
    "description": "# tsampling\nThompson Sampling Multi-Armed Bandit for Python\n\nA package that implements the Thompson Sampling approach for a Multi-Armed Bandit.\nThe purpose of this project is to help people simply create and maintain Thompson Sampling experiments that have Bernoulli and Poisson distributions.\n\n## Usage\n\n### Setting up the experiment:\n\nThe following method will instantiate the experiment with the default priors.\n```python\nfrom tsampling.bernoulli import BernoulliExperiment\n\nexperiment = BernoulliExperiment(arms=2)\n```\n\nYou can also set your custom priors by using the Priors module:\n```python\n\nfrom tsampling.bernoulli import BernoulliExperiment\nfrom tsampling.priors import BetaPrior\n\npr = BetaPrior()\npr.add_one(mean=0.5, variance=0.2, effective_size=10, label=\"option1\")\npr.add_one(mean=0.6, variance=0.3, effective_size=30, label=\"option2\")\nexperiment = BernoulliExperiment(priors=pr)\n```\n\n### Performing an action:\nYou can randomly choos which arm to \"pull\" in the multi-armed bandit:\n```python\nexperiment.choose_arm()\n```\n\n### Updating reward:\nYou can update the different arms information by adding reward information:\n\n```python\nrewards = [{\"label\":\"option1\", \"reward\":1}, {\"label\":\"option2\", \"reward\":0}]\nexperiment.add_rewards(rewards)\n```\n\n### Plotting Posterior Distribution:\nYou can plot the posterior distribution \n\n```python\nexperiment.plot_posterior()\n```\n\n## Installation\n\n### Pip \n```\npip install tsampling\n```\n\n## License\n Free software: MIT license\n\n## Credits\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n_Cookiecutter: https://github.com/audreyr/cookiecutter\n`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "A package that implements the Thompson Sampling approach for a Multi-Armed Bandit.",
    "version": "0.0.1",
    "split_keywords": [
        "tsampling"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "60d99fc89dd581346dae134b0b9b0a88",
                "sha256": "d7c5ddbaaa4af7dad311f5cb2f4aa80fce5665c5fa5a4f3c457936c095a584b4"
            },
            "downloads": -1,
            "filename": "tsampling-0.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "60d99fc89dd581346dae134b0b9b0a88",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 7690,
            "upload_time": "2022-12-15T15:05:49",
            "upload_time_iso_8601": "2022-12-15T15:05:49.632023Z",
            "url": "https://files.pythonhosted.org/packages/bc/9c/815b55f46330763ea71f7922ef329e48d93b8b975377eafd69cc0a985a51/tsampling-0.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "47c8b886d00d14ee6c9bdb81f5dd41c7",
                "sha256": "e77343d03b858760dd77503470d17614b8228fd6f8495e2ccdcd0508caeeb83e"
            },
            "downloads": -1,
            "filename": "tsampling-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "47c8b886d00d14ee6c9bdb81f5dd41c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8875,
            "upload_time": "2022-12-15T15:05:51",
            "upload_time_iso_8601": "2022-12-15T15:05:51.691793Z",
            "url": "https://files.pythonhosted.org/packages/50/61/c1eb27aa96fa58a20589b081bc09b75b2b07b1a8da94d7f8d5c4e2d3c649/tsampling-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-15 15:05:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dianasargsyan",
    "github_project": "tsampling.git",
    "lcname": "tsampling"
}
        
Elapsed time: 0.02434s