Training View
Experimental
The Workbench View classes are currently in experimental mode so have fun but expect issues and API changes going forward.
TrainingView Class: A View with an additional training column that marks holdout ids
TrainingView
Bases: CreateView
TrainingView Class: A View with an additional training column (80/20 or holdout ids). The TrainingView class creates a SQL view that includes all columns from the source table along with an additional boolean column named "training". This view can also include a SQL filter expression to filter the rows included in the view.
Common Usage
# Create a default TrainingView
fs = FeatureSet("test_features")
training_view = TrainingView.create(fs)
df = training_view.pull_dataframe()
# Create a TrainingView with a specific filter expression
training_view = TrainingView.create(fs, id_column="auto_id", filter_expression="age > 30")
df = training_view.pull_dataframe()
# Query the view
df = training_view.query(f"SELECT * FROM {training_view.table} where training = TRUE")
Source code in src/workbench/core/views/training_view.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
create(feature_set, *, id_column=None, holdout_ids=None, filter_expression=None, source_table=None)
classmethod
Factory method to create and return a TrainingView instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_set
|
FeatureSet
|
A FeatureSet object |
required |
id_column
|
str
|
The name of the id column. Defaults to None. |
None
|
holdout_ids
|
Union[list[str], list[int], None]
|
A list of holdout ids. Defaults to None. |
None
|
filter_expression
|
str
|
SQL filter expression (e.g., "age > 25 AND status = 'active'"). Defaults to None. |
None
|
source_table
|
str
|
The table/view to create the view from. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Union[View, None]
|
Union[View, None]: The created View object (or None if failed to create the view) |
Source code in src/workbench/core/views/training_view.py
create_with_sql(feature_set, *, sql_query, id_column=None)
classmethod
Factory method to create a TrainingView from a custom SQL query.
This method takes a complete SQL query and adds the default 80/20 training split. Use this when you need complex queries like UNION ALL for oversampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feature_set
|
FeatureSet
|
A FeatureSet object |
required |
sql_query
|
str
|
Complete SELECT query (without the final semicolon) |
required |
id_column
|
str
|
The name of the id column for training split. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Union[View, None]
|
Union[View, None]: The created View object (or None if failed) |
Source code in src/workbench/core/views/training_view.py
Questions?

The SuperCowPowers team is happy to answer any questions you may have about AWS and Workbench. Please contact us at workbench@supercowpowers.com or on chat us up on Discord