Metadata-Version: 2.4
Name: modern-ml-pipeline
Version: 1.1.24
Summary: A modern, yaml-driven ML pipeline for multiple models.
Project-URL: Homepage, https://github.com/wooshikwon/modern-ml-pipeline
Project-URL: Issues, https://github.com/wooshikwon/modern-ml-pipeline/issues
Project-URL: Repository, https://github.com/wooshikwon/modern-ml-pipeline
Author-email: wooshikwon <wooshikwon@github.com>
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to the Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           Copyright 2025 Wooshik Won
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: <3.14,>=3.10
Requires-Dist: boto3>=1.20.0
Requires-Dist: category-encoders>=2.8.1
Requires-Dist: fastapi
Requires-Dist: google-cloud-bigquery>=3.12.0
Requires-Dist: google-cloud-storage>=2.0.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: jinja2
Requires-Dist: mlflow<4,>=3
Requires-Dist: optuna>=3.0.0
Requires-Dist: packaging>=24.2
Requires-Dist: pandas
Requires-Dist: prometheus-fastapi-instrumentator>=7.0.0
Requires-Dist: psycopg[binary]>=3.2.9
Requires-Dist: pyarrow
Requires-Dist: pydantic>=2.0.0
Requires-Dist: python-dotenv
Requires-Dist: pyyaml
Requires-Dist: redis>=6.2.0
Requires-Dist: rich>=14.0.0
Requires-Dist: rtdl-revisiting-models>=0.0.2
Requires-Dist: scikit-learn
Requires-Dist: scipy>=1.10.0
Requires-Dist: setuptools>=68
Requires-Dist: shap>=0.41.0
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: typer
Requires-Dist: uvicorn[standard]
Requires-Dist: xgboost>=1.7.0
Provides-Extra: all
Requires-Dist: catboost>=1.2.0; extra == 'all'
Requires-Dist: db-dtypes>=1.0.0; extra == 'all'
Requires-Dist: feast>=0.35.0; extra == 'all'
Requires-Dist: fsspec>=2024.0.0; extra == 'all'
Requires-Dist: gcsfs>=2025.5.1; extra == 'all'
Requires-Dist: google-cloud-bigquery-storage>=2.24.0; extra == 'all'
Requires-Dist: lightgbm>=4.1.0; extra == 'all'
Requires-Dist: llvmlite>=0.41.1; extra == 'all'
Requires-Dist: numba>=0.58.1; extra == 'all'
Requires-Dist: s3fs>=2025.5.1; extra == 'all'
Requires-Dist: sqlalchemy-bigquery>=1.9.0; extra == 'all'
Requires-Dist: torch>=2.0.0; extra == 'all'
Provides-Extra: cloud-extras
Requires-Dist: db-dtypes>=1.0.0; extra == 'cloud-extras'
Requires-Dist: fsspec>=2024.0.0; extra == 'cloud-extras'
Requires-Dist: gcsfs>=2025.5.1; extra == 'cloud-extras'
Requires-Dist: google-cloud-bigquery-storage>=2.24.0; extra == 'cloud-extras'
Requires-Dist: s3fs>=2025.5.1; extra == 'cloud-extras'
Requires-Dist: sqlalchemy-bigquery>=1.9.0; extra == 'cloud-extras'
Provides-Extra: dev
Requires-Dist: import-linter>=2.3.0; extra == 'dev'
Requires-Dist: ipykernel>=6.0.0; extra == 'dev'
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: psutil>=5.9.0; extra == 'dev'
Requires-Dist: psycopg2-binary>=2.9.9; extra == 'dev'
Requires-Dist: pytest-cov>=6.2.1; extra == 'dev'
Requires-Dist: pytest-json-report>=1.5.0; extra == 'dev'
Requires-Dist: pytest-timeout>=2.3.1; extra == 'dev'
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.12.0; extra == 'dev'
Provides-Extra: feature-store
Requires-Dist: feast>=0.35.0; extra == 'feature-store'
Provides-Extra: ml-extras
Requires-Dist: catboost>=1.2.0; extra == 'ml-extras'
Requires-Dist: lightgbm>=4.1.0; extra == 'ml-extras'
Requires-Dist: llvmlite>=0.41.1; extra == 'ml-extras'
Requires-Dist: numba>=0.58.1; extra == 'ml-extras'
Provides-Extra: torch-extras
Requires-Dist: torch>=2.0.0; extra == 'torch-extras'
Description-Content-Type: text/markdown

# Modern ML Pipeline

YAML 설정 기반의 머신러닝 파이프라인 CLI 도구입니다.

코드를 수정하지 않고 **YAML 설정 파일**만으로 모델 학습부터 API 서빙까지 처리합니다. 프로젝트 생성(`mmp init`)부터 실험, Docker 이미지 빌드, 컨테이너 레지스트리(GCR/ECR) 푸시까지 일관된 워크플로우를 제공합니다.


## 주요 특징

- **설정 기반 (Config-driven)**: YAML만으로 실험을 정의하고 환경 간 이식 가능
- **단일 이미지 배포**: 학습, 추론, API 서빙을 하나의 Docker 이미지로 지원 (GCR/ECR 푸시까지)
- **클라우드 데이터 연동**: GCS/S3/BigQuery에서 직접 데이터 로드
- **자동 실험 추적**: MLflow와 연동되어 모든 실험 결과와 모델이 자동 저장
- **Data Leakage 방지**: Train/Validation/Test/Calibration 4단계 분할 자동 처리
- **즉시 서빙**: 학습 완료 후 명령어 한 줄로 REST API 서버 기동


## 빠른 시작

### 1. 설치

**요구사항**: Python 3.10, 3.11, 3.12, 또는 3.13

#### 기본 설치

```bash
pip install modern-ml-pipeline        # pip
pipx install modern-ml-pipeline       # pipx (CLI 전역 설치, 권장)
```

#### 시나리오별 추가 설치

기본 설치 후 필요한 extras를 추가합니다:

| 시나리오 | pip | pipx inject |
|----------|-----|-------------|
| BigQuery/GCS/S3 | `pip install 'modern-ml-pipeline[cloud-extras]'` | `pipx inject modern-ml-pipeline 'modern-ml-pipeline[cloud-extras]' --force` |
| LightGBM, CatBoost | `pip install 'modern-ml-pipeline[ml-extras]'` | `pipx inject modern-ml-pipeline 'modern-ml-pipeline[ml-extras]' --force` |
| PyTorch (LSTM 등) | `pip install 'modern-ml-pipeline[torch-extras]'` | `pipx inject modern-ml-pipeline 'modern-ml-pipeline[torch-extras]' --force` |
| 전체 기능 | `pip install 'modern-ml-pipeline[all]'` | `pipx inject modern-ml-pipeline 'modern-ml-pipeline[all]' --force` |

상세 설치 옵션은 [환경 설정 가이드](./docs/user/ENVIRONMENT_SETUP.md)를 참고하세요.


### 2. 프로젝트 생성

```bash
mmp init my-project
cd my-project
```

생성되는 디렉토리 구조:

```text
my-project/
├── configs/             # 환경별 설정 (dev.yaml, prod.yaml)
├── recipes/             # 실험 레시피
├── data/                # 데이터 파일 (CSV, SQL)
├── Dockerfile           # 프로덕션 배포용 (학습/추론/서빙 통합)
├── docker-compose.yml   # 로컬 실행 및 테스트
└── ...
```

> **Tip**: `Dockerfile`과 `docker-compose.yml`이 기본 포함되어, 로컬 개발부터 클라우드 배포까지 동일한 환경에서 실행할 수 있습니다.


### 3. 학습 전 준비

#### 3-1. 데이터 준비

학습 데이터를 `data/` 디렉토리에 CSV 또는 SQL 파일로 준비합니다.

> Task별 데이터 형식은 [Task 가이드](./docs/user/TASK_GUIDE.md)를 참고하세요.

---

#### 3-2. Config 파일 생성 (인프라 설정)

```bash
mmp get-config
```

대화형 인터페이스를 통해 MLflow, 스토리지, DB 연결 등을 설정하고 `configs/{env}.yaml` 파일을 생성합니다.

---

#### 3-3. Recipe 파일 생성 (실험 설정)

```bash
mmp get-recipe
```

Task, 모델, 전처리 등을 선택하고 `recipes/{name}.yaml` 파일을 생성합니다. 생성된 파일에서 **데이터 컬럼 정보만 수정**하면 됩니다:

```yaml
# recipes/my-recipe.yaml
task_choice: classification

data:
  data_interface:
    entity_columns: [user_id]      # [필수] ID 컬럼
    target_column: is_fraud        # [필수] 예측 대상

model:
  class_path: xgboost.XGBClassifier
```

> 상세 옵션은 [Task 가이드](./docs/user/TASK_GUIDE.md), [설정 스키마](./docs/user/SETTINGS_SCHEMA.md)를 참고하세요.

---

#### 3-4. 환경변수 (.env)

`mmp get-config` 실행 시 `.env.{env_name}.template` 파일이 함께 생성됩니다. 이 템플릿을 복사하여 실제 값을 입력합니다:

```bash
# 템플릿 파일을 복사하여 실제 환경변수 파일 생성
cp .env.local.template .env.local

# .env.local 파일 편집하여 값 입력
```

```bash
# .env.local 예시
GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
```

CLI 명령어(`train`, `batch-inference`, `serve-api`)는 Config 파일명에서 환경 이름을 추출하여 대응되는 `.env.{env_name}` 파일을 자동으로 로드합니다:

| Config 파일 | 자동 로드되는 .env 파일 |
|-------------|------------------------|
| `configs/local.yaml` | `.env.local` |
| `configs/dev.yaml` | `.env.dev` |
| `configs/prod.yaml` | `.env.prod` |

> **Note**: 모델 서빙/추론 시 `run_id`는 CLI `--run-id` 인자로 전달합니다. Docker 실행 시에는 `MODEL_RUN_ID` 환경변수를 사용합니다.


### 4. 학습 및 실험

Recipe 파일을 여러 개 만들어 다양한 모델과 하이퍼파라미터를 실험할 수 있습니다. MLflow가 설정되어 있다면 모든 실험 결과가 자동으로 기록되어 `mlflow ui` 명령어로 성능 비교가 가능합니다. 상세 설정은 [MLflow 가이드](./docs/user/MLFLOW_GUIDE.md)를 참고하세요.

#### 로컬 실행

```bash
# CSV 파일로 학습
mmp train -c configs/dev.yaml -r recipes/my-recipe.yaml -d data/train.csv

# SQL 파일로 학습 (BigQuery/PostgreSQL 등)
mmp train -c configs/dev.yaml -r recipes/my-recipe.yaml -d data/query.sql

# SQL에 Jinja 변수 사용 시
mmp train -c configs/dev.yaml -r recipes/my-recipe.yaml -d data/query.sql -p '{"start_date": "2024-01-01", "end_date": "2024-12-31"}'
```

#### Docker 실행

```bash
# 이미지 빌드 (최초 1회)
docker build -t my-model:latest .

# Docker로 학습 실행
docker-compose run --rm train
```

학습 완료 시 출력되는 `run_id`를 추론/서빙에 사용합니다.


### 5. 추론

#### 배치 추론

대량의 데이터를 한 번에 예측합니다.

```bash
mmp batch-inference -c configs/dev.yaml --run-id <run_id> -d data/test.csv

# 결과 파일 경로 직접 지정 (날짜별 디렉토리, CSV/JSON 포맷 지원)
mmp batch-inference --run-id <run_id> -o gs://bucket/2025/01/09/result.parquet
```

#### 실시간 API 서빙

REST API 서버를 기동하여 실시간 예측 요청을 처리합니다.

```bash
# 기본 포트 8000
mmp serve-api -c configs/dev.yaml --run-id <run_id>

# 포트/호스트 지정
mmp serve-api -c configs/dev.yaml --run-id <run_id> --host 0.0.0.0 --port 8080
```

```bash
# API 호출
curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d '{"feature_1": 0.5, "feature_2": 100}'
```

API 엔드포인트 상세는 [API 서빙 가이드](./docs/user/API_SERVING_GUIDE.md)를 참고하세요.


### 6. 배포 및 운영

#### 배포 흐름

```text
mmp init → 실험 → docker build → (( CI/CD로 GCR/ECR 푸시 → k8s에서 실행 ))
```

```bash
# 이미지 빌드 및 푸시 (CI/CD에서 자동화)
docker build -t gcr.io/my-project/mmp:v1 .
docker push gcr.io/my-project/mmp:v1
```

> **MMP의 범위**: 프로젝트 생성 → 실험 → 이미지 빌드
>
> **MMP 범위 외**: CI/CD, k8s 매니페스트, ConfigMap은 각 조직에서 별도 구성

상세 가이드는 [배포 및 운영 가이드](./docs/user/DEPLOYMENT_GUIDE.md)를 참고하세요.


## 지원 Task

| Task | 설명 | 활용 사례 |
|------|------|----------|
| Classification | 범주형 분류 | 사기 탐지, 이탈 예측 |
| Regression | 연속값 예측 | 집값 예측, 매출 예측 |
| Timeseries | 시계열 예측 | 일별 매출, 트래픽 예측 |
| Clustering | 비지도 군집화 | 고객 세분화 |
| Causal | 인과 추론 | 프로모션 효과 분석 |

각 Task별 데이터 형식과 모델 설정은 [Task 가이드](./docs/user/TASK_GUIDE.md)를 참고하세요.


## 지원 모델

| 라이브러리 | 모델 |
|------------|------|
| Scikit-learn | RandomForest, LogisticRegression, KMeans 등 |
| XGBoost | XGBClassifier, XGBRegressor |
| LightGBM | LGBMClassifier, LGBMRegressor |
| CatBoost | CatBoostClassifier, CatBoostRegressor |
| PyTorch | LSTM, TabNet |
| statsmodels | ARIMA, ExponentialSmoothing |
| CausalML | T-Learner, S-Learner |

```bash
mmp list models   # 사용 가능한 모델 목록
mmp list metrics  # 사용 가능한 메트릭 목록
```


## 문서

### 사용자 문서

| 순서 | 문서 | 설명 |
|------|------|------|
| 1 | [환경 설정 가이드](./docs/user/ENVIRONMENT_SETUP.md) | 설치, DB 연결, Cloud 설정 |
| 2 | [Task 가이드](./docs/user/TASK_GUIDE.md) | Task별 데이터 형식, 모델, Recipe 설정 |
| 3 | [설정 스키마](./docs/user/SETTINGS_SCHEMA.md) | Config/Recipe YAML 작성법 |
| 4 | [CLI 레퍼런스](./docs/user/CLI_REFERENCE.md) | 명령어 상세 옵션 |
| 5 | [MLflow 가이드](./docs/user/MLFLOW_GUIDE.md) | 실험 추적, UI 설정 |
| 6 | [API 서빙 가이드](./docs/user/API_SERVING_GUIDE.md) | REST API 서버 사용법 |
| 7 | [배포 및 운영 가이드](./docs/user/DEPLOYMENT_GUIDE.md) | 이미지 빌드, CI/CD, 운영 설정 |
| 8 | [전처리 레퍼런스](./docs/user/PREPROCESSOR_REFERENCE.md) | 전처리 상세 (선택) |
| 9 | [로컬 개발 환경](./docs/user/LOCAL_DEV_ENVIRONMENT.md) | Docker 기반 로컬 개발 (선택) |

### 개발자 문서

시스템 확장이나 기여를 원하시면 [개발자 문서](./docs/developer/)를 참고하세요.


## 도움말

```bash
mmp --help              # 전체 명령어 도움말
mmp train --help        # 특정 명령어 사용법
```

---

**Version**: 1.1.24 | **License**: Apache 2.0 | **Python**: 3.10 - 3.13
