Seclea User Documentation
HomeAI RegulationsAI Risk ManagementGet started
  • Seclea User Documentation
  • Introducing Seclea
    • Seclea - Building trust in AI
      • Seclea - Features and services
      • Seclea integrations and supported frameworks
  • Getting Started
    • Create a Seclea account
    • First Project - Example
    • Cloud Platform
    • On-Premises Deployment
  • Seclea Web UI
    • Overview
    • Basic Workflows
    • Creating a Project
    • Project Settings
      • User Access Setting
      • Compliance Settings
      • Risk Management Settings
      • Performance (Internal Policies) Setting
    • User Management
    • AI regulatory compliance
      • Seclea Compliance Dashboard
      • Working with templates for compliance
    • AI risk management
      • Seclea AI Risk Management Dashboard
      • Working with templates for risk management
  • Python API (seclea-ai)
    • Overview
    • API Documentation
  • Supported AI regulations
    • EC Artificial Intelligence Act
    • FDA SaMD with Artificial Intelligence
    • OECD AI Principles
    • Canada Artificial Intelligence and Data Act (AIDA)
    • South Korean - AI-based Medical Devices (SK-AIMD)
    • Saudi Arabia - AI-based Medical Devices (SA-AIMD)
  • Supported risk management frameworks
    • NIST AI risk management
    • ISO AI risk management
    • FDA AI based SaMD Risk Management
  • Seclea INFO
    • Reporting Bugs
    • Error Catalog
Powered by GitBook
On this page
  • Installation
  • Initialisation
  • Uploading Datasets
  • Applying Dataset Transformations
  • Training and Uploading Models
  • Conclusion
  1. Python API (seclea-ai)

API Documentation

PreviousOverviewNextEC Artificial Intelligence Act

Last updated 2 years ago

For the full Python API documentation, please go to .

If you just want to get straight into though, we have the basics here just for you!

Installation

To install the seclea_ai package, run the following command:

pip install seclea_ai

Initialisation

To use the seclea_ai API, first import the SecleaAI class and create an instance with your project and organisation details:

from seclea_ai import SecleaAI 

# NOTE - use the organisation name provided to you from which you received credentials. 
seclea = SecleaAI(project_name="Your AI Project Name", organization='')

Uploading Datasets

To upload a dataset to the Seclea Platform, use the upload_dataset() method, providing the dataset, dataset name, and metadata:

import pandas as pd 

# Load the data 
data = pd.read_csv('your_data.csv', index_col="index_column") 

# Define the metadata for the dataset. 
dataset_metadata = { 
# ... 
} 

seclea.upload_dataset(dataset=data, dataset_name="Your Dataset Name", metadata=dataset_metadata)

Uploading Datasets - as separate samples and labels

To upload dataset that is split into samples and labels, use the upload_dataset_split() method:

# Upload the train and test dataset splits
seclea.upload_dataset_split(
    X=X_train, 
    y=y_train, dataset_name="Your Dataset Name - Train", 
    metadata={}, 
    transformations=train_transformations
    ) 

Applying Dataset Transformations

To apply and record dataset transformations, use the DatasetTransformation class from the seclea_ai.transformations module:

from seclea_ai.transformations import DatasetTransformation 

# Define the updates to the metadata 
processed_metadata = { 
# ... 
} 

# Define the transformations to the dataset 
processing_transformations = [ 
    DatasetTransformation(
        # Define the dataset transformations
        ) 
] 

# Upload the processed datasets
seclea.upload_dataset(dataset=processed_data, 
                    dataset_name="Your Processed Dataset Name", 
                    metadata=processed_metadata, 
                    transformations=processing_transformations
                    )

Training and Uploading Models

To upload a model using the seclea_ai API, follow these steps:

from sklearn.model_selection import cross_val_score 
from sklearn.ensemble import RandomForestClassifier 

# Initialize a classifier 
classifier = RandomForestClassifier() 

# Cross-validate the classifier 
training_score = cross_val_score(classifier, X_train, y_train, cv=5) 

# Train the classifier on the full training set 
classifier.fit(X_train, y_train) 

# Upload the fully trained model
seclea.upload_training_run_split(model=classifier, 
                                X_train=X_train, 
                                y_train=y_train, 
                                X_test=X_test, 
                                y_test=y_test)

Note that this uses the upload_training_run_split function that takes datasets as samples and labels. If you prefer to reference a dataset that isn't split in this way you can use the upload_training_run function instead.

Conclusion

By following the steps outlined in this documentation, you can efficiently integrate the seclea_ai API into your AI project, enabling seamless data and model management, as well as regulatory compliance and risk management through the Seclea Platform.

https://api-docs.seclea.com