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.
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.
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.
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:
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
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();
}
}