Skip to main content

Start your own Data-provider from simple Python

Project description

DebiAI Data Provider Python module

License

This DebiAI Data Provider Python module allows you to easily deploy your own data-provider through the data-provider API.

A data-provider allows you to provide data to DebiAI so that no duplication of data is needed.

DebiAI Data-providers documentation

Getting started

Installation

Install debiai_data_provider with pip:

pip install debiai_data_provider

Usage example

Find out how to use the DebiAI Data Provider Python module in the examples folder:

Provide project metadata

Create a Python Class representing your project:

from debiai_data_provider import DebiAIProject, DataProvider


class MyProject(DebiAIProject):
    creation_date = "2024-01-01"

    def get_structure(self) -> dict:
        # This function will be called when the user
        # opens the project in the DebiAI interface
        # It serves to classify the project data structure

        return {
            "Data ID": {"type": "text", "category": "id"},
            "My context 1": {"type": "text", "category": "context"},
            "My context 2": {"type": "number", "category": "context"},
            "My groundtruth 1": {"type": "number", "category": "groundtruth"},
        }

    def get_data(self) -> pd.DataFrame:
        # This function will be called when the user
        # wants to analyze data from your project
        samples_df = pd.DataFrame(
            {
                "Data ID": ["image-1", "image-2", "image-3"],
                "My context 1": ["A", "B", "C"],
                "My context 2": [0.28, 0.388, 0.5],
                "My groundtruth 1": [8, 7, 19],
            }
        )

        return samples_df


my_project = MyProject()

Start the server and link your data-provider with DebiAI

Then, create an DataProvider object and add your project to it:

provider = DataProvider()

provider.add_project(my_project)

# Finally, start the server
provider.start_server()

Run the Python file and your project is now available through the DebiAI Data Provider API!

To link your data-provider with DebiAI, you can follow our Creation of a data provider guide

Provide project model results

To provide your model results to DebiAI, add the following method to your project class:

class MyProject(DebiAIProject):

    # Project metadata
    def get_results_structure(self) -> dict:
        # This function will be called when the user
        # opens the project in the DebiAI interface
        # It is required if you plan to analyze model results

        return {
            "prediction": {
                "type": "number",
            },
            "confidence": {
                "type": "number",
            },
            "error": {
                "type": "number",
                "group": "error",
            },
            "error_abs": {
                "type": "number",
                "group": "error",
            },
        }

    # Project model results
    def get_models(self) -> list[dict]:
        # This function will be called when DebiAI
        # ask the user to select a model to analyze the results
        # The function should return the list of models
        # that have been evaluated on the project

        unique_models = MODEL_RESULTS["model"].unique()

        models_data = []
        for model in unique_models:
            nb_results = len(MODEL_RESULTS[MODEL_RESULTS["model"] == model])

            models_data.append(
                {
                    "id": model,
                    "name": model,
                    "nb_results": nb_results,
                }
            )

        return models_data

    def get_model_evaluated_data_id_list(self, model_id: str) -> list[str]:
        # This function will be called when the user
        # wants to analyze the results of a specific model
        # The function should return the list of samples ids
        # that have been evaluated by the model

        unique_models = MODEL_RESULTS["model"].unique()

        if model_id not in unique_models:
            raise ValueError(f"Model {model_id} not found")

        return MODEL_RESULTS[MODEL_RESULTS["model"] == model_id]["sample_id"].tolist()

    def get_model_results(self, model_id: str, samples_ids: list[str]) -> pd.DataFrame:
        # This function will be called when the user
        # wants to analyze the results of a specific model
        # The function should return a pandas DataFrame
        # containing the results of the model corresponding
        # to the samples_ids provided

        # Filter the results
        model_inferences = MODEL_RESULTS[
            (MODEL_RESULTS["model"] == model_id)
            & (MODEL_RESULTS["sample_id"].isin(samples_ids))
        ]

        return model_inferences

Roadmap

  • Publish to Pypi
  • Provide project data
    • Provide project metadata
    • Provide project samples
    • Provide project models & model results
    • Provide project selections
  • Make available project interactions
    • Project deletion
    • Model deletion
    • Selection creation
    • Selection deletion
  • High level data-providers
    • CSV data-provider
    • Json data-provider
  • Start DebiAI along with the data-provider
  • LLM improved data-provider for auto configuration

DebiAI is developed by And is integrated in


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

debiai_data_provider-1.0.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

debiai_data_provider-1.0.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: debiai_data_provider-1.0.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for debiai_data_provider-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eca79f71539f2d29825f081b204cc7eb9613712dfaf176e94add841d4e5807a2
MD5 c6f0c3bf35903479cd7f79ce5095ebea
BLAKE2b-256 f459aa422a2bbb6a5a70953988f7fa29794b034cd461aa29186852f9fb2cbb29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for debiai_data_provider-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b964dcfc2f99feb30ac311ef18799108ed22e3d2b6db515430dbe78f4d4606bd
MD5 cdcbba95b581bd7b718df4fd083bbef5
BLAKE2b-256 d667e3f4b2a0a57d9a31f3225bf276eaff9a54d7503549db097cba4214f948e0

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