Quick Start Guide
Get CloudExplain up and running in minutes. Follow these simple steps to start making your AI models explainable.
- Python 3.11 or higher
- A trained machine learning model (scikit-learn, TensorFlow, PyTorch, XGBoost, etc.)
- An active CloudExplain account and API token
Step 1: Installation
The traditional way to install Python packages
pip install cloudexplain[azure]
The [azure]
extra includes Azure-specific dependencies for cloud integration.
Ultra-fast Python package installer and resolver
uv add cloudexplain[azure]
If you don't have uv installed, you can install it with: pip install uv
Step 2: Get Your API Token
Step 3: Your First Explanation
Here's a complete example showing how to explain any machine learning model
# Import your favorite ML library
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import cloudexplain
# Train your model as usual (example with scikit-learn)
# Load your data
X, y = load_your_data() # Replace with your data loading
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train your model
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
# Define feature descriptions (optional but recommended)
feature_descriptions = {
"feature_1": "Description of what feature 1 represents",
"feature_2": "Description of what feature 2 represents",
# Add descriptions for all your features
}
# Explain your model with CloudExplain
with cloudexplain.azure.explain(
model=model,
X=X_test,
y=y_test,
model_version="1.0.0",
model_name="My Awesome Model",
model_description="A model that predicts something important.",
explanation_name="My Model Explanation 2025-06-14",
explanation_env="prod",
data_source="my dataset",
ml_type="binary_classification", # or "multi_class_classification", "regression"
is_higher_output_better=True,
feature_descriptions=feature_descriptions,
baseline_data=X_train,
api_token="your_api_token_here", # Get this from /dashboards/analytics/tokens
function_url="https://your-env-execute-containers.azurewebsites.net/api/upload_via_token"
) as run:
# Your model is now explained!
print(f"Explanation completed! ID: {run.explanation_id}")
print("View your results in the CloudExplain dashboard")
# The explanation is automatically uploaded to the cloud
# You can access detailed insights in your dashboard
Parameter Reference
model
Your trained ML model (any framework)
X
Input features for explanation
y
Target values (optional for some use cases)
api_token
Your CloudExplain API token
ml_type
Model type: "binary_classification", "multi_class_classification", or "regression"
model_name
Human-readable name for your model
explanation_name
Name for this specific explanation run
feature_descriptions
Dictionary mapping feature names to descriptions