Skip to main content

REsults MAde easY in pythoN

Project description

REMAYN: REsults MAde easY in pythoN

remayn is an open-source Python toolkit focused on results management for machine learning experiments. It includes the required functionalities to save the complete results of an experiment, load them, and generate repots.

Overview
CI/CD !codecov !docs
Code !python !black Linter: Ruff

Getting started

⚙️ Installation

remayn v0.1.0 is the last version supported by Python >=3.8.

The easiest way to install remayn is via pip, from this main branch of this GitHub repository:

pip install git+https://github.com/ayrna/remayn.git@main

💾 Saving the results of a experiment

A new Result object can be created using the make_result function. Then, the Result can be saved to disk by simply calling the save() method.

import numpy as np
from remayn.result import make_result

targets = np.array([1, 2, 3])
predictions = np.array([1.1, 2.2, 3.3])
config = {"model": "linear_regression", "dataset": "iris", "learning_rate": 1e-3}

result = make_result("./results",
                    config=config,
                    targets=targets,
                    predictions=predictions
                    )
result.save()

This will generate an unique identifier for this Result and it will be saved in a subdirectory of the ./results directory.

⌛ Loading a set of results

After saving the results of all the experiments, the set of results can be loaded using the ResultFolder class, as shown in the following snippet:

from remayn.result_set import ResultFolder

rs = ResultFolder('./results')

Note that the same path used to save the results is employed here to load the ResultFolder. The ResultFolder object is a special type of ResultSet and represents a set of results which have been loaded from disk.

📝 Creating a pandas DataFrame that contains all the results

After loading the results, the create_dataframe method of the ResultSet class can be used to generate a pandas.DataFrame containing all the results. This method receives a callable which is used to compute the metrics from the targets and predictions stored in each Result. Therefore, first we can define a function that computes the metrics:

def mse(y_true, y_pred):
    return ((y_true - y_pred)**2).mean()

def _compute_metrics(targets, predictions):
    return {
        "mse": mse(targets, predictions),
    }

Then, the create_dataframe method of the ResultSet is used:

from remayn.result_set import ResultFolder

rs = ResultFolder('./results')
df = rs.create_dataframe(
    config_columns=[
        "model",
        "dataset",
        "learning_rate",
    ],
    metrics_fn=_compute_metrics,
)

Finally, the DataFrame can be saved to a file by using the existing pandas methods:

df.to_excel('results.xlsx', index=False)

This will generate an Excel file that contains the column given in the config_columns parameter along with the columns associated with the metrics computed in the function provided.

Collaborating

Code contributions to the remayn project are welcomed via pull requests. Please, contact the maintainers (maybe opening an issue) before doing any work to make sure that your contributions align with the project.

Guidelines for code contributions

  • You can clone the repository and then install the library from the local repository folder:
git clone git@github.com:ayrna/remayn.git
pip install ./remayn
  • In order to set up the environment for development, install the project in editable mode and include the optional dev requirements:
pip install -e '.[dev]'
  • Install the pre-commit hooks before starting to make any modifications:
pre-commit install
  • Write code that is compatible with all supported versions of Python listed in the pyproject.toml file.
  • Create tests that cover the common cases and the corner cases of the code.
  • Preserve backwards-compatibility whenever possible, and make clear if something must change.
  • Document any portions of the code that might be less clear to others, especially to new developers.
  • Write API documentation as docstrings.

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

remayn-1.0.2.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

remayn-1.0.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file remayn-1.0.2.tar.gz.

File metadata

  • Download URL: remayn-1.0.2.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for remayn-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f02e03414649b2ab8c88818ee16797f9976023be77fbf2642099f3f628e20e1e
MD5 cbb2b9daacc66b970ecd03c83c770335
BLAKE2b-256 08566e3ae826337b7bae9dc988d1c6790ba5fc75e072650e5f6e7367c67e7b8d

See more details on using hashes here.

File details

Details for the file remayn-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: remayn-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for remayn-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 496300d462db8850c8b8dcfdd8457254b420ed26727c20951b0ec1484b40273a
MD5 16198949d81ee45b7f6ac9d63d5308c5
BLAKE2b-256 96c1112427faace9961cb9b62785d715195bfebdeddeab3c87861bf36cb24c1d

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