إنتقل إلى المحتوى الرئيسي

الفصل 2: هندسة الميزات على نطاق واسع

مخازن الميزات​

تقوم مخازن الميزات بمركزية حساب وتقديم الميزات، مما يضمن التناسق بين التدريب والاستدلال.

مثال Feast​

from feast import FeatureStore, Entity, Feature, ValueType, FeatureView
from feast.infra.offline_stores.file_source import FileSource

# Define entity
customer = Entity(
name="customer_id",
value_type=ValueType.STRING,
description="Customer identifier"
)

# Define feature view
customer_features = FeatureView(
name="customer_features",
entities=["customer_id"],
ttl=timedelta(days=1),
features=[
Feature(name="total_purchases", dtype=ValueType.FLOAT),
Feature(name="days_since_last_login", dtype=ValueType.INT64),
Feature(name="account_age_days", dtype=ValueType.INT64),
],
online=True,
source=FileSource(path="data/customer_features.parquet")
)

# Get features for training
store = FeatureStore(repo_path=".")
training_df = store.get_historical_features(
entity_df=entity_df,
features=["customer_features:total_purchases", "customer_features:days_since_last_login"]
).to_df()

# Get features for inference (online)
online_features = store.get_online_features(
features=["customer_features:total_purchases"],
entity_rows=[{"customer_id": "CUS-12345"}]
).to_dict()

الميزات عبر الإنترنت مقابل غير المتصلة​

النوعالغرضزمن الاستجابةالتخزين
غير المتصلةالتدريبدقائقمستودع البيانات
عبر الإنترنتالاستدلالميلي ثانيةRedis, DynamoDB

النقاط الرئيسية​

ملخص
  1. مخازن الميزات تضمن التناسق بين التدريب والتقديم
  2. فصل المخازن عبر الإنترنت/غير المتصلة لتلبية احتياجات زمن الاستجابة المختلفة
  3. إصدار الميزات مثل الكود والبيانات

التالي: الفصل 3: جودة البيانات والتحقق