# API design for machine learning software: experiences from the scikit-learn project

scikit-learn: 머신러닝 API 설계 경험

Buitinck, Lars, Louppe, Gilles, Blondel, Mathieu, Pedregosa, Fabian, Mueller, Andreas, Grisel, Olivier 외 9명 · arXiv · 2013년 9월 1일

- **연구 문제** 라이브러리에는 학습 알고리즘, 전처리, 모델 선택 도구가 많아서, 사용자가 쉽게 조합하고 개발자가 유지보수할 공통 인터페이스가 필요합니다.
- **연구 방법** 저자들은 모든 객체가 추정기, 예측기, 변환기의 세 인터페이스를 공유하게 합니다. Pipeline과 FeatureUnion으로 이어 한 객체로 묶습니다.
- **주요 결과** 학습과 처리 단위가 같은 단순한 인터페이스를 공유하여, 조합과 재사용에서 얻는 장점을 설명합니다.

## 기계학습 라이브러리에서 API가 어려운 이유

scikit-learn은 Python에서 기계학습 도구를 비전문가도 쓸 수 있고 여러 과학 분야에서 재사용할 수 있도록 설계된 라이브러리입니다. 이 논문이 다루는 문제는 라이브러리 안의 수많은 학습 알고리즘, 전처리, 모델 선택 도구를 어떤 공통 인터페이스로 묶어야 사용자가 쉽게 조합하고 개발자가 유지보수할 수 있는지입니다.

이 논문은 scikit-learn을 기계학습 개념을 Python 객체와 연산으로 옮긴 사례로 보고, 그 API 설계 선택과 이유를 정리합니다. 다만 저자들이 밝히는 범위는 설계 경험과 구현 원칙의 설명이며, 모든 기계학습 라이브러리에 대한 일반 증명은 아닙니다.

## 세 가지 인터페이스와 데이터 표현

scikit-learn의 모든 객체는 추정기, 예측기, 변환기라는 세 가지 상호 보완적 인터페이스를 공유합니다. 추정기는 생성자에서 하이퍼파라미터를 공개 속성으로 저장하고, fit 메서드로 훈련 데이터에서 학습한 파라미터를 속성으로 설정한 뒤 자기 자신을 반환합니다. 생성자는 실제 데이터를 받지 않으며 학습도 하지 않습니다.

예측기는 predict로 새 입력에 대한 예측을 만들고, 변환기는 transform으로 데이터를 바꿉니다. 데이터는 NumPy 배열이나 SciPy 희소 행렬로 표현되어 벡터화 연산을 활용합니다. 배치 단위 처리를 기본으로 하는 이유는 Python 함수 호출과 원소별 타입 검사의 오버헤드를 줄이기 위해서입니다.

## Pipeline과 FeatureUnion을 통한 조합

Pipeline은 여러 추정기를 순차적으로 연결해 하나의 추정기로 만듭니다. 앞의 N−1개 단계는 변환기여야 하며, 마지막 단계는 예측기나 변환기가 될 수 있습니다. 파이프라인을 학습할 때는 첫 단계를 fit하고 훈련 데이터를 변환한 뒤 나머지 단계를 같은 방식으로 학습합니다.

FeatureUnion은 여러 변환기를 병렬로 적용한 뒤 출력을 이어 붙입니다. d개의 입력 특성을 각각 d′, d′′개로 바꾸는 두 변환기의 결합은 d′+d′′개의 특성을 만듭니다. 이 두 구조를 중첩하면 여러 특성 추출과 선택, 분류 단계를 하나의 객체로 묶을 수 있습니다.

## 모델 선택과 하이퍼파라미터 탐색

GridSearchCV와 RandomizedSearchCV는 추정기와 하이퍼파라미터 설정을 받아 교차검증으로 최적 조합을 찾는 메타 추정기입니다. 격자 탐색은 설정의 곱집합을 모두 시도하고, 무작위 탐색은 파라미터 분포에서 고정된 횟수만큼 샘플링합니다.

원문 예제는 SVC에 대해 linear와 rbf 커널을 별도의 격자로 두고, F1 점수를 기준으로 10-fold 교차검증을 수행합니다. 이 예제는 설정을 고르는 절차를 보여 주는 사용 사례이며, 여러 데이터셋이나 과제에서 얻은 성능 결과는 아닙니다.

## 남은 한계와 향후 과제

이 설계는 모든 고전 학습 알고리즘을 포함하지 않습니다. 저자들은 신경망과 bagging 같은 앙상블 메타 추정기, 결측값 보완 알고리즘이 현재 라이브러리에서 지원되지 않는다고 밝힙니다. 구조화 예측과 강화학습은 데이터 표현과 API가 달라 범위 밖으로 둡니다.

직렬화도 과제로 남아 있습니다. pickle은 파일 형식을 제공하지만 버전 간 호환성을 보장하지 않으며, 역직렬화 과정에서 임의의 Python 코드를 실행할 수 있어 신뢰할 수 없는 출처의 모델은 안전하게 열 수 없습니다.

## 논문 정보

- **저자**: Buitinck, Lars, Louppe, Gilles, Blondel, Mathieu, Pedregosa, Fabian, Mueller, Andreas, Grisel, Olivier, Niculae, Vlad, Prettenhofer, Peter, Gramfort, Alexandre, Grobler, Jaques, Layton, Robert, Vanderplas, Jake, Joly, Arnaud, Holt, Brian, Varoquaux, Gaël
- **학회·저널**: arXiv · 프리프린트
- **최초 공개일**: 2013년 9월 1일
- **등록일**: 2026년 11월 12일
- **수정일**: 2013년 9월 1일
- **버전**: v1
- **arXiv**: 1309.0238
- **분류**: cs.LG · cs.MS
- **원문 이용 조건**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **제공 범위**: 논문 정보, 해설

[논문 원문 ↗](https://arxiv.org/abs/1309.0238v1) · [원문 PDF ↗](https://arxiv.org/pdf/1309.0238v1)

AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.

## 원문 인용

Buitinck, Lars, Louppe, Gilles, Blondel, Mathieu, Pedregosa, Fabian, Mueller, Andreas, Grisel, Olivier, Niculae, Vlad, Prettenhofer, Peter, Gramfort, Alexandre, Grobler, Jaques, Layton, Robert, Vanderplas, Jake, Joly, Arnaud, Holt, Brian, Varoquaux, Gaël (2013). API design for machine learning software: experiences from the scikit-learn project. arXiv:1309.0238v1. https://arxiv.org/abs/1309.0238v1

**BibTeX**

```
@misc{lars2013design,
  title = {{API design for machine learning software: experiences from the scikit-learn project}},
  author = {Buitinck, Lars and Louppe, Gilles and Blondel, Mathieu and Pedregosa, Fabian and Mueller, Andreas and Grisel, Olivier and Niculae, Vlad and Prettenhofer, Peter and Gramfort, Alexandre and Grobler, Jaques and Layton, Robert and Vanderplas, Jake and Joly, Arnaud and Holt, Brian and Varoquaux, Gaël},
  year = {2013},
  eprint = {1309.0238},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1309.0238v1}
}
```

## 이 논문의 용어

- [F1 score](https://refivu.com/terms/220c2aa29a7c-f1-score)
- [score function](https://refivu.com/terms/850200f986d6-score-function)
- [leave-one-out](https://refivu.com/terms/54673b642474-leave-one-out)
- [Pipeline](https://refivu.com/terms/4098f540538e-pipeline)
- [scikit-learn](https://refivu.com/terms/ca417a1df302-scikit-learn)
- [GridSearchCV](https://refivu.com/terms/331f7cd2c14c-gridsearchcv)

## 다른 논문 해설

- [Tabular Data: Deep Learning is Not All You Need](https://refivu.com/papers/0cc42765-172d-4179-95b3-7ecf786ac425-tabular-data-deep-learning-is-not-all-you.md)
- [A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification](https://refivu.com/papers/f99c2916-c5f5-45e3-8503-ed9342776182-a-gentle-introduction-to-conformal-prediction-and.md)
- [European Union regulations on algorithmic decision-making and a "right to explanation"](https://refivu.com/papers/8d7d2fe1-f155-44ca-8f0a-551e154b6b3a-european-union-regulations-on-algorithmic-decision-making.md)
- [Robust Physical-World Attacks on Deep Learning Models](https://refivu.com/papers/07947804-f6f2-481e-a0c5-1e222ca2e06f-robust-physical-world-attacks-on-deep-learning-models.md)
- [Invariant Risk Minimization](https://refivu.com/papers/7f6a0d34-8d04-4205-b5c5-1e73e1c91b62-invariant-risk-minimization.md)
- [Equality of Opportunity in Supervised Learning](https://refivu.com/papers/97e846bf-1b27-4e7b-934a-caa8326bd5e9-equality-of-opportunity-in-supervised-learning.md)
- [H-DenseUNet: Hybrid Densely Connected UNet for Liver and Tumor Segmentation from CT Volumes](https://refivu.com/papers/baba5f05-45fc-4d5b-84cb-c78d65c377a5-h-denseunet-hybrid-densely-connected-unet-for-liver.md)
- [Tokens-to-Token ViT: Training Vision Transformers from Scratch on ImageNet](https://refivu.com/papers/55385708-c65a-43d7-b2e0-c4751a8d2757-tokens-to-token-vit-training-vision-transformers-from.md)
- [Recurrent Neural Networks for Multivariate Time Series with Missing Values](https://refivu.com/papers/04779a68-ae30-4f73-bc85-9bae7235eaaf-recurrent-neural-networks-for-multivariate-time-series-with.md)
- [Learning deep representations by mutual information estimation and maximization](https://refivu.com/papers/0ecc4e49-5a6d-49c7-a22d-0464db0ce259-learning-deep-representations-by-mutual-information.md)
- [Swin UNETR: Swin Transformers for Semantic Segmentation of Brain Tumors in MRI Images](https://refivu.com/papers/44c6c3a9-434b-4cb2-aed0-e8b3167653fc-swin-unetr-swin-transformers-for-semantic-segmentation-of.md)
- [Uformer: A General U-Shaped Transformer for Image Restoration](https://refivu.com/papers/f59714df-d19d-41d7-8c41-8c04e0636925-uformer-a-general-u-shaped-transformer-for-image.md)

---

AI 해설에는 오류가 있을 수 있습니다. [Refivu](https://refivu.com/papers/8db0eb21-6067-4eaf-b1d9-2d627cd20b53-api-design-for-machine-learning-software-experiences-from)
