{"id":19343044,"url":"https://github.com/wenkesj/khh","last_synced_at":"2026-06-12T06:32:03.199Z","repository":{"id":98776650,"uuid":"112259056","full_name":"wenkesj/khh","owner":"wenkesj","description":"Vanilla python implementation of the K- Heavy Hitters algorithm (data-structure)","archived":false,"fork":false,"pushed_at":"2017-11-28T02:06:22.000Z","size":6,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T09:16:26.213Z","etag":null,"topics":["algorithms","count-min-sketch","k-heavy-hitters","probabilistic-data-structures"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenkesj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-27T23:03:05.000Z","updated_at":"2022-02-19T22:25:56.000Z","dependencies_parsed_at":"2023-05-25T07:30:18.628Z","dependency_job_id":null,"html_url":"https://github.com/wenkesj/khh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wenkesj/khh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkesj%2Fkhh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkesj%2Fkhh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkesj%2Fkhh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkesj%2Fkhh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenkesj","download_url":"https://codeload.github.com/wenkesj/khh/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenkesj%2Fkhh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34232790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","count-min-sketch","k-heavy-hitters","probabilistic-data-structures"],"created_at":"2024-11-10T03:37:11.483Z","updated_at":"2026-06-12T06:32:03.183Z","avatar_url":"https://github.com/wenkesj.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# khh\nK- Heavy Hitters data-structure implemented in `python`. [This is a nice reference](http://theory.stanford.edu/~tim/s17/l/l2.pdf) for the problem and implementation.\n\n```sh\ngit clone https://github.com/wenkesj/khh.git\n(cd khh \u0026\u0026 python setup.py install)\n```\n\nTrivial example:\n\n```python\nimport enum\n\nfrom khh import KHeavyHitters\n\n\nDozen = 12\nHalfDozen = Dozen / 2\nBakersDozen = Dozen + 1\nBushel = 125\n\n\nclass Fruits(enum.Enum):\n  Apple = 'apple'\n  Orange = 'orange'\n  Banana = 'banana'\n  Strawberry = 'strawberry'\n  Kiwi = 'kiwi'\n  Mango = 'mango'\n\n\nk = 5\ncounts = dict()\nkhh = KHeavyHitters(k)\n\n# add a single banana\nkhh.add(Fruits.Banana)\n\n# add a dozen apples\nfor i in range(Dozen):\n  khh.add(Fruits.Apple)\ncounts[Fruits.Apple] = i\n\n# add 2 \"bushel\"s of mangos, we like mangos\nfor i in range(Bushel * 2):\n  khh.add(Fruits.Mango)\ncounts[Fruits.Mango] = i\n\n# add a bakers oranges\nfor i in range(BakersDozen):\n  khh.add(Fruits.Orange)\ncounts[Fruits.Orange] = i\n\n# add a \"bushel\"\nfor i in range(Bushel):\n  khh.add(Fruits.Strawberry)\ncounts[Fruits.Strawberry] = i\n\ntop_k = khh.top_k()\n# [\u003cFruits.Mango: 'mango'\u003e, \u003cFruits.Strawberry: 'strawberry'\u003e, \u003cFruits.Orange: 'orange'\u003e]\n\nfor f, v in counts.items():\n  if v \u003e= (len(khh) / k): # items that show up more than (n / k) times :)\n    assert f in top_k\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkesj%2Fkhh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenkesj%2Fkhh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenkesj%2Fkhh/lists"}