Skip to main content

Ezstat: Easy statistics

OO For easy statistics, inspired by Statistics class of deap

It is really easy and awesome! Believe me!

Introduction

ezstat is built for easy statistics, esp. for the history of iterations.

Statistics

The 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.

Frankly, It just borrows the idea from the Statistics class of deap. But unlike the author of deap, I just create it a subclass of dict, need not define strange methods.

See the following example and function _call, the underlying implementation.

Examples

Example:

>>> import numpy as np

>>> T = np.random.random((100,100)) # samples(one hundrand 100D samples)
>>> stat = Statistics({'mean': np.mean, 'max': 'max', 'shape':'shape'}) # create statistics
>>> print(stat(T))
>>> {'mean': 0.5009150557686407, 'max': 0.5748552862392957, 'shape': (100, 100)}

>>> print(stat(T, split=True)) # split the tuple if it needs
>>> {mean': 0.5009150557686407, 'max': 0.5748552862392957, 'shape[0]': 100, 'shape[1]': 100}
# with sub-statistics
s = Statistics({'mean': np.mean,
'extreme': {'max':'max', 'min':np.min},  # as a sub-statistics
'shape':'shape'})
print(s(X))
# dict-valued statistics, equivalent to the above
s = Statistics({'mean': np.mean, 'extreme': lambda x:{'max': np.max(x), 'min': np.min(x)}, 'shape':'shape'})
print(s(X))

#Result: {'mean': 0.49786554518848564, 'extreme[max]': 0.9999761647791217, 'extreme[min]': 0.0001368184546896023, 'shape': (100, 100)}

MappingStatistics

MappingStatistics is a subclass of Statistics. It only copes with iterable object, and maps the obect to an array by funcional attribute key.

Example:

>>> stat = MappingStatistics(key='mean', {'mean':np.mean, 'max':np.max})
>>> print(stat(T))
>>> {'mean': 0.5009150557686407, 'max': 0.5748552862392957}

In the exmaple, 'mean', an attribute of T, maps T to a 1D array.

Advanced Usage

Statistics acts on a list/tuple of objects iteratively, gets a series of results, forming an object of pandas.DataFrame. In fact, it is insprited by Statistics class of third part lib deap. 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.

history = pd.DataFrame(columns=stat.keys())
for obj in objs:
    history = history.append(stat(obj), ignore_index=True)

To Do

  • To define tuple of functions for the value of statistics dict.

Metadata

Release files for ezstat 2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ezstat 2.4
File Size Uploaded Provenance Actions
ezstat-2.4.tar.gz 4.6 kB Without provenance Details for ezstat-2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ezstat 2.4
File Interpreter ABI Platform Actions
ezstat-2.4-py3-none-any.whl Python 3 none any Details for ezstat-2.4-py3-none-any.whl

Total release size: 9.4 kB

Release files / ezstat-2.4.tar.gz

Download URL ezstat-2.4.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
43e78dabbd67d936d07892578e69efed59a5d749ac880553eca6009cbac29fda
BLAKE2b-256 checksum
How to use checksums
9ad37e07cbfde4be64cc299a500e9e653ddcf21a06d404364e7f0a5e3a63d301
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.14 Darwin/21.6.0

Release files / ezstat-2.4-py3-none-any.whl

Download URL ezstat-2.4-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a41ffd9b9cca52ccc90e8d7d984e96c6845baad90670146fc30535d6c14932b
BLAKE2b-256 checksum
How to use checksums
6f63eb4b7fa46bd071952a8d6396f6c672b17eca44b658b744f81b804a6488e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.14 Darwin/21.6.0

Security for ezstat 2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page