diff --git a/docs/user_guides/fs/feature_group/on_demand_transformations.md b/docs/user_guides/fs/feature_group/on_demand_transformations.md index 81efb413..d961e77a 100644 --- a/docs/user_guides/fs/feature_group/on_demand_transformations.md +++ b/docs/user_guides/fs/feature_group/on_demand_transformations.md @@ -103,8 +103,13 @@ The `get_feature_vector` function retrieves a single feature vector based on the === "Python" !!! example "Computing on-demand features while retrieving a feature vector" ```python - - 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()}) + 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(), + }, + ) ``` #### Retrieving feature vectors @@ -114,24 +119,44 @@ The `get_feature_vectors` function retrieves multiple feature vectors using a li === "Python" !!! example "Computing on-demand features while retrieving a feature vectors" ```python - # Specify unique request parameters for each serving key. - 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()}, - {"transaction_time":datetime(2022, 11, 20, 12, 50, 00), "current_time":datetime.now()}]) + 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(), + }, + { + "transaction_time": datetime(2022, 11, 20, 12, 50, 00), + "current_time": datetime.now(), + }, + ], + ) # Specify common request parameters for all serving key. - 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()}) + 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(), + }, + ) ``` -The `get_feature_vector` and `get_feature_vectors` can also return untransformed features by setting the parameter `transform` to `False`. +#### Retrieving feature vector without on-demand features + +The `get_feature_vector` and `get_feature_vectors` methods can return untransformed feature vectors without on-demand features by disabling model-dependent transformations and excluding on-demand features. To achieve this, set the parameters `transform` and `on_demand_features` to `False`. === "Python" !!! example "Returning untransformed feature vectors" ```python - - untransformed_feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False) - - untransformed_feature_vectors = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], transform=False) + untransformed_feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False, on_demand_features=False + ) + untransformed_feature_vectors = feature_view.get_feature_vectors( + entry=[{"id": 1}, {"id": 2}], transform=False, on_demand_features=False + ) ``` #### Compute all on-demand features @@ -143,27 +168,51 @@ The `request_parameter` in this case, can be a list of dictionaries that specifi === "Python" !!! example "Computing all on-demand features and manually applying model dependent transformations." ```python - # Specify request parameters for each serving key. - untransformed_feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False) + untransformed_feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False, on_demand_features=False + ) # re-compute and add on-demand features to the feature vector - feature_vector_with_on_demand_features = fv.compute_on_demand_features(untransformed_feature_vector, - request_parameter={"transaction_time":datetime(2022, 12, 28, 23, 55, 59), "current_time":datetime.now()}) + feature_vector_with_on_demand_features = fv.compute_on_demand_features( + untransformed_feature_vector, + request_parameter={ + "transaction_time": datetime(2022, 12, 28, 23, 55, 59), + "current_time": datetime.now(), + }, + ) # Applying model dependent transformations encoded_feature_vector = fv.transform(feature_vector_with_on_demand_features) # Specify request parameters for each serving key. - untransformed_feature_vectors = feature_view.get_feature_vectors(entry=[{"id":1}, {"id":2}], transform=False) + untransformed_feature_vectors = feature_view.get_feature_vectors( + entry=[{"id": 1}, {"id": 2}], transform=False, on_demand_features=False + ) # re-compute and add on-demand features to the feature vectors - Specify unique request parameter for each feature vector - 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()}, - {"transaction_time":datetime(2022, 11, 20, 12, 50, 00), "current_time":datetime.now()}]) + 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(), + }, + { + "transaction_time": datetime(2022, 11, 20, 12, 50, 00), + "current_time": datetime.now(), + }, + ], + ) # re-compute and add on-demand feature to the feature vectors - Specify common request parameter for all feature vectors - 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()}) + 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(), + }, + ) # Applying model dependent transformations 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 === "Python" !!! example "Executing each on-demand transformation function" ```python - # Specify request parameters for each serving key. - feature_vector = feature_view.get_feature_vector(entry={"id":1}, transform=False, return_type="pandas") + feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False, on_demand_features=False, return_type="pandas" + ) # Applying model dependent transformations - feature_vector["on_demand_feature1"] = fv.on_demand_transformations["on_demand_feature1"](feature_vector["transaction_time"], datetime.now()) + feature_vector["on_demand_feature1"] = fv.on_demand_transformations[ + "on_demand_feature1" + ](feature_vector["transaction_time"], datetime.now()) + ``` \ No newline at end of file diff --git a/docs/user_guides/fs/feature_view/batch-data.md b/docs/user_guides/fs/feature_view/batch-data.md index 5f1fd9a7..1663da9b 100644 --- a/docs/user_guides/fs/feature_view/batch-data.md +++ b/docs/user_guides/fs/feature_view/batch-data.md @@ -55,6 +55,17 @@ feature_view.init_batch_scoring(training_dataset_version=1) It is important to note that in addition to the filters defined in feature view, [extra filters](./training-data.md#Extra-filters) will be applied if they are defined in the given training dataset version. +## Retrieving untransformed batch data + +By default, the `get_batch_data` function returns batch data with model-dependent transformations applied. However, you can retrieve untransformed batch data—while still including on-demand features—by setting the `transform` parameter to `False`. + +=== "Python" +!!! example "Returning untransformed batch data" + ```python + # Fetching untransformed batch data. + untransformed_batch_data = feature_view.get_batch_data(transform=False) + ``` + ## Passing Context Variables to Transformation Functions After [defining a transformation function using a context variable](../transformation_functions.md#passing-context-variables-to-transformation-function), you can pass the necessary context variables through the `transformation_context` parameter when fetching batch data. diff --git a/docs/user_guides/fs/feature_view/feature-vectors.md b/docs/user_guides/fs/feature_view/feature-vectors.md index ed7f46b1..6af3675c 100644 --- a/docs/user_guides/fs/feature_view/feature-vectors.md +++ b/docs/user_guides/fs/feature_view/feature-vectors.md @@ -191,6 +191,41 @@ You can also use the parameter to provide values for all the features which are ) ``` +## Retrieving untransformed feature vectors + +By default, the `get_feature_vector` and `get_feature_vectors` functions return transformed feature vectors, which has model-dependent transformations applied and includes on-demand features. + +However, you can retrieve the untransformed feature vectors without applying model-dependent transformations while still including on-demand features by setting the `transform` parameter to False. + +=== "Python" +!!! example "Returning untransformed feature vectors" + ```python + # Fetching untransformed feature vector. + untransformed_feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False + ) + + # Fetching untransformed feature vectors. + untransformed_feature_vectors = feature_view.get_feature_vectors( + entry=[{"id": 1}, {"id": 2}], transform=False + ) + ``` + +## Retrieving feature vector without on-demand features + +The `get_feature_vector` and `get_feature_vectors` methods can also return untransformed feature vectors without on-demand features by disabling model-dependent transformations and excluding on-demand features. To achieve this, set the parameters `transform` and `on_demand_features` to `False`. + +=== "Python" +!!! example "Returning untransformed feature vectors" + ```python + untransformed_feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False, on_demand_features=False + ) + untransformed_feature_vectors = feature_view.get_feature_vectors( + entry=[{"id": 1}, {"id": 2}], transform=False, on_demand_features=False + ) + ``` + ## Passing Context Variables to Transformation Functions After [defining a transformation function using a context variable](../transformation_functions.md#passing-context-variables-to-transformation-function), you can pass the required context variables using the `transformation_context` parameter when fetching the feature vectors. diff --git a/docs/user_guides/fs/feature_view/model-dependent-transformations.md b/docs/user_guides/fs/feature_view/model-dependent-transformations.md index 314bd14e..b6657ae5 100644 --- a/docs/user_guides/fs/feature_view/model-dependent-transformations.md +++ b/docs/user_guides/fs/feature_view/model-dependent-transformations.md @@ -123,9 +123,32 @@ Model-dependent transformation functions can also be manually applied to a featu fv.init_serving(training_dataset_version) # Get untransformed feature Vector - feature_vector = fv.get_feature_vector(entry={"index":10}, transformed=False, return_type="pandas") + feature_vector = fv.get_feature_vector(entry={"index":10}, transform=False, return_type="pandas") # Apply Model Dependent transformations - encode_feature_vector = fv.transform(feature_vector) + encoded_feature_vector = fv.transform(feature_vector) ``` +#### Retrieving untransformed feature vector and batch inference data + +The `get_feature_vector`, `get_feature_vectors`, and `get_batch_data` methods can return untransformed feature vectors and batch data without applying model-dependent transformations while still including on-demand features. To achieve this, set the `transform` parameter to False. + +=== "Python" +!!! example "Returning untransformed feature vectors and batch data." + ```python + # Fetching untransformed feature vector. + untransformed_feature_vector = feature_view.get_feature_vector( + entry={"id": 1}, transform=False + ) + + # Fetching untransformed feature vectors. + untransformed_feature_vectors = feature_view.get_feature_vectors( + entry=[{"id": 1}, {"id": 2}], transform=False + ) + + # Fetching untransformed batch data. + untransformed_batch_data = feature_view.get_batch_data( + transform=False + ) + ``` +