프로덕션 ML 시스템: 데이터를 변환해야 하는 경우
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
원시 데이터는 특성 추출 (변환)되어야 합니다. 언제 데이터를 변환해야 하나요? 대략적으로 다음 두 기간 중 하나에 기능 설계를 실행할 수 있습니다.
이 접근 방식에서는 다음 두 단계를 따릅니다.
- 코드를 작성하거나 특수 도구(예: Flume 또는 F1)를 사용하여
원시 데이터를 변환합니다.
- 변환된 데이터를 모델이 처리할 수 있는 위치(예: 디스크)에 저장합니다.
장점
- 시스템은 원시 데이터를 한 번만 변환합니다.
- 시스템은 전체 데이터 세트를 분석하여 최적의 변환 전략을 결정할 수 있습니다.
단점
- 예측 시점에 변환을 다시 만들어야 합니다. 학습-제공 편향에 주의하세요.
학습-게재 편향은 시스템이 동적(온라인) 추론을 실행할 때 더 위험합니다.
동적 추론을 사용하는 시스템에서는 원시 데이터 세트를 변환하는 소프트웨어가 일반적으로 예측을 제공하는 소프트웨어와 다르므로 학습-제공 편향이 발생할 수 있습니다.
반면 정적 (오프라인) 추론을 사용하는 시스템은 동일한 소프트웨어를 사용할 수 있습니다.
이 접근 방식에서는 변환이 모델 코드의 일부입니다. 모델은 원시 데이터를 처리하고 변환합니다.
장점
- 변환을 변경해도 동일한 원시 데이터 파일을 계속 사용할 수 있습니다.
- 학습과 예측 시 동일한 변환이 보장됩니다.
단점
- 복잡한 변환은 모델 지연 시간을 늘릴 수 있습니다.
- 변환은 모든 배치에 대해 발생합니다.
일괄적으로 데이터를 변환하는 것은 쉽지 않을 수 있습니다. 예를 들어 Z-점수 정규화를 사용하여 원시 숫자 데이터를 변환하려고 한다고 가정해 보겠습니다. Z-점수 정규화에는 특성의 평균 및 표준 편차가 필요합니다.
그러나 일괄 변환의 경우 전체 데이터 세트가 아닌 데이터 일괄 처리 하나에만 액세스할 수 있습니다. 따라서 배치가 매우 다양한 경우 한 배치의 Z 점수(예: -2.5)가 다른 배치의 -2.5와 동일한 의미를 갖지 않습니다.
해결 방법으로 시스템은 전체 데이터 세트에서 평균과 표준 편차를 미리 계산한 후 모델에서 상수로 사용할 수 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[[["\u003cp\u003eFeature engineering can be performed before or during model training, each with its own advantages and disadvantages.\u003c/p\u003e\n"],["\u003cp\u003eTransforming data before training allows for a one-time transformation of the entire dataset but requires careful recreation of transformations during prediction to avoid training-serving skew.\u003c/p\u003e\n"],["\u003cp\u003eTransforming data during training ensures consistency between training and prediction but can increase model latency and complicate batch processing.\u003c/p\u003e\n"],["\u003cp\u003eWhen transforming data during training, considerations such as Z-score normalization across batches with varying distributions need to be addressed.\u003c/p\u003e\n"]]],[],null,["# Production ML systems: When to transform data?\n\nRaw data must be feature engineered (transformed). When should you transform\ndata? Broadly speaking, you can perform feature engineering during either of\nthe following two periods:\n\n- *Before* training the model.\n- *While* training the model.\n\nTransforming data before training\n---------------------------------\n\nIn this approach, you follow two steps:\n\n1. Write code or use specialized tools to transform the raw data.\n2. Store the transformed data somewhere that the model can ingest, such as on disk.\n\nAdvantages\n\n- The system transforms raw data only once.\n- The system can analyze the entire dataset to determine the best transformation strategy.\n\nDisadvantages\n\n- You must recreate the transformations at prediction time. Beware of [**training-serving skew**](/machine-learning/glossary#training-serving-skew)!\n\nTraining-serving skew is more dangerous when your system performs dynamic\n(online) inference.\nOn a system that uses dynamic inference, the software that transforms\nthe raw dataset usually differs from the software that serves predictions,\nwhich can cause training-serving skew.\nIn contrast, systems that use static (offline) inference can sometimes\nuse the same software.\n\nTransforming data while training\n--------------------------------\n\nIn this approach, the transformation is part of the model code. The model\ningests raw data and transforms it.\n\nAdvantages\n\n- You can still use the same raw data files if you change the transformations.\n- You're ensured the same transformations at training and prediction time.\n\nDisadvantages\n\n- Complicated transforms can increase model latency.\n- Transformations occur for each and every batch.\n\nTransforming the data per batch can be tricky. For example, suppose you want to\nuse [**Z-score normalization**](/machine-learning/glossary#z-score-normalization)\nto transform raw numerical data. Z-score normalization requires the mean and\nstandard deviation of the feature.\nHowever, transformations per batch mean you'll only have access to\n*one batch of data*, not the full dataset. So, if the batches are highly\nvariant, a Z-score of, say, -2.5 in one batch won't have the same meaning\nas -2.5 in another batch.\nAs a workaround, your system can precompute the mean and standard deviation\nacross the entire dataset and then use them as constants in the model.\n| **Key terms:**\n|\n| - [Training-serving skew](/machine-learning/glossary#training-serving-skew)\n- [Z-score normalization](/machine-learning/glossary#z-score-normalization) \n[Help Center](https://support.google.com/machinelearningeducation)"]]