@@ -103,8 +103,13 @@ The `get_feature_vector` function retrieves a single feature vector based on the
103
103
=== "Python"
104
104
!!! example "Computing on-demand features while retrieving a feature vector"
105
105
```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
+ )
108
113
```
109
114
110
115
#### Retrieving feature vectors
@@ -114,24 +119,44 @@ The `get_feature_vectors` function retrieves multiple feature vectors using a li
114
119
=== "Python"
115
120
!!! example "Computing on-demand features while retrieving a feature vectors"
116
121
```python
117
-
118
122
# 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
+ )
121
136
122
137
# 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
+ )
124
145
```
125
146
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 ` .
127
150
128
151
=== "Python"
129
152
!!! example "Returning untransformed feature vectors"
130
153
```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
+ )
135
160
```
136
161
137
162
#### Compute all on-demand features
@@ -143,27 +168,51 @@ The `request_parameter` in this case, can be a list of dictionaries that specifi
143
168
=== "Python"
144
169
!!! example "Computing all on-demand features and manually applying model dependent transformations."
145
170
```python
146
-
147
171
# 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
+ )
149
175
150
176
# 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
+ )
153
184
154
185
# Applying model dependent transformations
155
186
encoded_feature_vector = fv.transform(feature_vector_with_on_demand_features)
156
187
157
188
# 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
+ )
159
192
160
193
# 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
+ )
164
207
165
208
# 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
+ )
167
216
168
217
# Applying model dependent transformations
169
218
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
177
226
=== "Python"
178
227
!!! example "Executing each on-demand transformation function"
179
228
```python
180
-
181
229
# 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
+ )
183
233
184
234
# 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
+
186
239
```
0 commit comments