Skip to main content
Version: v3.0.0

Modify a schema

Once you have a schema you can adjust it before registering a feature set with it.

Create a new schema by changing the data type of the current schema

from h2o_featurestore.core.data_types import STRING
schema["col"].data_type = STRING
# nested columns
schema["col1"].schema["col2"].data_type = STRING

Create a new schema by column selection

schema.select(features)
schema.exclude(features)

Create a new schema by adding a new feature schema

from h2o_featurestore.core.data_types import STRING
from h2o_featurestore import FeatureSchema
new_feature_schema = FeatureSchema("new_name", STRING)
# Append
schema.append(new_feature_schema) # Append to the end
schema.append(new_feature_schema, schema["old"]) # Append after old
# Prepend
new_schema = schema.prepend(new_feature_schema) # Prepend to the beginning
new_schema = schema.prepend(new_feature_schema, schema["old"]) # Prepend before old

Modify special data on a schema

schema["col1"].special_data.sensitive = True
schema["col2"].special_data.spi = True
# Nested feature modification
schema["col3"].schema["col4"].special_data.pci = True
note

Available special data fields on the Schema object are spi, pci, rpi, demographic and sensitive. These are boolean fields and can be either set with true/false.

Modify feature type

from h2o_featurestore.core.resources.feature import FeatureType
schema["col1"].feature_type = FeatureType.NUMERICAL
schema["col2"].feature_type = FeatureType.AUTOMATIC_DISCOVERY
# Nested feature modification
schema["col3"].schema["col4"].feature_type = FeatureType.TEXT

The AUTOMATIC_DISCOVERY means that the feature type will be determined on the backend side based on the feature data type automatically. AUTOMATIC_DISCOVERY is the default value for all the schema's feature types.

Set feature description

It is also possible to provide a description for a feature schema. This description is propagated to the feature.

schema["col1"].description = "The best feature"

Set feature classifier

Features in a feature set can be tagged by a classifier from a predefined list. The classifier on the feature denotes the type of data stored in the feature.

client.classifiers.list() # this returns all configured classifiers on the backend
schema["col1"].classifiers = {"emailId"}

Feedback