Skip to content

Commit 7afa987

Browse files
adchiagitbook-bot
authored andcommitted
GitBook: [master] 3 pages modified
1 parent 7d177b6 commit 7afa987

3 files changed

Lines changed: 86 additions & 2 deletions

File tree

docs/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
* [Feature repository](reference/feature-repository/README.md)
7070
* [feature\_store.yaml](reference/feature-repository/feature-store-yaml.md)
7171
* [.feastignore](reference/feature-repository/feast-ignore.md)
72-
* [Feature Server](reference/feature-server.md)
72+
* [\[Alpha\] On demand feature view](reference/alpha-on-demand-feature-view.md)
73+
* [\[Alpha\] Feature server](reference/feature-server.md)
7374
* [Feast CLI reference](reference/feast-cli-commands.md)
7475
* [Python API reference](http://rtd.feast.dev/)
7576
* [Usage](reference/usage.md)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# \[Alpha\] On demand feature view
2+
3+
**Warning**: This is an _experimental_ feature. It's intended for early testing and feedback, and could change without warnings in future releases.
4+
5+
{% hint style="info" %}
6+
To enable this feature, run **`feast alpha enable enable_on_demand_transforms`**
7+
{% endhint %}
8+
9+
## Overview
10+
11+
On demand feature views allows users to use existing features and request time data \(features only available at request time\) to transform and create new features. Users define python transformation logic which is executed in both historical retrieval and online retrieval paths.
12+
13+
Currently, these transformations are executed locally. Future milestones include building a Feature Transformation Server for executing transformations at higher scale.
14+
15+
## CLI
16+
17+
There are new CLI commands:
18+
19+
* `feast on-demand-feature-views list` lists all registered on demand feature view after `feast apply` is run
20+
* `feast on-demand-feature-views describe [NAME]` describes the definition of an on demand feature view
21+
22+
## Example
23+
24+
See [https://github.com/feast-dev/on-demand-feature-views-demo](https://github.com/feast-dev/on-demand-feature-views-demo) for an example on how to use on demand feature views.
25+
26+
### **Registering transformations**
27+
28+
We register `RequestDataSource` inputs and the transform in `on_demand_feature_view`:
29+
30+
```python
31+
# Define a request data source which encodes features / information only
32+
# available at request time (e.g. part of the user initiated HTTP request)
33+
input_request = RequestDataSource(
34+
name="vals_to_add",
35+
schema={
36+
"val_to_add": ValueType.INT64,
37+
"val_to_add_2": ValueType.INT64
38+
}
39+
)
40+
41+
# Use the input data and feature view features to create new features
42+
@on_demand_feature_view(
43+
inputs={
44+
'driver_hourly_stats': driver_hourly_stats_view,
45+
'vals_to_add': input_request
46+
},
47+
features=[
48+
Feature(name='conv_rate_plus_val1', dtype=ValueType.DOUBLE),
49+
Feature(name='conv_rate_plus_val2', dtype=ValueType.DOUBLE)
50+
]
51+
)
52+
def transformed_conv_rate(features_df: pd.DataFrame) -> pd.DataFrame:
53+
df = pd.DataFrame()
54+
df['conv_rate_plus_val1'] = (features_df['conv_rate'] + features_df['val_to_add'])
55+
df['conv_rate_plus_val2'] = (features_df['conv_rate'] + features_df['val_to_add_2'])
56+
return df
57+
```
58+
59+
### **Feature retrieval**
60+
61+
{% hint style="info" %}
62+
The on demand feature view's name is the function name \(i.e. `transformed_conv_rate`\).
63+
{% endhint %}
64+
65+
And then to retrieve historical or online features, we can call this in a feature service or reference individual features:
66+
67+
```python
68+
training_df = store.get_historical_features(
69+
entity_df=entity_df,
70+
features=[
71+
"driver_hourly_stats:conv_rate",
72+
"driver_hourly_stats:acc_rate",
73+
"driver_hourly_stats:avg_daily_trips",
74+
"transformed_conv_rate:conv_rate_plus_val1",
75+
"transformed_conv_rate:conv_rate_plus_val2",
76+
],
77+
).to_df()
78+
```
79+

docs/reference/feature-server.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Feature Server
1+
# \[Alpha\] Feature server
22

33
**Warning**: This is an _experimental_ feature. It's intended for early testing and feedback, and could change without warnings in future releases.
44

5+
{% hint style="info" %}
6+
To enable this feature, run **`feast alpha enable python_feature_server`**
7+
{% endhint %}
8+
59
## Overview
610

711
Feature Server is an HTTP endpoint that serves features with JSON I/O. This enables users to get features from Feast using any programming language that can make HTTP requests. As of now, it's only possible to run the server locally. A remote feature server is work in progress.

0 commit comments

Comments
 (0)