Skip to content


Using SDK to create clustering applications

This guide shows you how to create a clustering application on the AI & Analytics Engine.

You can download the dataset used in this example here: insurance-customers-segmentation.csv.

from aiaengine import Org
from aiaengine import FileSource, Column, SemanticType
from aiaengine import ClusteringConfig, Clusterers, HyperparameterTuningMethod
from aiaengine import get_all_clustering_results

# create a new demo project in the org
org = Org(id='b6240512-cd17-43a0-8297-84c51c1bc5a0') # replace with your org ID
project = org.create_project(name="Demo project using Python SDK", description="Your demo project")
# or you can get an existing project that you want to work on
# project = Project(id='ID_of_your_project') # replace with your own project ID

# import the dataset
dataset = project.create_dataset(
    name='Insurance customers',
            Column("Customer", SemanticType.Text),
            Column("State", SemanticType.Text),
            Column("Response", SemanticType.Text),
            Column("Coverage", SemanticType.Text),
            Column("Education", SemanticType.Text),
            Column("Effective To Date", SemanticType.DateTime),
            Column("EmploymentStatus", SemanticType.Text),
            Column("Gender", SemanticType.Text),
            Column("Income", SemanticType.Numeric),
            Column("Location Code", SemanticType.Text),
            Column("Marital Status", SemanticType.Text),
            Column("Monthly Premium Auto", SemanticType.Numeric),
            Column("Months Since Last Claim", SemanticType.Numeric),
            Column("Months Since Policy Inception", SemanticType.Numeric),
            Column("Number of Open Complaints", SemanticType.Numeric),
            Column("Number of Policies", SemanticType.Numeric),
            Column("Policy Type", SemanticType.Text),
            Column("Policy", SemanticType.Text),
            Column("Renew Offer Type", SemanticType.Text),
            Column("Sales Channel", SemanticType.Text),
            Column("Total Claim Amount", SemanticType.Numeric),
            Column("Vehicle Class", SemanticType.Text),
            Column("Vehicle Size", SemanticType.Text)

# create a clustering application
app = project.create_app(
    name='Insurance Customer Segmentation - Clustering',,
            'selected_features': [
                "Location Code",
                "Marital Status",
                "Monthly Premium Auto",
                "Months Since Last Claim",
                "Months Since Policy Inception",
                "Number of Open Complaints",
                "Number of Policies",
                "Policy Type",
                "Renew Offer Type",
                "Sales Channel",
                "Total Claim Amount",
                "Vehicle Class",
                "Vehicle Size",
                'name': 'GMM',
                'template_id': Clusterers.GMM,
                    'hyperparameter_tuning_method': HyperparameterTuningMethod.GRID_SEARCH,
                    'hyperparameter_tuning_config': None,
                    'hyperparameters': {
                        'k': {
                            'max_num_clusters': 5,
                            'min_num_clusters': 2

                'name': 'UMAP_HDBSCAN',
                'template_id': Clusterers.UMAP_HDBSCAN,
                'training_config': {
                    'hyperparameter_tuning_method': None,
                    'hyperparameter_tuning_config': None,
                    'hyperparameters': {},

# get the clustering results
clustering_results = get_all_clustering_results(app)
Coming soon