{ "info": { "author": "Pierre Paci", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "# Mojito\n\nMocking temporal data made easy !\n\nThere are lot of data mocking framework in Python. But none of them are really oriented toward generating \nstatistically homogeneous data, especially temporal event. **Mojito is designed for that !**\n\n## How to use it\nStart by installing Mojito `pip install git+https://github.com/PPACI/mojito.git`.\n\n```python\nfrom datetime import datetime\nfrom pprint import pprint\n\nfrom mojito import DateGenerator, EventComposer, FixedValueGenerator, NumberGenerator, PropertyEventGenerator, \\\n RandomChoiceGenerator\n\nevent1 = PropertyEventGenerator(\n properties={\n \"timestamp\": DateGenerator(center=datetime(2018, 5, 2, 0, 0, 0), deviation=3 * 3600),\n \"age\": NumberGenerator(mean=15, deviation=3, return_int=True),\n \"gender\": RandomChoiceGenerator(['M', 'F']),\n \"label\": FixedValueGenerator(1)\n })\nevent2 = PropertyEventGenerator(\n properties={\n \"timestamp\": DateGenerator(center=datetime(2018, 5, 10, 0, 0, 0), deviation=3 * 3600, skew=0),\n \"age\": NumberGenerator(mean=30, deviation=3, return_int=True),\n \"gender\": RandomChoiceGenerator(['M', 'F'], weights=[2, 1]),\n \"label\": FixedValueGenerator(0)\n })\n\ncomposer = EventComposer()\ncomposer.add_generator(event1, 3) # 3 samples from this generator\ncomposer.add_generator(event2, 2) # 2 samples from this generator\n\npprint(composer.generate(shuffle=True))\n```\nWill output\n```python\n[{'age': 16.0,\n 'gender': 'M',\n 'label': 1,\n 'timestamp': datetime.datetime(2018, 5, 1, 22, 23, 1, 450298)},\n {'age': 19.0,\n 'gender': 'F',\n 'label': 1,\n 'timestamp': datetime.datetime(2018, 5, 1, 21, 0, 11, 583775)},\n {'age': 30.0,\n 'gender': 'M',\n 'label': 0,\n 'timestamp': datetime.datetime(2018, 5, 9, 22, 57, 30, 441924)},\n {'age': 15.0,\n 'gender': 'F',\n 'label': 1,\n 'timestamp': datetime.datetime(2018, 5, 2, 5, 59, 54, 96498)},\n {'age': 32.0,\n 'gender': 'M',\n 'label': 0,\n 'timestamp': datetime.datetime(2018, 5, 10, 0, 15, 55, 676862)}]\n```\n\n## API\nMojito use a model where a **PropertyEventGenerator** will be used to generate sample events.\nAn **Event** is something happening, characterized by the statistical distribution of the sample it represent.\nA **Sample** is the generated data. It could represent a visit on your site, or someone buying a specific item\nor whatever.\nRemember that if you want to generate sample from two statistical distribution, you will have to create two events and\ncompose them as in the example.\nCurrently, the main distribution used to generate data is the **Normal distribution** as it's used to represent\nlot's of real life distribution.\n\n### EventGenerator\nA **PropertyEventGenetator** will be instantiated with a dictionary of {\"name\":PropertyGenerator}.\nThis event generator will be at the center of your mocking task as it's describing how event should look like.\n\n### PropertyGenerator\nYou have access to the following **PropertyGenerator**\n* **DateGenerator**\n * Output datetime distributed around the supplied center datetime\n * Distribution is a [Skew Normal](https://en.wikipedia.org/wiki/Skew_normal_distribution)\n * You can pass `skew=0` to have a non skewed normal distribution\n * `scale` is in second, so `deviation=3600` will result in a standard deviation of 1 hours around the provided datetime\n* **FixedValueGenerator**\n * Always output the same value\n* **RandomChoiceGenerator**\n * Take random choice from a provided list of possibilities\n * You can pass `weights=[a, b]` to weight the list accordingly\n* **NumberGenerator**\n * Output number distributed around the supplied mean\n * Distribution is a [Skew Normal](https://en.wikipedia.org/wiki/Skew_normal_distribution)\n * You can pass `skew=0` to have a non skewed normal distribution\n * You can pass `return_int=True` to generate *integer* instead of *float*\n * Also available as NormalNumberGenerator class\n* **PoissonNumberGenerator**\n * Output number from a [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution)\n * Only distribution parameter is `mu`, the average number of event in the time period\n * You can pass `return_int=True` to generate *integer* instead of *float*\n\n\n### Composition\nReal models are aggregation of multiple, different, events. To simulate this, you can use the *EventComposer*.\n````python\ncomposer = EventComposer()\ncomposer.add_generator(event1, 3) # 3 samples from this generator\ncomposer.add_generator(event2, 2) # 2 samples from this generator\n````\n\nAdd your EventGenerator and the number of wanted generated events from each generator.\nYou can also remove one with `.remove_generator(event1)`.\n\n* `.generate()` will return you a list of generated events as dictionary\n* `.to_csv(\"output.csv\")` will save the generated events as csv, ready for your process !\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/PPACI/mojito", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mojito-mock", "package_url": "https://pypi.org/project/mojito-mock/", "platform": "", "project_url": "https://pypi.org/project/mojito-mock/", "project_urls": { "Homepage": "https://github.com/PPACI/mojito" }, "release_url": "https://pypi.org/project/mojito-mock/0.3.0/", "requires_dist": [ "numpy (==1.13.3)", "scipy (==1.1.0)" ], "requires_python": "", "summary": "Mocking temporal data made easy !", "version": "0.3.0" }, "last_serial": 4019879, "releases": { "0.3.0": [ { "comment_text": "", "digests": { "md5": "697844db2a406dc545f63cac8ebc6d33", "sha256": "26d53bd7718d697ef2bc41325e26ea017cac4f58aa44ed7d32de2561357e0636" }, "downloads": -1, "filename": "mojito_mock-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "697844db2a406dc545f63cac8ebc6d33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8788, "upload_time": "2018-07-01T09:54:04", "url": "https://files.pythonhosted.org/packages/61/1b/a749647928c469d2ded2b6c9c0ab7952583e863a5d71ad9258af3252ac73/mojito_mock-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "55bc59eebfbc6410e2f371b7b9318d03", "sha256": "2379ae505a7e5a086636c72b1afdab4372a6e2dbd417bd3214b25d37d3f51576" }, "downloads": -1, "filename": "mojito-mock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "55bc59eebfbc6410e2f371b7b9318d03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5276, "upload_time": "2018-07-01T09:54:05", "url": "https://files.pythonhosted.org/packages/16/de/f35b72f58e2ec6010cb07d41698661017f66f20f691b32dccb3938880efa/mojito-mock-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "697844db2a406dc545f63cac8ebc6d33", "sha256": "26d53bd7718d697ef2bc41325e26ea017cac4f58aa44ed7d32de2561357e0636" }, "downloads": -1, "filename": "mojito_mock-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "697844db2a406dc545f63cac8ebc6d33", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8788, "upload_time": "2018-07-01T09:54:04", "url": "https://files.pythonhosted.org/packages/61/1b/a749647928c469d2ded2b6c9c0ab7952583e863a5d71ad9258af3252ac73/mojito_mock-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "55bc59eebfbc6410e2f371b7b9318d03", "sha256": "2379ae505a7e5a086636c72b1afdab4372a6e2dbd417bd3214b25d37d3f51576" }, "downloads": -1, "filename": "mojito-mock-0.3.0.tar.gz", "has_sig": false, "md5_digest": "55bc59eebfbc6410e2f371b7b9318d03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5276, "upload_time": "2018-07-01T09:54:05", "url": "https://files.pythonhosted.org/packages/16/de/f35b72f58e2ec6010cb07d41698661017f66f20f691b32dccb3938880efa/mojito-mock-0.3.0.tar.gz" } ] }