# API Documentation

For the full Python API documentation, please go to <https://api-docs.seclea.com>.&#x20;

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:

```python
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:

```python
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:

```python
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:

```python
# 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:

<pre class="language-python"><code class="lang-python">from seclea_ai.transformations import DatasetTransformation 

<strong># Define the updates to the metadata 
</strong>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
                    )
</code></pre>

### Training and Uploading Models

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

```python
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.

\ <br>
