Machine-Readable Data Analysis Results with Function Wrappers
Project description
mrap
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f37f73525b255d06a0213315b315a78aca177d74ac004e26f79de14ccf523309
|
|
| MD5 |
aed60a03281ecf6f067461b8ca38d1cd
|
|
| BLAKE2b-256 |
4f945ae02bd2b938bf8302094eccae5a83f0329e605e9923b972543f8d20310c
|
Provenance
The following attestation bundles were made for mrap-1.0.1.tar.gz:
Publisher:
publish.yml on OlgaLezhnina/mrap_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrap-1.0.1.tar.gz -
Subject digest:
f37f73525b255d06a0213315b315a78aca177d74ac004e26f79de14ccf523309 - Sigstore transparency entry: 749129021
- Sigstore integration time:
-
Permalink:
OlgaLezhnina/mrap_py@5084e5f57f0560d44a1622c09bef60998262c9ac -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/OlgaLezhnina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5084e5f57f0560d44a1622c09bef60998262c9ac -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f37b14a8c47ff55ae129b816f4fdfbd2886b90980e529bf1abc3000955e9a8e
|
|
| MD5 |
3514f43947a8b601a87a2fadf380d470
|
|
| BLAKE2b-256 |
f3e4a4fbc222ab1c90630f832bc72998fb89a574ed3a6b425414f52b3c9a4937
|
Provenance
The following attestation bundles were made for mrap-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on OlgaLezhnina/mrap_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mrap-1.0.1-py3-none-any.whl -
Subject digest:
5f37b14a8c47ff55ae129b816f4fdfbd2886b90980e529bf1abc3000955e9a8e - Sigstore transparency entry: 749129030
- Sigstore integration time:
-
Permalink:
OlgaLezhnina/mrap_py@5084e5f57f0560d44a1622c09bef60998262c9ac -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/OlgaLezhnina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5084e5f57f0560d44a1622c09bef60998262c9ac -
Trigger Event:
release
-
Statement type: