Skip to main content

Package for generating and evaluating patterns in quantitative reports

Project description

data-patterns

Pypi Version Build Status Documentation Status License

Package for generating and evaluating data-patterns in quantitative reports

Features

Here is what the package does:

  • Generating and evaluating patterns in structured datasets and exporting to Excel and JSON

  • Transforming generated patterns into XBRL validation rules and Pandas code

  • Evaluating reporting data with data quality rules published by De Nederlandsche Bank (to be provided)

Quick overview

To install the package

pip install data_patterns

To introduce the features of the this package define the following Pandas DataFrame:

df = pd.DataFrame(columns = ['Name',       'Type',             'Assets', 'TV-life', 'TV-nonlife' , 'Own funds', 'Excess'],
                  data   = [['Insurer  1', 'life insurer',     1000,     800,       0,             200,         200],
                            ['Insurer  2', 'non-life insurer', 4000,     0,         3200,          800,         800],
                            ['Insurer  3', 'non-life insurer', 800,      0,         700,           100,         100],
                            ['Insurer  4', 'life insurer',     2500,     1800,      0,             700,         700],
                            ['Insurer  5', 'non-life insurer', 2100,     0,         2200,          200,         200],
                            ['Insurer  6', 'life insurer',     9000,     8800,      0,             200,         200],
                            ['Insurer  7', 'life insurer',     9000,     0,         8800,          200,         200],
                            ['Insurer  8', 'life insurer',     9000,     8800,      0,             200,         200],
                            ['Insurer  9', 'non-life insurer', 9000,     0,         8800,          200,         200],
                            ['Insurer 10', 'non-life insurer', 9000,     0,         8800,          200,         199.99]])
df.set_index('Name', inplace = True)

Start by defining a PatternMiner:

miner = data_patterns.PatternMiner(df)

To generate patterns use the find-function of this object:

df_patterns = miner.find({'name'      : 'equal values',
                          'pattern'   : '=',
                          'parameters': {"min_confidence": 0.5,
                                         "min_support"   : 2}})

The result is a DataFrame with the patterns that were found. The first part of the DataFrame now contains

id

pattern_id

P columns

relation type

Q columns

support

exceptions

confidence

0

equal values

[Own funds]

=

[Excess]

9

1

0.9

1

equal values

[Excess]

=

[Own funds]

9

1

0.9

The miner finds two patterns; the first states that the ‘Own funds’-column is identical to the ‘Excess’-column in 9 of the 10 cases (with a confidence of 90 %, there is one case where the equal-pattern does not hold), and the second pattern is identical to the first but with the columns reversed.

To analyze data with the generated set of data-patterns use the analyze function with the dataframe with the data as input:

df_results = miner.analyze(df)

The result is a DataFrame with the results. If we select result_type = False then the first part of the output contains

index

result_type

pattern_id

P columns

relation type

Q columns

P values

Q values

Insurer 10

False

equal values

[Own funds]

=

[Excess]

[200]

[199.99]

Insurer 10

False

equal values

[Excess]

=

[Own funds]

[199.99]

[200]

Other patterns you can use are ‘>’, ‘<’, ‘<=’, ‘>=’, ‘!=’, ‘sum’, and ‘–>’.

Read the documentation for more features.

History

0.1.0 (2019-10-27)

  • Development release.

0.1.11 (2019-11-6)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_patterns-0.1.13.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_patterns-0.1.13-py2.py3-none-any.whl (14.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file data_patterns-0.1.13.tar.gz.

File metadata

  • Download URL: data_patterns-0.1.13.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for data_patterns-0.1.13.tar.gz
Algorithm Hash digest
SHA256 bb88e4bb7fadd09cadb25cc95df3a229612f3416e79f07a1a671465aaa1b4a5c
MD5 862fabe43766f199e2c47f8c337df99e
BLAKE2b-256 1a514a0d4ddf9dd0096aa1198825ff5c11ecad0f05984e33081a9108d5af5342

See more details on using hashes here.

File details

Details for the file data_patterns-0.1.13-py2.py3-none-any.whl.

File metadata

  • Download URL: data_patterns-0.1.13-py2.py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for data_patterns-0.1.13-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5688f4991682b1857cb3bc75cf4a9581b3d91aa8ab060573ae42a0054a22cdc2
MD5 5915898056692a2fa8270635f30219c7
BLAKE2b-256 bce68857f46d5091c03775a7a6e039669bc3c60e3547b9d92e5a28c0e92820eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page