1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6 setuptools,
7 setuptools-scm,
8 joblib,
9 keras,
10 numpy,
11 pandas,
12 scikit-learn,
13 scipy,
14 tensorflow,
15 threadpoolctl,
16 pytestCheckHook,
17 sklearn-compat,
18 python,
19}:
20
21buildPythonPackage rec {
22 pname = "imbalanced-learn";
23 version = "0.13.0";
24 pyproject = true;
25
26 disabled = pythonOlder "3.8";
27
28 src = fetchFromGitHub {
29 owner = "scikit-learn-contrib";
30 repo = "imbalanced-learn";
31 tag = version;
32 hash = "sha256-osmALi5vTV+3kgldY/VhYkNvpXX11KwJ/dIX/5E7Uhc=";
33 };
34
35 build-system = [
36 setuptools
37 setuptools-scm
38 ];
39
40 dependencies = [
41 joblib
42 numpy
43 scikit-learn
44 scipy
45 threadpoolctl
46 sklearn-compat
47 ];
48
49 optional-dependencies = {
50 optional = [
51 keras
52 pandas
53 tensorflow
54 ];
55 };
56
57 pythonImportsCheck = [ "imblearn" ];
58
59 nativeCheckInputs = [
60 pytestCheckHook
61 pandas
62 ];
63
64 preCheck = ''
65 export HOME=$TMPDIR
66 # The GitHub source contains too many files picked up by pytest like
67 # examples and documentation files which can't pass.
68 cd $out/${python.sitePackages}
69 '';
70
71 disabledTestPaths = [
72 # require tensorflow and keras, but we don't want to
73 # add them to nativeCheckInputs just for this tests
74 "imblearn/keras"
75 "imblearn/tensorflow"
76 # even with precheck directory change, pytest still tries to test docstrings
77 "imblearn/tests/test_docstring_parameters.py"
78 # Skip dependencies test - pythonImportsCheck already does this
79 "imblearn/utils/tests/test_min_dependencies.py"
80 ];
81
82 disabledTests = [
83 # Broken upstream test https://github.com/scikit-learn-contrib/imbalanced-learn/issues/1131
84 "test_estimators_compatibility_sklearn"
85 ];
86
87 meta = {
88 description = "Library offering a number of re-sampling techniques commonly used in datasets showing strong between-class imbalance";
89 homepage = "https://github.com/scikit-learn-contrib/imbalanced-learn";
90 changelog = "https://github.com/scikit-learn-contrib/imbalanced-learn/releases/tag/${version}";
91 license = lib.licenses.mit;
92 maintainers = with lib.maintainers; [
93 rmcgibbo
94 philipwilk
95 ];
96 };
97}