{ "info": { "author": "Yukino Ikegami", "author_email": "yukinoik@icloud.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Programming Language :: C++", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Linguistic" ], "description": "madoka\n===========\n\n|travis| |coveralls| |pyversion| |version| |license|\n\nMadoka is an implementation of a Count-Min sketch data structure for summarizing data streams.\n\nString-int pairs in a Madoka-Sketch may take less memory than in a standard Python dict, Counter, Redis.\n\nCounting error rate is about 0.0911 %\n\nMore details are described in `Benchmark.ipynb`_\n\n.. _Benchmark.ipynb: https://github.com/ikegami-yukino/madoka-python/blob/master/Benchmark.ipynb\n\nThis module is based on `madoka`_ C++ library.\n\n.. _madoka: https://github.com/s-yata/madoka\n\nNOTE: Madoka-Sketch does not have index of keys. so Madoka-Sketch can not dump all keys such as Python dict's `dict.keys()`. However, when set `k` parameter to costructer, `most_common` method (returns key and value as many as `k`) is available.\n\nContributions are welcome!\n\nInstallation\n============\n\n::\n\n $ pip install madoka\n\nClass\n============\n\nMadoka has some classes having same interface. These classes are vary in value data type. So you can choose for your purpose.\n\nFor example, if you wants to count float data, it's preferable to choose CroquisFloat class or CroquisDouble class.\n\n- Sketch\n - storing unsigned long long (64bit) and fast implementation\n- CroquisFloat\n - storing float (32bit)\n- CroquisDouble\n - storing double (64bit)\n- CroquisUint8\n - storing unsigned char (8bit)\n- CroquisUint16\n - storing unsigned short (16bit)\n- CroquisUint32\n - storing unsigned int (32bit)\n- CroquisUint64\n - storing unsigned long long (64bit)\n\nUsage\n=====\n\nFrom here, I will describe about Sketch class.\nBut, Croquis classes have also same interfaces mostly.\nSo you can use other classes by the same way as Sketch class.\nIn that case, you should replace to intended class from \"Sketch\".\n\n\nCreate a new sketch\n--------------------------------------------\n\n.. code:: python\n\n >>> import madoka\n >>> sketch = madoka.Sketch()\n\n- Sketch madoka.Sketch([width=1048576, max_value=35184372088831, path='', flags=0, seed=0, k=5])\n\n - `width` is a size of register. If you are worrying about gap, you should increase `width` value. The larger `width` is, the fewer mistakes madoka makes in estimating value. But, the larger `width` is, the larger memory consumption is.\n\n - Permission of `path` should be 644\n\n - `k` means Top-K used by `most_common` method. if you don't want to use `most_common` method, then I recommend to set `k=0` so it is slightly fast.\n\n - `madoka.Sketch()` calls `madoka.Sketch.create()`, so you don't have to explicitly call `create()` in initialization\n\n\nIncrement a key value\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch['mami'] += 1\n\nor\n\n.. code:: python\n\n >>> sketch.inc('mami')\n\n\n- int inc(key[, key_length=0])\n\n - Note that `key_length` is automatically determined when not giving `key_length`. Thus, the order of parameters differs from original madoka C++ library.\n\n\nAdd a value to the current key value\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch['mami'] += 6\n\nor\n\n.. code:: python\n\n >>> sketch.add('mami', 6)\n\n\n- int add(key, value[, key_length=0])\n\n - Note that `key_length` is automatically determined when not giving `key_length`. Thus, the order of parameters differs from original madoka C++ library.\n\n\n\nUpdate a key value\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch['mami'] = 6\n\nor\n\n.. code:: python\n\n >>> sketch.set('mami', 6)\n\n\n- void set(key, value[, key_length=0])\n\n * Note that `set()` does nothing when the given value is not greater than the current key value.\n\n * Also note that the new value is saturated when the given value is greater than the upper limit.\n\n * Additionally note that `key_length` is automatically determined when not giving `key_length`. Thus, the order of parameters differs from original madoka C++ library.\n\n\nGet a key value\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch['mami']\n\nor\n\n.. code:: python\n\n >>> sketch.get('mami')\n\n\n- int get(key[, key_length=0])\n\n - Note that `key_length` is automatically determined when not giving `key_length`. Thus, the order of parameters differs from original madoka C++ library.\n\nGet all values\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.values()\n\n\n- generator values()\n\n - Note that processing time increases according to sketch's width. But this method may be slow, so I recommend setting width to less than 1000000 when creating sketch.\n\nSave a sketch to a file\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.save('example.madoka')\n\n- void save(path)\n\n - Permission of `path` should be 644\n\nLoad a sketch from a file\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.load('example.madoka')\n\n- void load(path)\n\n - Permission of `path` should be 644\n\nClear a sketch\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.clear()\n\n- void clear()\n\n * Delete all key-value pairs. It differs from `create()` in maintaining current settings.\n\n\nInitialize a sketch with settings change\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.create()\n\n- void create([width=0, max_value=0, path=NULL, flags=0, seed=0])\n\n - Permission of file given to `path` should be 644\n\nCopy a sketch\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.copy(othersketch)\n\n- void copy(Sketch)\n\n\nMerge two sketches\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch += other_sketch\n\nor\n\n.. code:: python\n\n >>> sketch.merge(othersketch)\n\n- void merge(Sketch[, lhs_filter=None, rhs_filter=None])\n\n - lhs_filter is applied for self.sketch, rhs_filter is applied for given sketch\n\n\nShrink a sketch\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.shrink(sketch, width=1000)\n\n- void shrink(Sketch[, width=0, max_value=0, filter=None, path=None, flags=0])\n\n - When width > 0, width must be less than source sketch\n\n - Permission of `path` should be 644\n\n\nGet summed sketch\n-----------------------\n\n.. code:: python\n\n >>> summed_sketch = sketch + other_sketch\n\n- Create summed sketch, So it does not break original sketches\n\nGet summed sketch by dict\n--------------------------\n\n.. code:: python\n\n >>> summed_sketch = sketch + {'mami': 1, 'kyoko': 2}\n\n- Create summed sketch, So it does not break original sketches\n\n\nCheck whether sketch contains key value\n-----------------------------------------\n\n.. code:: python\n\n >>> 'mami' in sketch\n\n\nGet inner product of two sketches\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.inner_product(other_sketch)\n\n- list inner_product(Sketch)\n\n - Returns [inner product, square length of left hands sketch (float), square length of right hands sketch (float)]\n\nGet median value\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch['madoka'] = 1\n >>> sketch['mami'] = 2\n >>> sketch['sayaka'] = 3\n >>> sketch['kyouko'] = 4\n >>> sketch['homura'] = 5\n >>> sketch.median() # => 3\n\n- int or float median()\n\nApply filter into all values\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.filter(lambda x: x + 1)\n\n- void filter(Callable[, apply_zerovalue=False])\n\n - If apply_zerovalue = True, filter_method is applied also 0 values (It may be slow) (from version 0.6 or later)\n\n - Note that processing time increases according to sketch's width. If you feel this method is slow, I recommend setting width to less than 1000000 when creating sketch\n\nSet values from dict\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.fromdict({'mami': 14, 'madoka': 13})\n\nor\n\n.. code:: python\n\n >>> sketch += {'mami': 14, 'madoka': 13}\n\n\n- void fromdict(dict)\n\nGet most common keys\n--------------------------------------------\n\n.. code:: python\n\n >>> sketch.most_common()\n\n- generator most_common([k=5])\n\n - returns key-value pair as many as `k`\n\n - Note that this method is required to set `k` parameter in constructer.\n\nLicense\n=========\n\n- Wrapper code is licensed under New BSD License.\n- Bundled `madoka`_ C++ library is licensed under the Simplified BSD License.\n\n\n.. |travis| image:: https://travis-ci.org/ikegami-yukino/madoka-python.svg?branch=master\n :target: https://travis-ci.org/ikegami-yukino/madoka-python\n :alt: travis-ci.org\n\n.. |coveralls| image:: https://coveralls.io/repos/ikegami-yukino/madoka-python/badge.svg\n :target: https://coveralls.io/r/ikegami-yukino/madoka-python\n :alt: coveralls.io\n\n.. |pyversion| image:: https://img.shields.io/pypi/pyversions/madoka.svg\n\n.. |version| image:: https://img.shields.io/pypi/v/madoka.svg\n :target: http://pypi.python.org/pypi/madoka/\n :alt: latest version\n\n.. |license| image:: https://img.shields.io/pypi/l/madoka.svg\n :target: http://pypi.python.org/pypi/madoka/\n :alt: license\n\n\nCHANGES\n========\n\n0.7.1 (2018-02-11)\n------------------\n\n- Fix bug for Python 2.7\n\n\n0.7 (2018-02-11)\n----------------\n\n- Support Python 3.5 - 3.7\n- Unsupport Python 2.6\n- Add `most_common()` function (requiring to give `k=n` parameter to constructer)\n- Add `median()` function\n- Fixed a bug that madoka::FILE_PRELOAD does not work\n\n0.6 (2014-11-23)\n----------------\n\n- Support Python 3.4\n- Improve processing time of `inner_product()`\n- Fix `shrink()` method bug\n- Change `filter()` methods param\n- Support with-statement\n- Implement increment-add from dict\n - (e.g.) summed_sketch = sketch + dict; sketch += dict\n\n\n0.5 (2014-04-08)\n----------------\n\n- Add Croquis classes handling some data types (e.g., float, uint8)\n- Given length=True to inner product method, returns also square length of both left hands and right hands sketch\n- Add fromdict method\n\n0.4 (2014-03-30)\n----------------\n\n- Implement dict-like interface (e.g., sketch['key'])\n- Add filter() method\n- Add values() method for dumping all values\n\n0.3 (2014-03-14)\n----------------\n\n- Key length is automatically determined when it is not given\n- Remove filter function\n- Slightly decreasing amount of memory usage\n\n0.2 (2013-10-12)\n----------------\n\nSimplify the step of creating new sketch.\n\n0.1 (2013-10-11)\n----------------\n\nInitial release.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ikegami-yukino/madoka-python", "keywords": "Count-Min Sketch,counter,word count", "license": "New BSD License", "maintainer": "", "maintainer_email": "", "name": "madoka", "package_url": "https://pypi.org/project/madoka/", "platform": "", "project_url": "https://pypi.org/project/madoka/", "project_urls": { "Homepage": "https://github.com/ikegami-yukino/madoka-python" }, "release_url": "https://pypi.org/project/madoka/0.7.1/", "requires_dist": null, "requires_python": "", "summary": "Memory-efficient CountMin Sketch key-value structure (based on Madoka C++ library)", "version": "0.7.1" }, "last_serial": 4888836, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7c31a516146c0f4286e2595598c15975", "sha256": "83c7e29a05895102164f243164381c2b1a3a21cfcba6addbfeab6d7462b9e466" }, "downloads": -1, "filename": "madoka-0.1.tar.gz", "has_sig": false, "md5_digest": "7c31a516146c0f4286e2595598c15975", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 59684, "upload_time": "2013-10-11T18:43:59", "url": "https://files.pythonhosted.org/packages/e6/9e/b514d7024cbc118d7ca8e8d0d50af14fb2af500405a99cfbe25ac589c89e/madoka-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "b6527511efc68aae73e1ba2ee2a5cbd0", "sha256": "9c228be9855bfea68000f5e4fa395e42237cb17492258f6d3f8f284396077fcb" }, "downloads": -1, "filename": "madoka-0.2.tar.gz", "has_sig": false, "md5_digest": "b6527511efc68aae73e1ba2ee2a5cbd0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 60620, "upload_time": "2013-10-12T20:12:34", "url": "https://files.pythonhosted.org/packages/eb/83/5f40eaf54222258e6fcfbaff808a6005b046d169efe8e1ad6ce6ac703bfc/madoka-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "cdb07009aa3cb1c4785ad6fcf28e86fb", "sha256": "ee1dfc17bd407b80f3507cbf7c9398692141a6b1f531175a8859d5f5493310a0" }, "downloads": -1, "filename": "madoka-0.3.tar.gz", "has_sig": false, "md5_digest": "cdb07009aa3cb1c4785ad6fcf28e86fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61003, "upload_time": "2014-03-14T07:15:54", "url": "https://files.pythonhosted.org/packages/8a/b8/c151a228fefd6b23ee4c278e3ff100cab1c19c9e8569dc93b4879985232e/madoka-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "65559a1d450fd0f74cf1ab5653e95556", "sha256": "e2adde915c82181dbc3300f5cad71ad28de4dceda51c1c7cf4a757e1aeeb6610" }, "downloads": -1, "filename": "madoka-0.4.tar.gz", "has_sig": false, "md5_digest": "65559a1d450fd0f74cf1ab5653e95556", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 60785, "upload_time": "2014-03-30T17:45:11", "url": "https://files.pythonhosted.org/packages/9d/53/528e586d9b917c08fb1c9c668823f77f991ad681a30f75ea8f7dd914c9e5/madoka-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "42aab530f5ef0f53be16c47ac816f23b", "sha256": "a5e2a091f12cba8e312b4018d0f5e8e4006973cdf115a3ab4d358b608888b91c" }, "downloads": -1, "filename": "madoka-0.5.tar.gz", "has_sig": false, "md5_digest": "42aab530f5ef0f53be16c47ac816f23b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 84454, "upload_time": "2014-04-07T20:18:30", "url": "https://files.pythonhosted.org/packages/b9/87/05723332721080246bc2c2c2b1d4848d91d88f89fcf144dcfcfbf4dba1c1/madoka-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "edad6b068b472cfb8f23663fb3fe093a", "sha256": "10e2b18e455fb3402483b9544b982918a11d6194d1af412287d07d206bea68d7" }, "downloads": -1, "filename": "madoka-0.6.tar.gz", "has_sig": false, "md5_digest": "edad6b068b472cfb8f23663fb3fe093a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 83388, "upload_time": "2014-11-23T09:48:11", "url": "https://files.pythonhosted.org/packages/d4/e6/94e9545faa4c65cc096fd0833e014cea3fc22ac7dffbc8d064fe066ffdce/madoka-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "e632564ae9851bdc806a88bb7ea82b25", "sha256": "02a170a1cf4807b0ec37a1c9d95950f804cf62ad580aae6a86b9523d1168895e" }, "downloads": -1, "filename": "madoka-0.7.tar.gz", "has_sig": false, "md5_digest": "e632564ae9851bdc806a88bb7ea82b25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 81380, "upload_time": "2019-02-10T18:30:28", "url": "https://files.pythonhosted.org/packages/9c/fc/c6d3914918567d9b852d0c2d30c6a70694176c474c50e8b17bdf42725cf9/madoka-0.7.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "c8228571ac7a0f37f2a4c6dd6107e593", "sha256": "7521eee9ace30b376bb54fdcb2cb42bf6b7a0346b0d0b612f25f3299aa4a95af" }, "downloads": -1, "filename": "madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl", "has_sig": false, "md5_digest": "c8228571ac7a0f37f2a4c6dd6107e593", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 123988, "upload_time": "2019-03-02T18:28:36", "url": "https://files.pythonhosted.org/packages/14/b9/39c7b9144210795f26026dfce9db6faeb8b33be6cdeb3064814dfbcfea43/madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "41c65efa669437e4485c45641bbe442e", "sha256": "e258baa84fc0a3764365993b8bf5e1b065383a6ca8c9f862fb3e3e709843fae7" }, "downloads": -1, "filename": "madoka-0.7.1.tar.gz", "has_sig": false, "md5_digest": "41c65efa669437e4485c45641bbe442e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 81413, "upload_time": "2019-02-10T18:38:01", "url": "https://files.pythonhosted.org/packages/da/eb/95288b1c4aa541eb296a6271e3f8c7ece03b78923ac47dbe95d2287d9f5e/madoka-0.7.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c8228571ac7a0f37f2a4c6dd6107e593", "sha256": "7521eee9ace30b376bb54fdcb2cb42bf6b7a0346b0d0b612f25f3299aa4a95af" }, "downloads": -1, "filename": "madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl", "has_sig": false, "md5_digest": "c8228571ac7a0f37f2a4c6dd6107e593", "packagetype": "bdist_wheel", "python_version": "cp37", "requires_python": null, "size": 123988, "upload_time": "2019-03-02T18:28:36", "url": "https://files.pythonhosted.org/packages/14/b9/39c7b9144210795f26026dfce9db6faeb8b33be6cdeb3064814dfbcfea43/madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl" }, { "comment_text": "", "digests": { "md5": "41c65efa669437e4485c45641bbe442e", "sha256": "e258baa84fc0a3764365993b8bf5e1b065383a6ca8c9f862fb3e3e709843fae7" }, "downloads": -1, "filename": "madoka-0.7.1.tar.gz", "has_sig": false, "md5_digest": "41c65efa669437e4485c45641bbe442e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 81413, "upload_time": "2019-02-10T18:38:01", "url": "https://files.pythonhosted.org/packages/da/eb/95288b1c4aa541eb296a6271e3f8c7ece03b78923ac47dbe95d2287d9f5e/madoka-0.7.1.tar.gz" } ] }