tecton.feature_views.OnDemandFeatureView¶
-
class
tecton.feature_views.
OnDemandFeatureView
(*, output_schema, transform, name, description, family, tags, pipeline_function, owner, inputs, user_function)¶ OnDemandFeatureView internal declaration and testing class.
Do not instantiate this class directly. Use
tecton.on_demand_feature_view
instead.Methods
Do not directly use this constructor. Internal constructor for OnDemandFeatureView.
Run the OnDemandFeatureView using mock inputs.
-
__init__
(*, output_schema, transform, name, description, family, tags, pipeline_function, owner, inputs, user_function)¶ Do not directly use this constructor. Internal constructor for OnDemandFeatureView.
- Parameters
output_schema – Spark schema declaring the expected output.
transform – Transformation used to produce the feature values.
name (
str
) – Unique, human friendly name.tags (
Optional
[Dict
[str
,str
]]) – Arbitrary key-value pairs of tagging metadata.pipeline_function – Pipeline definition function.
owner (
Optional
[str
]) – Owner name, used to organize features.inputs – Inputs passed into the pipeline.
user_function – User-defined function.
-
run
(**mock_inputs)¶ Run the OnDemandFeatureView using mock inputs.
- Parameters
mock_inputs (
Union
[Dict
[str
,Any
],DataFrame
,DataFrame
]) – Required. Keyword args with the same expected keys as the OnDemandFeatureView’s inputs parameters. For the “python” mode, each input must be a Dictionary representing a single row. For the “pandas” mode, each input must be a DataFrame with all of them containing the same number of rows and matching row ordering.
Example
@on_demand_feature_view( inputs={'tx_request': Input(transaction_request)}, mode='pandas', output_schema=output_schema ) def transaction_amount_is_high(tx_request: pandas.DataFrame) -> pandas.DataFrame: import pandas as pd df = pd.DataFrame() df['transaction_amount_is_high'] = tx_request['amount'] >= 10000).astype('int64') return df # Test using `run` API. input_df=pd.DataFrame({'amount': [8000, 12000]}) transaction_amount_is_high.run(tx_request=input_df)
- Returns
A Dict object for the “python” mode and a pandas.DataFrame object for the “pandas” mode”.
Attributes
name
Name of this Tecton Object.
-