Community研究&データ分析github.com

特徴量パイプラインの構築

ML特徴量パイプラインと特徴量ストアを構築 — ラベルリークを防ぐポイントインタイム正しい結合、オフライン/オンラインのパリティ、特徴量の鮮度とバックフィル、Feast等のツールによるマテリアライゼーション。MLの特徴量エンジニアリング、トレイン/サーブスキューやデータリークの防止、特徴量ストアの構築、トレーニング用の履歴特徴量のバックフィルに使用。

特徴量パイプラインの構築 とは?

このスキルは、MLモデルのための特徴量パイプラインを構築する際のベストプラクティスを提供します。主な目的は、ラベルリークの防止、オフライン(トレーニング)とオンライン(推論)のパリティ維持、特徴量の鮮度管理、そして再現可能なバックフィルを実現することです。ポイントインタイム結合により、モデルが過去のデータのみを使って学習することを保証し、トレイン/サーブスキューを防ぐために単一の特徴量定義を共有します。このスキルは、Feastなどの特徴量ストアと連携し、SQLや定義ファイルを用いた具体的な実装パターンを示しています。主なプラットフォームは、SQLをサポートするデータウェアハウスや特徴量ストアツールであり、AIエージェントはこのスキルを実行することで、プロダクション品質の特徴量パイプラインを設計・実装できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Unknown-333/awesome-data-engineering-skills/tree/main/skills/building-feature-pipelines

Installed? Explore more 研究&データ分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

特徴量パイプラインの構築 は何をしますか?

使用すべき場面

  • ウェアハウス/ストリームデータからMLモデル用の特徴量をエンジニアリングする場合。
  • ラベルリークやトレイン/サーブスキューを防ぐ場合。
  • 特徴量ストア、オンライン推論、または履歴バックフィルを設定する場合。
  • 一般的なモデリング/集約(dbt/Sparkのスキルを使用)には使用しないこと。ただし、ML特徴量にフィードする場合は除く。

ワークフロー

- [ ] 各特徴量をエンティティキーとイベントタイムスタンプで定義する
- [ ] ポイントインタイム正しい結合(ラベル時刻時点)でトレーニングセットを構築する
- [ ] オフライン(トレーニング)とオンライン(推論)で1つの定義を共有する
- [ ] オンライン特徴量の鮮度/マテリアライゼーションを設定する
- [ ] トレーニング用に履歴特徴量を冪等にバックフィルする
  1. ポイントインタイムの正確性。 各ラベルのタイムスタンプ時点で特徴量を結合する — 予測時刻より前に分かっていたデータのみを使用する。これにより、最も有害な特徴量バグであるラベルリークを防ぐ。
  2. オフライン/オンラインのパリティ。 トレーニング(オフライン、バッチ)と推論(オンライン、低レイテンシ)で同じ方法で特徴量を計算する。ロジックが異なるとトレイン/サーブスキューが発生し、プロダクションで静かに劣化する。
  3. 鮮度。 オンライン特徴量は、モデルの許容する古さに合わせたスケジュールでマテリアライズする必要がある。
  4. 冪等なバックフィル。 履歴特徴量の再計算は繰り返し可能でなければならない(designing-backfills-and-replays を参照)。

パターン

ポイントインタイム(時点)結合 — 各ラベルイベントの厳密に前の最新特徴量値を選択する:

SELECT l.entity_id, l.label_ts, f.value AS feature
FROM labels l
LEFT JOIN features f
  ON f.entity_id = l.entity_id
 AND f.event_ts <= l.label_ts          -- 過去のデータのみ;リークなし
QUALIFY ROW_NUMBER() OVER (
  PARTITION BY l.entity_id, l.label_ts ORDER BY f.event_ts DESC) = 1;

単一の定義、2つのパス — 特徴量を一度定義し(例:Feast FeatureView)、トレーニング用にオフラインストアへ、推論用にオンラインストアへマテリアライズする。これにより、両方で同一のロジックが使用される。

鮮度とマテリアライゼーション — オンラインマテリアライゼーションをスケジュールする;特徴量の鮮度を他のデータセットSLAと同様に監視する(implementing-pipeline-observability を参照)。

よくある落とし穴

  • ラベルリーク — ラベル時刻より後に計算された特徴量を結合すると、オフラインメトリクスが水増しされ、プロダクションで劣化する;常に時点結合を行う。
  • トレイン/サーブスキュー — オフラインとオンラインの実装が分離するとドリフトする;1つの定義を共有する。
  • 古いオンライン特徴量 — モデルが古い値で推論する;鮮度を設定し監視する。
  • 再現不可能なバックフィル — 一貫性のないトレーニング履歴;特徴量の再計算を冪等にする。
  • エンティティ/タイムスタンプキーの欠落 — 特徴量を時間をまたいで正しく結合できない;両方を必須にする。
  • バージョン管理されていない特徴量 — 静かな再定義がモデルの比較可能性を損なう;特徴量定義をバージョン管理する。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

Unknown-333/authoring-airflow-dags

Write production-grade Apache Airflow DAGs using the TaskFlow API — idempotent tasks, correct scheduling and catchup, retries/SLAs, connections/variables, and avoiding top-level code. Use when creating or reviewing Airflow DAGs, scheduling pipelines, wiring task dependencies, configuring retries/backfills, or fixing non-idempotent tasks.

Unknown-333/building-dagster-assets

Build Dagster pipelines using software-defined assets — asset dependencies, partitions, resources and IO managers, asset checks, and schedules/sensors. Use when creating Dagster assets or jobs, modeling data as assets, adding partitions or backfills, wiring resources/IO managers, or migrating from task-based orchestration to assets.

Unknown-333/building-dbt-models

Build well-structured dbt models — staging/intermediate/marts layers, ref() and source(), materializations, and incremental models with the right strategy. Use when creating or refactoring dbt models, choosing table vs view vs incremental, structuring a dbt project, or writing incremental logic.

Unknown-333/building-iceberg-tables

Design and operate Apache Iceberg tables — partitioning and hidden partitioning, partition/schema evolution, snapshots and time travel, compaction and small-file cleanup, and MERGE/upsert for lakehouse tables on Spark, Flink, Trino, or Snowflake. Use when creating or maintaining Iceberg tables, choosing partitioning, evolving schema/partitions, or fixing small-file and metadata bloat.

Unknown-333/building-ingestion-pipelines

Build batch and incremental data ingestion (extract-load) pipelines — full vs incremental extraction, change data capture (CDC), watermarks and high-water marks, API pagination and rate limits, and choosing managed EL tools (Fivetran, Airbyte) vs custom code. Use when ingesting data from databases, APIs, files, or SaaS into a warehouse/lake, or designing incremental extraction and CDC.

Unknown-333/building-kafka-consumers

Build reliable Apache Kafka consumers and producers — consumer groups and partition assignment, offset commit strategy, at-least-once vs exactly-once, idempotent/transactional producers, rebalancing, and dead-letter handling. Use when writing Kafka consumers/producers, configuring offset commits or consumer groups, tuning throughput, or handling rebalances and poison messages.

Unknown-333/debugging-data-pipelines

Systematically root-cause data pipeline failures and data incidents — job errors, wrong or missing data, duplicates, and freshness misses — by tracing lineage upstream, isolating the failing stage, reconciling against source, and planning a safe fix and backfill. Use when a pipeline fails, numbers look wrong, data is missing or duplicated, a dashboard is stale, or a stakeholder reports a data discrepancy.

Unknown-333/designing-backfills-and-replays

Plan and run safe data backfills and replays — idempotent reprocessing of historical windows, partition-by-partition execution, isolating backfill compute from production, verifying results, and avoiding double-counting or changed history. Use when backfilling a new or fixed model, reprocessing after a bug, replaying events, or loading history for a new pipeline without corrupting existing data.

Unknown-333/designing-data-contracts

Define and enforce data contracts between producers and consumers — explicit schema, semantics, ownership, SLAs, and versioning — to prevent silent upstream changes from breaking downstream pipelines. Use when a producer schema change could break consumers, defining an interface between teams/services and the warehouse, or adding schema enforcement at ingestion.

関連スキル