Skip to content

Feature Set

This section shows how to create, modify and list feature sets in AI & Analytics Engine using the Python SDK

Creating a feature set

You can add a new feature set by specifying the required parameter values as follows.

from aiaengine import App

# get the application
app_id = ''
app = App(id=app_id)

# create a new feature set in the app
feature_set = app.create_feature_set(
    name=f"German Credit Risk Prediction Task",
    feature_names=('Bedroom', 'Bathroom', 'Garage', 'Land'),
    description='Numeric features'
)
package com.aiaengine.examples.featureset;

import com.aiaengine.App;
import com.aiaengine.Engine;
import com.aiaengine.FeatureSet;
import com.aiaengine.app.request.CreateFeatureSetRequest;

import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.HashSet;

public class CreateFeatureSetApp {
    public static void main(String[] args) throws FileNotFoundException {
        Engine engine = new Engine();
        App app = engine.getApp("50bd7f31-51a2-42c0-9112-85f8e6e23ccc");
        FeatureSet featureSet = app.createFeatureSet(CreateFeatureSetRequest.builder()
                .name("Demo feature set")
                .featureNames(new HashSet<>(Arrays.asList("Culmen Length (mm)")))
                .build());

        System.out.println(featureSet.getFeatureNames());
    }
}

Retrieving information of a feature set

You can get information about a feature set by providing the feature set ID.

from aiaengine import FeatureSet

feature_set_id = '' # set your own app ID
feature_set = FeatureSet(id=feature_set_id)
feature_set
package com.aiaengine.examples.featureset;

import com.aiaengine.Engine;
import com.aiaengine.FeatureSet;

import java.io.FileNotFoundException;

public class GetFeatureSetApp {
    public static void main(String[] args) throws FileNotFoundException {
        Engine engine = new Engine();
        FeatureSet featureSet = engine.getFeatureSet("ca1256ff-1714-4d52-a985-d2e62846efb8");
        System.out.println(featureSet.getFeatureNames());
    }
}

Updating a feature set

You can modify the name and description of an existing feature set.

from aiaengine import FeatureSet

feature_set_id = '' # set your own app ID
feature_set = FeatureSet(id=feature_set_id)
feature_set.update(name='Updated App', description='This app has been updated')
package com.aiaengine.examples.featureset;

import com.aiaengine.Engine;
import com.aiaengine.FeatureSet;
import com.aiaengine.featureset.request.UpdateFeatureSetRequest;

import java.io.FileNotFoundException;

public class UpdateFeatureSetApp {
    public static void main(String[] args) throws FileNotFoundException {
        Engine engine = new Engine();
        FeatureSet featureSet = engine.getFeatureSet("f55717be-14dd-40ea-8cad-f71370d5b961");
        featureSet.update(UpdateFeatureSetRequest.builder()
                .name("Updated name")
                .description("This feature set has been updated")
                .build());
    }
}

Listing feature sets in an app

You can list all the feature sets within an app using the following code:

from aiaengine import App

app_id = ''
app = App(id=app_id)

feature_sets = app.list_feature_sets()
feature_sets
package com.aiaengine.examples.featureset;

import com.aiaengine.App;
import com.aiaengine.Engine;
import com.aiaengine.FeatureSet;

import java.io.FileNotFoundException;
import java.util.List;

public class ListFeatureSetsApp {
    public static void main(String[] args) throws FileNotFoundException {
        Engine engine = new Engine();
        App app = engine.getApp("50bd7f31-51a2-42c0-9112-85f8e6e23ccc");
        List<FeatureSet> featureSets = app.listFeatureSets();
        featureSets.forEach(featureSet -> System.out.println(featureSet.getFeatureNames()));
    }
}

Deleting a feature set

You can also remove a feature set which is no longer needed using the delete() method

from aiaengine import FeatureSet

feature_set_id = '' # set your own app ID
feature_set = FeatureSet(id=feature_set_id)
feature_set.delete()
package com.aiaengine.examples.featureset;

import com.aiaengine.Engine;
import com.aiaengine.FeatureSet;

import java.io.FileNotFoundException;

public class DeleteFeatureSetApp {
    public static void main(String[] args) throws FileNotFoundException {
        Engine engine = new Engine();
        FeatureSet featureSet = engine.getFeatureSet("f55717be-14dd-40ea-8cad-f71370d5b961");
        featureSet.delete();
    }
}