.. -- mode: rst --
.. _scikit-learn: http://scikit-learn.org/stable/
.. _scikit-learn-contrib: https://github.com/scikit-learn-contrib
|Azure|_ |Codecov|_ |CircleCI|_ |PythonVersion|_ |Pypi|_ |Gitter|_ |Black|_
.. |Azure| image:: https://dev.azure.com/imbalanced-learn/imbalanced-learn/_apis/build/status/scikit-learn-contrib.imbalanced-learn?branchName=master .. _Azure: https://dev.azure.com/imbalanced-learn/imbalanced-learn/_build
.. |Codecov| image:: https://codecov.io/gh/scikit-learn-contrib/imbalanced-learn/branch/master/graph/badge.svg .. _Codecov: https://codecov.io/gh/scikit-learn-contrib/imbalanced-learn
.. |CircleCI| image:: https://circleci.com/gh/scikit-learn-contrib/imbalanced-learn.svg?style=shield .. _CircleCI: https://circleci.com/gh/scikit-learn-contrib/imbalanced-learn/tree/master
.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/imbalanced-learn.svg .. _PythonVersion: https://img.shields.io/pypi/pyversions/imbalanced-learn.svg
.. |Pypi| image:: https://badge.fury.io/py/imbalanced-learn.svg .. _Pypi: https://badge.fury.io/py/imbalanced-learn
.. |Gitter| image:: https://badges.gitter.im/scikit-learn-contrib/imbalanced-learn.svg .. _Gitter: https://gitter.im/scikit-learn-contrib/imbalanced-learn?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg .. _Black: :target: https://github.com/psf/black
.. |PythonMinVersion| replace:: 3.8 .. |NumPyMinVersion| replace:: 1.17.3 .. |SciPyMinVersion| replace:: 1.5.0 .. |ScikitLearnMinVersion| replace:: 1.0.2 .. |MatplotlibMinVersion| replace:: 3.1.2 .. |PandasMinVersion| replace:: 1.0.5 .. |TensorflowMinVersion| replace:: 2.4.3 .. |KerasMinVersion| replace:: 2.4.3 .. |SeabornMinVersion| replace:: 0.9.0 .. |PytestMinVersion| replace:: 5.0.1
imbalanced-learn
imbalanced-learn是一个提供多种重采样技术的Python包,这些技术通常用于处理类别间严重不平衡的数据集。它与scikit-learn_兼容,并且是scikit-learn-contrib_项目的一部分。
文档
安装文档、API文档和示例可以在文档_中找到。
.. _文档: https://imbalanced-learn.org/stable/
安装
依赖
`imbalanced-learn`需要以下依赖项:
- Python (>= |PythonMinVersion|)
- NumPy (>= |NumPyMinVersion|)
- SciPy (>= |SciPyMinVersion|)
- Scikit-learn (>= |ScikitLearnMinVersion|)
此外,`imbalanced-learn`还需要以下可选依赖项:
- Pandas (>= |PandasMinVersion|) 用于处理数据框
- Tensorflow (>= |TensorflowMinVersion|) 用于处理TensorFlow模型
- Keras (>= |KerasMinVersion|) 用于处理Keras模型
示例还需要以下额外依赖项:
- Matplotlib (>= |MatplotlibMinVersion|)
- Seaborn (>= |SeabornMinVersion|)
安装
从PyPi或conda-forge仓库 .....................................
imbalanced-learn目前可在PyPi仓库中获得,你可以通过pip
安装:
pip install -U imbalanced-learn
该包也在Anaconda Cloud平台上发布:
conda install -c conda-forge imbalanced-learn
从GitHub上的源代码 ...............................
如果你更喜欢,你可以克隆它并运行setup.py文件。使用以下命令从Github获取副本并安装所有依赖项:
git clone https://github.com/scikit-learn-contrib/imbalanced-learn.git cd imbalanced-learn pip install .
请注意,你可以以开发者模式安装:
pip install --no-build-isolation --editable .
如果你希望在GitHub上提交拉取请求,我们建议你安装pre-commit:
pip install pre-commit pre-commit install
测试
安装后,你可以使用`pytest`运行测试套件:
make coverage
开发
-----------
这个scikit-learn-contrib的开发与scikit-learn社区的开发方式一致。因此,你可以参考他们的`开发指南<http://scikit-learn.org/stable/developers>`_。
关于
-----
如果你在科学出版物中使用imbalanced-learn,我们将感谢你引用以下论文:
@article{JMLR:v18:16-365,
author = {Guillaume Lema{{\^i}}tre and Fernando Nogueira and Christos K. Aridas},
title = {Imbalanced-learn: A Python Toolbox to Tackle the Curse of Imbalanced Datasets in Machine Learning},
journal = {Journal of Machine Learning Research},
year = {2017},
volume = {18},
number = {17},
pages = {1-5},
url = {http://jmlr.org/papers/v18/16-365}
}
大多数分类算法只有在各个类别的样本数量大致相同时才能达到最佳性能。高度倾斜的数据集,其中少数类别被一个或多个类别严重outnumber,已经被证明是一个挑战,同时这种情况也越来越普遍。
解决这个问题的一种方法是通过重新采样数据集来抵消这种不平衡,希望能得到比原来更稳健和公平的决策边界。
你可以参考`imbalanced-learn`_文档以了解已实现算法的详细信息。
.. _imbalanced-learn: https://imbalanced-learn.org/stable/user_guide.html