Transformation Function#
You can create a TransformationFunction via FeatureStore.create_transformation_function and obtain an existing one via FeatureStore.get_transformation_function or FeatureStore.get_transformation_functions.
TransformationFunction #
NOT_FOUND_ERROR_CODE class-attribute instance-attribute #
NOT_FOUND_ERROR_CODE = 270160
DTO class for transformation functions.
| PARAMETER | DESCRIPTION |
|---|---|
featurestore_id |
|
hopsworks_udf |
|
version |
|
id |
|
transformation_type |
|
hopsworks_udf property #
hopsworks_udf: HopsworksUdf
Meta data class for the user defined transformation function.
output_column_names property #
Names of the output columns generated by the transformation functions.
transformation_statistics property writable #
transformation_statistics: TransformationStatistics | None
Feature statistics required for the defined UDF.
transformation_type property writable #
transformation_type: TransformationType
Type of the Transformation: can be model dependent or on-demand.
__call__ #
__call__(*features: list[str]) -> TransformationFunction
Update the feature to be using in the transformation function.
| PARAMETER | DESCRIPTION |
|---|---|
features |
|
| RETURNS | DESCRIPTION |
|---|---|
TransformationFunction |
|
| RAISES | DESCRIPTION |
|---|---|
`hopsworks.client.exceptions.FeatureStoreException` | If the provided number of features do not match the number of arguments in the defined UDF or if the provided feature names are not strings. |
alias #
alias(*args: str)
Set the names of the transformed features output by the transformation function.
delete #
delete() -> None
Delete transformation function from backend.
Example
# import hopsworks udf decorator
from hopworks import udf
# define function
@udf(int)
def plus_one(value):
return value + 1
# create transformation function
plus_one_meta = fs.create_transformation_function(
transformation_function=plus_one,
version=1
)
# persist transformation function in backend
plus_one_meta.save()
# retrieve transformation function
plus_one_fn = fs.get_transformation_function(name="plus_one")
# delete transformation function from backend
plus_one_fn.delete()
from_response_json classmethod #
from_response_json(
json_dict: dict[str, Any],
) -> TransformationFunction | list[TransformationFunction]
Function that constructs the class object from its json serialization.
| PARAMETER | DESCRIPTION |
|---|---|
json_dict |
|
| RETURNS | DESCRIPTION |
|---|---|
TransformationFunction | list[TransformationFunction] |
|
json #
json() -> str
Convert class into its json serialized form.
| RETURNS | DESCRIPTION |
|---|---|
str |
|
save #
save() -> None
Save a transformation function into the backend.
Example
# import hopsworks udf decorator
from hopworks import udf
# define function
@udf(int)
def plus_one(value):
return value + 1
# create transformation function
plus_one_meta = fs.create_transformation_function(
transformation_function=plus_one,
version=1
)
# persist transformation function in backend
plus_one_meta.save()
to_dict #
update_from_response_json #
update_from_response_json(
json_dict: dict[str, Any],
) -> TransformationFunction
Function that updates the class object from its json serialization.
| PARAMETER | DESCRIPTION |
|---|---|
json_dict |
|
| RETURNS | DESCRIPTION |
|---|---|
TransformationFunction |
|