Skip to main content

Library to log your Machine Learning datasets to Refuel Platform

Project description

Refuel Python API

This is the Refuel.ai Python client library. The primary use for this library is to log your machine learning datasets to the Refuel platform. More features coming soon!

Installation

You can install this library using pip:

pip install refuel

Usage

Make sure you have a valid API key from Refuel (shared with your team during onboarding). Contact us at support@refuel.ai if you need help.

Initialization:

Initialize the Refuel client with your API key. This can be done in one of two ways:

import refuel

# Assuming you've set `REFUEL_API_KEY` in your env,
# init() will pick it up automatically
refuel_client = refuel.init()

Alternatively, specify it as an explicit option:

import refuel

options = {
    "api_key": "<YOUR_API_KEY>"
}

refuel_client = refuel.init(**options)

Logging data

Log a single prediction event (no ground truth)

refuel_client.log(
    model_name='my-model-name',
    x={'id': 'id1', 'image_url': 's3://<bucket>/<path>', 'embedding': [0.42, -0.13, ...]},
    y_pred={'scores': {'cat': 0.92, 'dog': 0.08}, 'label': 'cat'},
    metadata={'camera_id': 'camera1'}
)

Log a single prediction event (with ground truth)

refuel_client.log(
    model_name='my-model-name',
    x={'id': 'id2', 'image_url': 's3://<bucket>/<path>', 'embedding': [0.35, -0.27, ...]},
    y_pred={'scores': {'cat': 0.12, 'dog': 0.88}, 'label': 'dog'},
    y_true={'label': 'cat'},
    metadata={'camera_id': 'camera1'}
)

Log a single prediction event (ground truth becomes available at a later point)

# This will be joined with the rest of the event logged previously
refuel_client.log(
    model_name='my-model-name',
    x={'id': 'id1'},
    y_true={'label': 'cat'},
    metadata={'camera_id': 'camera1'}
)

Log a batch of prediction events

# List of events to be logged. 
events = [{'x': ..., 'y': ..., 'y_true': ..., 'metadata': ...}]

refuel_client.log_batch(
    model_name='my-model-name',
    events=events
)

Questions?

Reach out to us at support@refuel.ai with any questions!

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

refuel-0.1.2.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

refuel-0.1.2-py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 3

Supported by

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