Created
January 31, 2023 08:37
-
-
Save ntankovic/69e899ad14729e95fa7a71f77a96084e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### lib modul | |
FEATURES = {} | |
def feature(name, source): | |
def wrapper(f): | |
FEATURES[name] = { | |
"name": name, | |
"source": source, | |
"fn": f, | |
} | |
return wrapper | |
def build_train_data(features): | |
context = {} | |
data = {f: FEATURES[f]["fn"](context) for f in features} | |
return data | |
### moduli s featurima | |
@feature(name="sales_sum", source="sales") | |
def get_sales_sum(context): | |
# context.sales_source.select("...") | |
return 10 | |
@feature(name="trips_sum", source="sales") | |
def get_trips_sum(context): | |
# context.sales_source.select("...") | |
return 12 | |
### pipeline | |
train_data = build_train_data(["sales_sum", "trips_sum"]) | |
print(train_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment