Skip to main content

Machine-Readable Data Analysis Results with Function Wrappers

Project description

mrap

PyPI version Python coverage

100% AI-free: we did not use any AI technologies in developing this package.

The goal of mrap is to provide wrapper functions to reduce the user's effort in writing machine-readable data with the dtreg library. All-in-one wrappers (such as scipy_f_oneway) will cover functions from scipy and other widely used libraries. The mrap.analytic_instances module contains wrappers for analytical schemata used by TIB Knowledge Loom.

To write the results of your data analysis as JSON-LD:

  • Select a wrapper from mrap, check the types of arguments it requires, and create an instance.
  • Modify the instance by setting or correcting its fields manually.
  • Write the finalised instance as a machine-readable JSON-LD file.

Installation

## activate a virtual environment (optional)
python3 -m venv .venv
source .venv/bin/activate
## install from PyPi:
pip install mrap

Example

Let us assume you intend to report the classification performance of your_fancy_algorithm. From the help page you know that the wrapper of choice is algorithm_evaluation(). The required arguments are:

  • code_list: a string "N/A" if not given or a list of two strings - the library and the line of code used for implementing the analysis.
  • input_data: a pd.DataFrame, a dictionary of pd.Series with names, or a string which is either the data URL or the file name.
  • dictionary_results: a dictionary with metrics names as keys.

The wrapper writes information about the data, your results, your Python version, the library version, etc. You can add or correct any information in relevant fields.

from mrap.analytic_instances import algorithm_evaluation
## run your analysis and write the results as a dictionary
results_dict = {"F1": 0.46, "recall": 0.51}
## create your instance with the wrapper
eval_instance = algorithm_evaluation(["the_library", "the_line_of_code"], 
                                   "my_URL", 
                                   results_dict)
## add information about the algorithm and the task                                   
eval_instance.evaluates = "my_fancy_algorithm"
eval_instance.evaluates_for = "Classification"

It is also possible to write the results of a few algorithms evaluated on the same data for the same task.

from mrap.list_algorithm_evaluations import list_algorithm_evaluations
## run your analysis and write a nested dictionary
results_nested = {"ABC": {"F1": 0.46, "recall": 0.64},
             "KLM": {"F1": 0.55, "recall": 0.38},
             "XYZ": {"F1": 0.87, "recall": 0.78}}
## create the list of instances
eval_instance = list_algorithm_evaluations("N/A", "my URL", "Classification", my_results)
## when manually modifying the instance, select an element of the list
eval_instance[2].label = "XYZ evaluation"

You can include the evaluation instance in data analysis instance, convert it into a machine-readable JSON-LD string, and write as a file.

from mrap.analytic_instances import data_analysis
from mrap.to_jsonld import to_jsonld
da_instance = data_analysis(eval_instance)
da_instance.is_implemented_by = "code_URL"
my_json = to_jsonld(da_instance)
with open('data_analysis.json', 'w') as f:
    f.write(my_json)

For more information, please see the help page.

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

mrap-1.0.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

mrap-1.0.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file mrap-1.0.0.tar.gz.

File metadata

  • Download URL: mrap-1.0.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mrap-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1d0989513ba57b8a53b4468817e835db4de322ffe30eb5b88f01998503afc703
MD5 286610f36a09a0cff8b5f04d2dd9fd90
BLAKE2b-256 af85bfddb4df07d19e6e020e9c18275b89d100d0542e24bf88931c625331e69a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrap-1.0.0.tar.gz:

Publisher: publish.yml on OlgaLezhnina/mrap_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mrap-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mrap-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mrap-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77e55a1b00466dc362b78865c2b1afbd08c76cf3bd7546857685cbf2ba695146
MD5 efde09b639113f6174161e83fcec8ac6
BLAKE2b-256 e79bfb4174c027a902fc20b9a5ae37056f4c8583511efe9503575ab20d599c9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrap-1.0.0-py3-none-any.whl:

Publisher: publish.yml on OlgaLezhnina/mrap_py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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