forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
65 lines (58 loc) · 1.96 KB
/
Copy pathexample.py
File metadata and controls
65 lines (58 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# # # # # # # # # # # # # # # # # # # # # # # #
# This is an example feature definition file #
# # # # # # # # # # # # # # # # # # # # # # # #
from datetime import timedelta
from pathlib import Path
from feast import Entity, Feature, FeatureView, ValueType
from feast.infra.offline_stores.contrib.spark_offline_store.spark_source import (
SparkSource,
)
# Constants related to the generated data sets
CURRENT_DIR = Path(__file__).parent
# Entity definitions
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id",)
customer = Entity(
name="customer_id", value_type=ValueType.INT64, description="customer id",
)
# Sources
driver_hourly_stats = SparkSource(
name="driver_hourly_stats",
path=f"{CURRENT_DIR}/data/driver_hourly_stats.parquet",
file_format="parquet",
event_timestamp_column="event_timestamp",
created_timestamp_column="created",
)
customer_daily_profile = SparkSource(
name="customer_daily_profile",
path=f"{CURRENT_DIR}/data/customer_daily_profile.parquet",
file_format="parquet",
event_timestamp_column="event_timestamp",
created_timestamp_column="created",
)
# Feature Views
driver_hourly_stats_view = FeatureView(
name="driver_hourly_stats",
entities=["driver_id"],
ttl=timedelta(days=7),
features=[
Feature(name="conv_rate", dtype=ValueType.FLOAT),
Feature(name="acc_rate", dtype=ValueType.FLOAT),
Feature(name="avg_daily_trips", dtype=ValueType.INT64),
],
online=True,
batch_source=driver_hourly_stats,
tags={},
)
customer_daily_profile_view = FeatureView(
name="customer_daily_profile",
entities=["customer_id"],
ttl=timedelta(days=7),
features=[
Feature(name="current_balance", dtype=ValueType.FLOAT),
Feature(name="avg_passenger_count", dtype=ValueType.FLOAT),
Feature(name="lifetime_trip_count", dtype=ValueType.INT64),
],
online=True,
batch_source=customer_daily_profile,
tags={},
)