Skip to content

Commit c3cf3c9

Browse files
sanooktiewgitbook-bot
authored andcommitted
GitBook: [master] 36 pages modified
1 parent a74b87b commit c3cf3c9

1 file changed

Lines changed: 37 additions & 78 deletions

File tree

docs/concepts/feature-tables.md

Lines changed: 37 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
Feature tables are both a schema and a logical means of grouping features, data [sources](sources.md), and other related metadata.
66

7-
Data typically comes in the form of flat files, dataframes, tables in a database, or events on a stream. Thus, the data is presented in multiple columns and/or fields in multiple rows and/or events.
7+
Feature tables serve the following purposes:
88

9-
Feature tables define the unique properties of these data [sources](sources.md), including how Feast interprets and sources them. Feature tables also enable Feast to[ ingest](../user-guide/data-ingestion.md) and [store](../advanced/stores.md) groups of fields from these data sources. Additionally, feature tables introduce efficient storage and logical namespacing to data within [stores](../advanced/stores.md).
9+
* They are a means for defining the location and properties of data [sources](sources.md).
10+
* They are used to create within Feast a database-level structure for the storage of feature values.
11+
* The data sources described within feature tables enable Feast to ingest and store features within Feast.
12+
* They ensure data is efficiently stored during [ingestion](../user-guide/data-ingestion.md).
13+
14+
{% hint style="info" %}
15+
Feast does not yet apply feature transformations. Transformations are currently expected to happen before data is ingested into Feast. The data sources described within feature tables should reference feature values in their already computed form.
16+
{% endhint %}
1017

1118
### Features
1219

13-
A feature is an individual measurable property or characteristic of an observable phenomenon. For example, in a bank a feature could be `total_foreign_transactions_24h` for a specific class of credit cards the bank issues. Feature data is the input both for training models, and for models served in production.
20+
A feature is an individual measurable property or characteristic of an observable phenomenon. For example, in a bank, a feature could be `total_foreign_transactions_24h` for a specific class of credit cards the bank issues. Feature data is the input both for training models, and for models served in production.
1421

1522
{% hint style="info" %}
1623
Features are the most important concepts within a feature store.
@@ -24,32 +31,26 @@ You define a feature by providing a name and value type. In our example, we use
2431
avg_daily_ride = Feature("average_daily_rides", ValueType.FLOAT)
2532
```
2633

27-
Visit [FeatureSpec](https://api.docs.feast.dev/grpc/feast.core.pb.html#FeatureSpecV2) for the complete feature specification API.
34+
Features act purely as a schema within feature tables. Feature tables and features act as normal database tables and columns.
2835

29-
{% hint style="warning" %}
30-
Feature tables are **not** a source for retrieving features. Rather, you can retrieve feature values from feature tables.
31-
{% endhint %}
36+
Visit [FeatureSpec](https://api.docs.feast.dev/grpc/feast.core.pb.html#FeatureSpecV2) for the complete feature specification API.
3237

3338
## Structure of a Feature Table
3439

35-
When you register a feature table, at a minimum specify a batch source to populate the feature table.
36-
37-
If your use case includes a stream source, specify the stream source when you register the feature table. However, because a stream source may not be available in all use cases, Feast does not require specifying one.
40+
Feature tables contain the following fields:
3841

39-
When you create a feature-table specification, include the following fields:
42+
* **Name:** Name of feature table. This name must be unique within a project.
43+
* **Entities:** List of [entities](entities.md) to associate with the features defined in this feature table. Entities are used as lookup keys when retrieving features from a feature table.
44+
* **Features:** List of features within this feature table.
45+
* **Labels:** Labels are arbitrary key-value properties that can be defined by users.
46+
* **Max age:** Max age affect the retrieval of features from a feature table. Age is measured as the duration of time between the event timestamp of a feature and the lookup time on an entity key used to retrieve the feature. Feature values outside max age will be returned as unset values. Max age allows for eviction of keys from online stores and limits the amount of scanning for historical feature values during retrieval.
47+
* **Batch Source:** The batch data source from which you can ingest feature values into Feast. Visit [Sources](sources.md) to learn more about them.
48+
* **Stream Source:** The streaming data source from which you can ingest streaming feature values into Feast. Visit [Sources](sources.md) to learn more about them.
4049

41-
* **name:** Name of feature table. This name must be unique.
42-
* **entities:** List of names of entities to associate with the features defined in this feature table. Visit [Entities](entities.md) to learn more about them.
43-
* **features:** List of feature specifications for each feature defined in this feature table.
44-
* **labels:** User-defined metadata.
45-
* **max\_age:** Max age is measured as the duration of time between the feature's event timestamp and its retrieval. Feature values outside max age will be returned as unset values and indicated to you.
46-
* **batch\_source:** The batch or offline data source from which you create batch source feature data. Visit [Sources](sources.md) to learn more about them.
47-
* **stream\_source:** The stream or online data source from which you create stream or online feature data. See [Sources](sources.md) page for more details.
48-
49-
Here is an example of a valid feature-table specification. In our example, we again use a ride-hailing company:
50+
Here is a ride-hailing example of a valid feature-table specification:
5051

5152
{% tabs %}
52-
{% tab title="driver\_feature\_table.py" %}
53+
{% tab title="driver\_trips\_feature\_table.py" %}
5354
```python
5455
from feast import BigQuerySource, FeatureTable, Feature, ValueType
5556

@@ -78,27 +79,20 @@ driver_ft = FeatureTable(
7879
{% endtab %}
7980
{% endtabs %}
8081

81-
By default, Feast assumes that features specified in the feature-table specification corresponds 1 - 1 to the fields found in the batch source.
82+
When you register a feature table, at a minimum specify a batch source to populate the feature table. Stream sources are optional. They are used to stream feature values into online stores.
8283

83-
However, if the names of the fields in the batch source are different from the names of features, you can use `field_mappings` to ensure the names correspond.
84+
By default, Feast assumes that features specified in the feature-table specification corresponds one-to-one to the fields found in the sources. All features defined in a feature table should be available in the defined sources.
8485

85-
In the example feature-specification table above, we use `field_mappings` to ensure the field named `rating` in the batch source is mapped to the feature named `driver_rating`.
86-
87-
88-
{% hint style="info" %}
89-
When applying a feature table without specifying a project, Feast either creates or updates the feature table in the `default` project.
86+
However, if the names of the fields in the batch source are different from the names of features, you can use `field_mappings` to ensure the names correspond.
9087

91-
To create a feature table for another project, specify the project of choice in the `apply_feature_table` call.
92-
{% endhint %}
88+
In the example feature-specification table above, we use `field_mappings` to ensure the field named `rating` in the batch source is mapped to the feature named `driver_rating`.
9389

9490
## Working with a Feature Table
9591

96-
Feature tables include a rich set of functions.
97-
9892
#### Creating a Feature Table
9993

10094
```python
101-
driver_ft = FeatureTable(..., max_age=14400, ...)
95+
driver_ft = FeatureTable(...)
10296
client.apply_feature_table(driver_ft)
10397
```
10498

@@ -107,21 +101,26 @@ client.apply_feature_table(driver_ft)
107101
Feature table definitions may need to change over time to reflect more accurately your use case. In our ride-hailing example below, we update the max age:
108102

109103
```python
110-
driver_ft = FeatureTable(..., max_age=7200, ...)
104+
driver_ft = FeatureTable()
105+
106+
client.apply_feature_table(driver_ft)
107+
108+
driver_ft.labels = {"team": "marketplace"}
109+
111110
client.apply_feature_table(driver_ft)
112111
```
113112

114-
Feast currently supports the following:
113+
Feast currently supports the following changes to feature tables:
115114

116115
* Adding new features.
117116
* Deleting existing features
118117
* Changing the feature table's source, max age, and labels.
119118

120119
{% hint style="warning" %}
121-
Deleted features are archived, rather than removed completely. Importantly, new features **cannot** use the names of these deleted features.
120+
Deleted features are archived, rather than removed completely. Importantly, new features cannot use the names of these deleted features.
122121
{% endhint %}
123122

124-
Feast currently does **not** support the following:
123+
Feast currently does not support the following changes to feature tables:
125124

126125
* Changes to the project or name of a feature table.
127126
* Changes to entities related to a feature table.
@@ -130,46 +129,6 @@ Feast currently does **not** support the following:
130129
#### Deleting a Feature Table
131130

132131
{% hint style="danger" %}
133-
Feast currently does not support deleting a feature table.
134-
{% endhint %}
135-
136-
#### Updating Features
137-
138-
```python
139-
# Adding a new Feature
140-
driver_ft = FeatureTable(
141-
...,
142-
max_age=7200,
143-
features=[
144-
...,
145-
Feature("new_feature", ValueType.STRING)
146-
]
147-
...
148-
)
149-
client.apply_feature_table(driver_ft)
150-
151-
# Adding a new Feature (using add_feature call)
152-
driver_ft.add_feature(Feature(name="new_feature", dtype=ValueType.STRING))
153-
client.apply_feature_table(driver_ft)
154-
155-
# Removing a Feature (eg. Remove new_feature)
156-
driver_ft = FeatureTable(
157-
...,
158-
max_age=7200,
159-
features=[
160-
...
161-
]
162-
...
163-
)
164-
client.apply_feature_table(driver_ft)
165-
```
166-
167-
{% hint style="info" %}
168-
Quick summary of Feature Tables:
169-
170-
* They are both a schema and a way of grouping features, data [sources](sources.md), and other related metadata.
171-
* They define the unique properties of the data within data [sources](sources.md).
172-
* They enable Feast to[ ingest](../user-guide/data-ingestion.md) and [store](../advanced/stores.md) groups of fields from these data sources
173-
* They ensure data is efficiently stored during [ingestion](../user-guide/data-ingestion.md).
132+
Feast currently does not support the deletion of feature tables.
174133
{% endhint %}
175134

0 commit comments

Comments
 (0)