API Documentation
If you just want to get straight into though, we have the basics here just for you!
To install the
seclea_ai
package, run the following command:pip install seclea_ai
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='')
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)
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
)
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
)
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.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.