Skip to content

Commit d29fbc8

Browse files
committed
reformatting code with black and correcting snippets
1 parent 98b71c9 commit d29fbc8

File tree

2 files changed

+78
-25
lines changed

2 files changed

+78
-25
lines changed

docs/user_guides/fs/feature_group/on_demand_transformations.md

+76-23
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ The `get_feature_vector` function retrieves a single feature vector based on the
103103
=== "Python"
104104
!!! example "Computing on-demand features while retrieving a feature vector"
105105
```python
106-
107-
feature_vector = feature_view.get_feature_vector(entry={"id":1}, request_parameter={"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()})
106+
feature_vector = feature_view.get_feature_vector(
107+
entry={"id": 1},
108+
request_parameter={
109+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
110+
"current_time": datetime.now(),
111+
},
112+
)
108113
```
109114

110115
#### Retrieving feature vectors
@@ -114,24 +119,44 @@ The `get_feature_vectors` function retrieves multiple feature vectors using a li
114119
=== "Python"
115120
!!! example "Computing on-demand features while retrieving a feature vectors"
116121
```python
117-
118122
# Specify unique request parameters for each serving key.
119-
feature_vector = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], request_parameter=[{"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()},
120-
{"transaction_time":datetime(2022, 11, 20, 12, 50, 00), "current_time":datetime.now()}])
123+
feature_vector = feature_view.get_feature_vectors(
124+
entry=[{"id": 1}, {"id": 2}],
125+
request_parameter=[
126+
{
127+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
128+
"current_time": datetime.now(),
129+
},
130+
{
131+
"transaction_time": datetime(2022, 11, 20, 12, 50, 00),
132+
"current_time": datetime.now(),
133+
},
134+
],
135+
)
121136

122137
# Specify common request parameters for all serving key.
123-
feature_vector = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], request_parameter={"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()})
138+
feature_vector = feature_view.get_feature_vectors(
139+
entry=[{"id": 1}, {"id": 2}],
140+
request_parameter={
141+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
142+
"current_time": datetime.now(),
143+
},
144+
)
124145
```
125146

126-
The `get_feature_vector` and `get_feature_vectors` can also return untransformed features by setting the parameter `transform` to `False`.
147+
#### Retrieving untransformed feature vector
148+
149+
The `get_feature_vector` and `get_feature_vectors` can also return untransformed features vector without applying model-dependent transformations that contains on-demand features by setting the parameter `transform` to `False`.
127150

128151
=== "Python"
129152
!!! example "Returning untransformed feature vectors"
130153
```python
131-
132-
untransformed_feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False)
133-
134-
untransformed_feature_vectors = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], transform=False)
154+
untransformed_feature_vector = feature_view.get_feature_vector(
155+
entry={"id": 1}, transform=False
156+
)
157+
untransformed_feature_vectors = feature_view.get_feature_vectors(
158+
entry=[{"id": 1}, {"id": 2}], transform=False
159+
)
135160
```
136161

137162
#### Compute all on-demand features
@@ -143,27 +168,51 @@ The `request_parameter` in this case, can be a list of dictionaries that specifi
143168
=== "Python"
144169
!!! example "Computing all on-demand features and manually applying model dependent transformations."
145170
```python
146-
147171
# Specify request parameters for each serving key.
148-
untransformed_feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False)
172+
untransformed_feature_vector = feature_view.get_feature_vector(
173+
entry={"id": 1}, transform=False
174+
)
149175

150176
# re-compute and add on-demand features to the feature vector
151-
feature_vector_with_on_demand_features = fv.compute_on_demand_features(untransformed_feature_vector,
152-
request_parameter={"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()})
177+
feature_vector_with_on_demand_features = fv.compute_on_demand_features(
178+
untransformed_feature_vector,
179+
request_parameter={
180+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
181+
"current_time": datetime.now(),
182+
},
183+
)
153184

154185
# Applying model dependent transformations
155186
encoded_feature_vector = fv.transform(feature_vector_with_on_demand_features)
156187

157188
# Specify request parameters for each serving key.
158-
untransformed_feature_vectors = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], transform=False)
189+
untransformed_feature_vectors = feature_view.get_feature_vectors(
190+
entry=[{"id": 1}, {"id": 2}], transform=False
191+
)
159192

160193
# re-compute and add on-demand features to the feature vectors - Specify unique request parameter for each feature vector
161-
feature_vectors_with_on_demand_features = fv.compute_on_demand_features(untransformed_feature_vectors,
162-
request_parameter=[{"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()},
163-
{"transaction_time":datetime(2022, 11, 20, 12, 50, 00), "current_time":datetime.now()}])
194+
feature_vectors_with_on_demand_features = fv.compute_on_demand_features(
195+
untransformed_feature_vectors,
196+
request_parameter=[
197+
{
198+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
199+
"current_time": datetime.now(),
200+
},
201+
{
202+
"transaction_time": datetime(2022, 11, 20, 12, 50, 00),
203+
"current_time": datetime.now(),
204+
},
205+
],
206+
)
164207

165208
# re-compute and add on-demand feature to the feature vectors - Specify common request parameter for all feature vectors
166-
feature_vectors_with_on_demand_features = fv.compute_on_demand_features(untransformed_feature_vectors, request_parameter={"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()})
209+
feature_vectors_with_on_demand_features = fv.compute_on_demand_features(
210+
untransformed_feature_vectors,
211+
request_parameter={
212+
"transaction_time": datetime(2022, 12, 28, 23, 55, 59),
213+
"current_time": datetime.now(),
214+
},
215+
)
167216

168217
# Applying model dependent transformations
169218
encoded_feature_vector = fv.transform(feature_vectors_with_on_demand_features)
@@ -177,10 +226,14 @@ On-demand transformation functions can also be accessed and executed as normal f
177226
=== "Python"
178227
!!! example "Executing each on-demand transformation function"
179228
```python
180-
181229
# Specify request parameters for each serving key.
182-
feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False, return_type="pandas")
230+
feature_vector = feature_view.get_feature_vector(
231+
entry={"id": 1}, transform=False, return_type="pandas"
232+
)
183233

184234
# Applying model dependent transformations
185-
feature_vector["on_demand_feature1"] = fv.on_demand_transformations["on_demand_feature1"](feature_vector["transaction_time"], datetime.now())
235+
feature_vector["on_demand_feature1"] = fv.on_demand_transformations[
236+
"on_demand_feature1"
237+
](feature_vector["transaction_time"], datetime.now())
238+
186239
```

docs/user_guides/fs/feature_view/model-dependent-transformations.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ Model-dependent transformation functions can also be manually applied to a featu
123123
fv.init_serving(training_dataset_version)
124124

125125
# Get untransformed feature Vector
126-
feature_vector = fv.get_feature_vector(entry={"index":10}, transformed=False, return_type="pandas")
126+
feature_vector = fv.get_feature_vector(entry={"index":10}, transform=False, return_type="pandas")
127127

128128
# Apply Model Dependent transformations
129-
encode_feature_vector = fv.transform(feature_vector)
129+
encoded_feature_vector = fv.transform(feature_vector)
130130
```
131131

0 commit comments

Comments
 (0)