3. Create a segment

Segment creation requires that you define a set of filters that need to be applied to the existing version schema.
Segments can be active or archived.

  • Active segment - For any new data sent to the platform, metrics will be computed for this segment.
  • Archived segment - The segment is still available for historical analysis, but new data metrics won't be computed for this segment.

Creating segments is an optional step and not mandatory, but it is recommended, as segments can be applied only on data sent after their creation.

πŸ“˜

Segment conditions builder

The possible entetites that can take part of the segment definition are:

  • Any entity under the role of: "Feature", "Prediction probability", "Prediction value" or "Metadata"
  • Categorical entities with more than 250 distinct values cannot be used for a segment filter

Create a segment via the console

1414

Create a segment via SDK

πŸ“˜

install the SDK

To install and get started with our SDK visit our SDK docs

from superwise import Superwise
from superwise.models.segment import Segment
from superwise.models.segment import SegmentCondition
from superwise.models.segment import SegmentConditionDefinition


segment = Segment(
            model_id=diamond_model.id,
            name="top_diamonds",
            definition=[
                SegmentConditionDefinition(
                    entity_name="cut",
                    condition=SegmentCondition.IN,
                    value=["Premium", "Ideal"],
                ),
                SegmentConditionDefinition(
                  entity_name="carat", 
                  condition=SegmentCondition.GREATER_THAN, 
                  value=1
                ),
            ],
        )

segment = sw.segment.create(segment)
print(segment.get_properties())

To read more on the available segment condition operators visit our SDK reference guide