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.1.tar.gz (15.6 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.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mrap-1.0.1.tar.gz
  • Upload date:
  • Size: 15.6 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.1.tar.gz
Algorithm Hash digest
SHA256 f37f73525b255d06a0213315b315a78aca177d74ac004e26f79de14ccf523309
MD5 aed60a03281ecf6f067461b8ca38d1cd
BLAKE2b-256 4f945ae02bd2b938bf8302094eccae5a83f0329e605e9923b972543f8d20310c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrap-1.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: mrap-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f37b14a8c47ff55ae129b816f4fdfbd2886b90980e529bf1abc3000955e9a8e
MD5 3514f43947a8b601a87a2fadf380d470
BLAKE2b-256 f3e4a4fbc222ab1c90630f832bc72998fb89a574ed3a6b425414f52b3c9a4937

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrap-1.0.1-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