
데이터 스트림에 대한 증분 학습을 위한 Python용 스트리밍 머신러닝 라이브러리로, 온라인 추정기, 드리프트 및 이상 탐지, 파이프라인, 메트릭, 내장 데이터셋을 제공합니다.
River는 온라인 머신러닝을 위한 Python 라이브러리입니다. 스트리밍 데이터로 머신러닝을 수행하는 데 가장 사용자 친화적인 라이브러리가 되는 것을 목표로 합니다. River는 creme과 scikit-multiflow의 합병으로 탄생했습니다.
간단한 예시로, 웹사이트 피싱 데이터셋을 분류하기 위해 로지스틱 회귀를 학습해 보겠습니다. 아래는 데이터셋의 첫 번째 관측값입니다.
>>> from pprint import pprint
>>> from river import datasets
>>> dataset = datasets.Phishing()
>>> for x, y in dataset:
... pprint(x)
... print(y)
... break
{'age_of_domain': 1,
'anchor_from_other_domain': 0.0,
'empty_server_form_handler': 0.0,
'https': 0.0,
'ip_in_url': 1,
'is_popular': 0.5,
'long_url': 1.0,
'popup_window': 0.0,
'request_from_other_domain': 0.0}
True
이제 스트리밍 방식으로 데이터셋에 모델을 실행해 보겠습니다. 예측과 모델 업데이트를 순차적으로 번갈아 수행합니다. 그동안 성능 지표를 업데이트하여 모델이 얼마나 잘 작동하는지 확인합니다.
>>> from river import compose
>>> from river import linear_model
>>> from river import metrics
>>> from river import preprocessing
>>> model = compose.Pipeline(
... preprocessing.StandardScaler(),
... linear_model.LogisticRegression()
... )
>>> metric = metrics.Accuracy()
>>> for x, y in dataset:
... y_pred = model.predict_one(x) # make a prediction
... metric.update(y, y_pred) # update the metric
... model.learn_one(x, y) # make the model learn
>>> metric
Accuracy: 89.28%
물론 이것은 단순히 인위적인 예시일 뿐입니다. 더 자세한 튜토리얼을 원하시면 문서의 소개 섹션을 확인해 보시기 바랍니다.
River는 Python 3.11 이상에서 작동하도록 설계되었습니다. 설치는 pip로 할 수 있습니다:
pip install river
Linux, MacOS, Windows용 휠이 제공됩니다. 즉, 대부분의 경우 River를 소스에서 빌드할 필요가 없습니다.
River의 핵심 온라인 인터페이스(learn_one / predict_one)는 pandas 의존성이 없습니다. 미니 배치 인터페이스(learn_many, predict_many, predict_proba_many, transform_many)는 pandas 기반이며 선택적으로 사용할 수 있습니다:
pip install "river[pandas]"
최신 개발 버전은 GitHub에서 다음과 같이 설치할 수 있습니다:
pip install git+https://github.com/online-ml/river --upgrade
pip install git+ssh://[email protected]/online-ml/river.git --upgrade # using SSH
이 방법을 사용하려면 컴퓨터에 Cython과 Rust가 설치되어 있어야 합니다.
River는 다음 알고리즘 계열의 온라인 구현을 제공합니다:
River는 또한 다른 온라인 유틸리티를 제공합니다:
포괄적인 개요는 API를 확인하세요.
온라인 머신러닝이 필요한지 스스로에게 물어봐야 합니다. 대답은 아마 '아니오'일 것입니다. 대부분의 경우 배치 학습으로 충분합니다. 온라인 접근 방식이 적합한 경우는 다음과 같습니다:
River의 몇 가지 특징은 다음과 같습니다:
어떤 방식으로든 자유롭게 기여해 주세요. 우리는 항상 새로운 아이디어와 접근 방식을 환영합니다.
코드베이스에 수정 사항을 적용하려면 기여 지침을 확인해 주세요.
River가 유용했고 과학 출판물에서 인용하고 싶다면 JMLR에 게재된 논문을 참조해 주세요:
@article{montiel2021river,
title={River: machine learning for streaming data in Python},
author={Montiel, Jacob and Halford, Max and Mastelini, Saulo Martiello
and Bolmier, Geoffrey and Sourty, Raphael and Vaysse, Robin and Zouitine, Adil
and Gomes, Heitor Murilo and Read, Jesse and Abdessalem, Talel and others},
year={2021}
}
River는 3-clause BSD 라이선스에 따라 배포되는 무료 오픈소스 소프트웨어입니다.