{"id":21850594,"url":"https://github.com/freakwill/ezstat","last_synced_at":"2026-05-21T05:32:05.260Z","repository":{"id":57427955,"uuid":"401206772","full_name":"Freakwill/ezstat","owner":"Freakwill","description":"OO For easy statistics","archived":false,"fork":false,"pushed_at":"2021-08-30T03:45:30.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-27T20:20:17.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Freakwill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-30T03:39:15.000Z","updated_at":"2021-08-30T03:45:32.000Z","dependencies_parsed_at":"2022-09-09T05:01:05.637Z","dependency_job_id":null,"html_url":"https://github.com/Freakwill/ezstat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fezstat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fezstat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fezstat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fezstat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freakwill","download_url":"https://codeload.github.com/Freakwill/ezstat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244843182,"owners_count":20519778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-28T00:18:25.561Z","updated_at":"2026-05-21T05:32:05.232Z","avatar_url":"https://github.com/Freakwill.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ezstat: Easy statistics\n\n\n\nOO For easy statistics, inspired by `Statistics` class of [deap](https://deap.readthedocs.io/en/master/index.html)\n\nIt is really easy and awesome! Believe me!\n\n![](logo.jpg)\n\n## Introduction\n\n`ezstat` is built for easy statistics, esp. for the history of iterations.\n\nThe main class `Statistics` just extends `dict{str:function}` (called statistics dict), function here will act on the object of statistics. The values of dict have not to be a function, if it is a string, then the object of method with the same name is applied.\n\nFrankly, It just borrows the idea from the `Statistics` class of [deap](https://deap.readthedocs.io/en/master/index.html). But unlike the author of deap, I just create it a subclass of dict, need not define strange methods.\n\nSee the following example and function `_call`, the underlying implementation.\n\nPseudo code of `_call`:\n```python\n    if s: str\n        f = getattr(obj, s)\n        if f: function\n            r = f()\n        else\n            r = f\n    elif s: function\n        r = s(obj)\n    elif s is number:\n        r = s\n```\n\n\n## Installation\n`pip install ezstat`\n\n## Examples\n\nExample:\n\n```python\n\u003e\u003e\u003e import numpy as np\n\n\u003e\u003e\u003e T = np.random.random((100,100))\n\u003e\u003e\u003e stat = Statistics({'mean': lambda x: np.mean(np.mean(x, axis=1)), 'max': lambda x: np.max(np.mean(x, axis=1)), 'shape':'shape'})\n\u003e\u003e\u003e print(stat(T))\n\u003e\u003e\u003e {'mean': 0.5009150557686407, 'max': 0.5748552862392957, 'shape': (100, 100)}\n\n\u003e\u003e\u003e print(stat(T, split=True)) # split the tuple if it needs\n\u003e\u003e\u003e {mean': 0.5009150557686407, 'max': 0.5748552862392957, 'shape-0': 100, 'shape-1': 100}\n```\n\n`MappingStatistics` is a subclass of `Statistics`. It just copes with iterable object, and maps the obect to an array by funcional attribute `key`.\n\nExample:\n\n```python\n\u003e\u003e\u003e stat = MappingStatistics('mean', {'mean':np.mean, 'max':np.max})\n\u003e\u003e\u003e print(stat(T))\n\u003e\u003e\u003e {'mean': 0.5009150557686407, 'max': 0.5748552862392957}\n```\n\nIn the exmaple, 'mean', an attribute of T, maps T to a 1D array.\n\n## Advanced Usage\n\n`Statistics` acts on a list/tuple of objects iteratively, gets a series of results,\nforming an object of `pandas.DataFrame`. In fact, it is insprited by `Statistics` class of third part lib [deap](https://deap.readthedocs.io/en/master/index.html). In some case, it collects a list of dicts of the statistics result for a series of objects. It is suggested to transform to DataFrame object.\n\n```python\nhistory = pd.DataFrame(columns=stat.keys())\nfor obj in objs:\n    history = history.append(stat(obj), ignore_index=True)\n```\n\n## To Do\n\n- [ ]  To define tuple of functions for the value of statistics dict.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreakwill%2Fezstat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreakwill%2Fezstat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreakwill%2Fezstat/lists"}