repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_tomek_links.py | """Test the module Tomek's links."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.utils._testing import assert_array_equal
from imblearn.under_sampling import TomekLinks
... | 2,698 | 28.988889 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_random_under_sampler.py | """Test the module random under sampler."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
from datetime import datetime
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.utils._testing impor... | 4,992 | 29.260606 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_allknn.py | """Test the module repeated edited nearest neighbour."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.neighbors import NearestNeighbors
from sklearn.utils._testing import a... | 8,773 | 23.50838 | 70 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_condensed_nearest_neighbour.py | """Test the module condensed nearest neighbour."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.neighbors import KNeighborsClassifier
from sklearn.utils._testing import ass... | 4,227 | 31.523077 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_one_sided_selection.py | """Test the module one-sided selection."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.neighbors import KNeighborsClassifier
from sklearn.utils._testing import assert_arra... | 4,185 | 31.2 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_neighbourhood_cleaning_rule.py | """Test the module neighbourhood cleaning rule."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.utils._testing import assert_array_equal
f... | 2,574 | 29.294118 | 86 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_generation/__init__.py | """
The :mod:`imblearn.under_sampling.prototype_generation` submodule contains
methods that generate new samples in order to balance the dataset.
"""
from ._cluster_centroids import ClusterCentroids
__all__ = ["ClusterCentroids"]
| 232 | 24.888889 | 74 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_generation/_cluster_centroids.py | """Class to perform under-sampling by generating centroids based on
clustering."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Fernando Nogueira
# Christos Aridas
# License: MIT
import numpy as np
from scipy import sparse
from sklearn.base import clone
from sklearn.cluster import KMeans... | 7,528 | 35.548544 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_generation/tests/test_cluster_centroids.py | """Test the module cluster centroids."""
from collections import Counter
import numpy as np
import pytest
from scipy import sparse
from sklearn.cluster import KMeans
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from imblearn.under_sampling import ClusterCentroid... | 5,289 | 31.256098 | 85 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/under_sampling/_prototype_generation/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/_smote_enn.py | """Class to perform over-sampling using SMOTE and cleaning using ENN."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numbers
from sklearn.base import clone
from sklearn.utils import check_X_y
from ..base import BaseSampler
from ..over_sampling import SMOTE... | 5,090 | 30.425926 | 79 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/_smote_tomek.py | """Class to perform over-sampling using SMOTE and cleaning using Tomek
links."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numbers
from sklearn.base import clone
from sklearn.utils import check_X_y
from ..base import BaseSampler
from ..over_sampling impo... | 4,948 | 30.125786 | 81 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/__init__.py | """The :mod:`imblearn.combine` provides methods which combine
over-sampling and under-sampling.
"""
from ._smote_enn import SMOTEENN
from ._smote_tomek import SMOTETomek
__all__ = ["SMOTEENN", "SMOTETomek"]
| 209 | 22.333333 | 61 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/tests/test_smote_enn.py | """Test the module SMOTE ENN."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.combine import SMOTEENN
from imblearn.over_sampling import SMOTE
from imblearn.under... | 4,800 | 29.386076 | 80 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/combine/tests/test_smote_tomek.py | """Test the module SMOTE ENN."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.combine import SMOTETomek
from imblearn.over_sampling import SMOTE
from imblearn.und... | 5,576 | 32.196429 | 82 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/pairwise.py | """Metrics to perform pairwise computation."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import numbers
import numpy as np
from scipy.spatial import distance_matrix
from sklearn.base import BaseEstimator
from sklearn.utils import check_consistent_length
from sklearn.utils.multiclass impor... | 8,670 | 35.897872 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/_classification.py | # coding: utf-8
"""Metrics to assess performance on a classification task given class
predictions. The available metrics are complementary from the metrics available
in scikit-learn.
Functions named as ``*_score`` return a scalar value to maximize: the higher
the better
Function named as ``*_error`` or ``*_loss`` ret... | 39,954 | 34.017528 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/__init__.py | """
The :mod:`imblearn.metrics` module includes score functions, performance
metrics and pairwise metrics and distance computations.
"""
from ._classification import (
classification_report_imbalanced,
geometric_mean_score,
macro_averaged_mean_absolute_error,
make_index_balanced_accuracy,
sensitivi... | 642 | 24.72 | 72 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/tests/test_classification.py | # coding: utf-8
"""Testing the metric for classification with imbalanced dataset"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from functools import partial
import numpy as np
import pytest
from sklearn import datasets, svm
from sklearn.metrics import (
accura... | 17,909 | 31.32852 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/tests/test_score_objects.py | """Test for score"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import pytest
from sklearn.datasets import make_blobs
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import make_scorer
from sklearn.model_selection import GridSearchCV, train... | 2,091 | 25.481013 | 70 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/metrics/tests/test_pairwise.py | """Test for the metrics that perform pairwise distance computation."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import numpy as np
import pytest
from sklearn.exceptions import NotFittedError
from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
from sklearn.utils._testing import ... | 6,395 | 35.971098 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/_imbalance.py | """Transform a dataset into an imbalanced dataset."""
# Authors: Dayvid Oliveira
# Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
from collections.abc import Mapping
from ..under_sampling import RandomUnderSampler
from ..utils import che... | 4,120 | 33.923729 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/_zenodo.py | """Collection of imbalanced datasets.
This collection of datasets has been proposed in [1]_. The
characteristics of the available datasets are presented in the table
below.
ID Name Repository & Target Ratio #S #F
1 ecoli UCI, target: imU 8.6:1 336 7
2 ... | 12,971 | 42.384615 | 79 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/__init__.py | """
The :mod:`imblearn.datasets` provides methods to generate
imbalanced data.
"""
from ._imbalance import make_imbalance
from ._zenodo import fetch_datasets
__all__ = ["make_imbalance", "fetch_datasets"]
| 207 | 19.8 | 57 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/tests/test_imbalance.py | """Test the module easy ensemble."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
import numpy as np
import pytest
from sklearn.datasets import load_iris
from imblearn.datasets import make_imbalance
@pytest.fixture
def iris():
... | 2,518 | 30.098765 | 79 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/tests/test_zenodo.py | """Test the datasets loader.
Skipped if datasets is not already downloaded to data_home.
"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import pytest
from sklearn.utils._testing import SkipTest
from imblearn.datasets import fetch_datasets
DATASET_SHAPE = {
"... | 2,773 | 27.020202 | 82 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/datasets/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_pipeline.py | """
Test the pipeline module.
"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import itertools
import re
import shutil
import time
from tempfile import mkdtemp
import numpy as np
import pytest
import sklearn
from joblib import Memory
from pytest import raises
from ... | 44,011 | 31.290536 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_common.py | """Common tests"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import warnings
from collections import OrderedDict
import numpy as np
import pytest
from sklearn.base import clone
from sklearn.exceptions import ConvergenceWarning
from sklearn.utils._testing import S... | 3,795 | 33.198198 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_docstring_parameters.py | # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Raghav RV <rvraghav93@gmail.com>
# License: BSD 3 clause
import importlib
import inspect
import warnings
from inspect import signature
from pkgutil import walk_packages
import pytest
from sklearn.datasets import make_classification
from sklearn.li... | 8,863 | 32.703422 | 86 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_public_functions.py | """This is a copy of sklearn/tests/test_public_functions.py. It can be
removed when we support scikit-learn >= 1.2.
"""
from importlib import import_module
from inspect import signature
import pytest
from imblearn.utils._param_validation import (
generate_invalid_param_val,
generate_valid_param,
make_cons... | 4,038 | 37.103774 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_base.py | """Test for miscellaneous samplers objects."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import numpy as np
import pytest
from scipy import sparse
from sklearn.datasets import load_iris, make_regression
from sklearn.linear_model import LinearRegression
from sklearn.utils import _safe_index... | 3,407 | 30.850467 | 83 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tests/test_exceptions.py | """Test for the exceptions modules"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from pytest import raises
from imblearn.exceptions import raise_isinstance_error
def test_raise_isinstance_error():
var = 10.0
with raises(ValueError, match="has to be one o... | 375 | 24.066667 | 54 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/base.py | """
Base class for the over-sampling method.
"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numbers
from collections.abc import Mapping
from ..base import BaseSampler
from ..utils._param_validation import Interval, StrOptions
class BaseOverSampler(BaseSam... | 2,519 | 35 | 102 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_random_over_sampler.py | """Class to perform random over-sampling."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections.abc import Mapping
from numbers import Real
import numpy as np
from scipy import sparse
from sklearn.utils import _safe_indexing, check_array, check_random_s... | 9,552 | 35.601533 | 86 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/__init__.py | """
The :mod:`imblearn.over_sampling` provides a set of method to
perform over-sampling.
"""
from ._adasyn import ADASYN
from ._random_over_sampler import RandomOverSampler
from ._smote import SMOTE, SMOTEN, SMOTENC, SVMSMOTE, BorderlineSMOTE, KMeansSMOTE
__all__ = [
"ADASYN",
"RandomOverSampler",
"KMeans... | 411 | 19.6 | 82 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_adasyn.py | """Class to perform over-sampling using ADASYN."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numbers
import warnings
import numpy as np
from scipy import sparse
from sklearn.utils import _safe_indexing, check_random_state
from ..utils import Substitutio... | 8,545 | 35.521368 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/tests/test_common.py | from collections import Counter
import numpy as np
import pytest
from sklearn.cluster import MiniBatchKMeans
from imblearn.over_sampling import (
ADASYN,
SMOTE,
SMOTEN,
SMOTENC,
SVMSMOTE,
BorderlineSMOTE,
KMeansSMOTE,
)
from imblearn.utils.testing import _CustomNearestNeighbors
@pytest.f... | 4,235 | 28.013699 | 83 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/tests/test_random_over_sampler.py | """Test the module under sampler."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
from datetime import datetime
import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.utils._testing import (
... | 9,430 | 31.52069 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/tests/test_adasyn.py | """Test the module under sampler."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.over_sampling import ADASYN
RND_... | 3,969 | 31.540984 | 80 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/base.py | """Base class and original SMOTE methods for over-sampling"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Fernando Nogueira
# Christos Aridas
# Dzianis Dudnik
# License: MIT
import math
import numbers
import warnings
import numpy as np
from scipy import sparse
from sklearn.bas... | 39,149 | 36.321258 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/filter.py | """SMOTE variant applying some filtering before the generation process."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Fernando Nogueira
# Christos Aridas
# Dzianis Dudnik
# License: MIT
import numbers
import warnings
import numpy as np
from scipy import sparse
from sklearn.b... | 19,936 | 35.988868 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/cluster.py | """SMOTE variant employing some clustering before the generation."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Fernando Nogueira
# Christos Aridas
# License: MIT
import math
import numbers
import numpy as np
from scipy import sparse
from sklearn.base import clone
from sklearn.cluster... | 11,028 | 34.808442 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/__init__.py | from .base import SMOTE, SMOTEN, SMOTENC
from .cluster import KMeansSMOTE
from .filter import SVMSMOTE, BorderlineSMOTE
__all__ = [
"SMOTE",
"SMOTEN",
"SMOTENC",
"KMeansSMOTE",
"BorderlineSMOTE",
"SVMSMOTE",
]
| 235 | 17.153846 | 45 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_smote_nc.py | """Test the module SMOTENC."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# Dzianis Dudnik
# License: MIT
from collections import Counter
import numpy as np
import pytest
import sklearn
from scipy import sparse
from sklearn.datasets import make_classification
from sklea... | 14,594 | 33.75 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_smoten.py | import numpy as np
import pytest
from sklearn.exceptions import DataConversionWarning
from sklearn.preprocessing import OneHotEncoder, OrdinalEncoder
from sklearn.utils._testing import _convert_container
from imblearn.over_sampling import SMOTEN
@pytest.fixture
def data():
rng = np.random.RandomState(0)
fea... | 3,231 | 32.666667 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_smote.py | """Test the module SMOTE."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.over_sampling import SMOTE
RND_SEED = 0
... | 5,046 | 32.646667 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_borderline_smote.py | from collections import Counter
import pytest
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.over_sampling import BorderlineSMOTE
@pytest.mark.parametrize("kind", ["borderline-1... | 3,490 | 30.45045 | 86 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_kmeans_smote.py | import numpy as np
import pytest
from sklearn.cluster import KMeans, MiniBatchKMeans
from sklearn.datasets import make_classification
from sklearn.neighbors import NearestNeighbors
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.over_sampling import SMOTE, KMeansSMOTE
@pytest.fix... | 3,632 | 32.330275 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/over_sampling/_smote/tests/test_svm_smote.py | import numpy as np
import pytest
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import NearestNeighbors
from sklearn.svm import SVC
from sklearn.utils._testing import assert_allclose, assert_array_equal
from imblearn.over_sampling import SVMS... | 2,860 | 31.146067 | 85 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/keras/_generator.py | """Implement generators for ``keras`` which will balance the data."""
# This is a trick to avoid an error during tests collection with pytest. We
# avoid the error when importing the package raise the error at the moment of
# creating the instance.
# This is a trick to avoid an error during tests collection with pyte... | 10,276 | 33.719595 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/keras/__init__.py | """The :mod:`imblearn.keras` provides utilities to deal with imbalanced dataset
in keras."""
from ._generator import BalancedBatchGenerator, balanced_batch_generator
__all__ = ["BalancedBatchGenerator", "balanced_batch_generator"]
| 233 | 32.428571 | 79 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/keras/tests/test_generator.py | import numpy as np
import pytest
from scipy import sparse
from sklearn.cluster import KMeans
from sklearn.datasets import load_iris
from sklearn.preprocessing import LabelBinarizer
keras = pytest.importorskip("keras")
from keras.layers import Dense # noqa: E402
from keras.models import Sequential # noqa: E402
from ... | 4,289 | 27.986486 | 86 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/keras/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/_show_versions.py | """
Utility method which prints system info to help with debugging,
and filing issues on GitHub.
Adapted from :func:`sklearn.show_versions`,
which was adapted from :func:`pandas.show_versions`
"""
# Author: Alexander L. Hayes <hayesall@iu.edu>
# License: MIT
from .. import __version__
def _get_deps_info():
"""O... | 2,176 | 22.408602 | 64 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/deprecation.py | """Utilities for deprecation"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import warnings
def deprecate_parameter(sampler, version_deprecation, param_deprecated, new_param=None):
"""Helper to deprecate a parameter by another one.
Parameters
----------
sampler : sampler o... | 1,631 | 33.723404 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/_docstring.py | """Utilities for docstring in imbalanced-learn."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
class Substitution:
"""Decorate a function's or a class' docstring to perform string
substitution on it.
This decorator should be robust even if obj.__doc__ is None
(for example, ... | 1,512 | 32.622222 | 83 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/testing.py | """Test utilities."""
# Adapted from scikit-learn
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import inspect
import pkgutil
from importlib import import_module
from operator import itemgetter
from pathlib import Path
import numpy as np
from scipy import sparse
from sklearn.base import BaseE... | 5,322 | 32.689873 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/estimator_checks.py | """Utils to check the samplers and compatibility with scikit-learn"""
# Adapated from scikit-learn
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import re
import sys
import traceback
import warnings
from collections import Counter
from functools import partial
import numpy as np
import pytest... | 28,070 | 34.08875 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/_validation.py | """Utilities for input validation"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import warnings
from collections import OrderedDict
from functools import wraps
from inspect import Parameter, signature
from numbers import Integral, Real
import numpy as np
from sklearn.base import clone
from... | 22,939 | 35.586922 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/_available_if.py | """This is a copy of sklearn/utils/_available_if.py. It can be removed when
we support scikit-learn >= 1.1.
"""
# mypy: ignore-errors
from functools import update_wrapper, wraps
from types import MethodType
import sklearn
from sklearn.utils import parse_version
sklearn_version = parse_version(sklearn.__version__)
i... | 3,316 | 32.17 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/__init__.py | """
The :mod:`imblearn.utils` module includes various utilities.
"""
from ._docstring import Substitution
from ._validation import (
check_neighbors_object,
check_sampling_strategy,
check_target_type,
)
__all__ = [
"check_neighbors_object",
"check_sampling_strategy",
"check_target_type",
"... | 337 | 17.777778 | 60 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/fixes.py | """Compatibility fixes for older version of python, numpy, scipy, and
scikit-learn.
If you add content to this file, please give the version of the package at
which the fix is no longer needed.
"""
import functools
import sys
import numpy as np
import scipy
import scipy.stats
import sklearn
from sklearn.utils.fixes i... | 5,221 | 33.582781 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/_param_validation.py | """This is a copy of sklearn/utils/_param_validation.py. It can be removed when
we support scikit-learn >= 1.2.
"""
# mypy: ignore-errors
import functools
import math
import operator
import re
import warnings
from abc import ABC, abstractmethod
from collections.abc import Iterable
from inspect import signature
from num... | 32,856 | 33.880042 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_param_validation.py | """This is a copy of sklearn/utils/tests/test_param_validation.py. It can be
removed when we support scikit-learn >= 1.2.
"""
from numbers import Integral, Real
import numpy as np
import pytest
from scipy.sparse import csr_matrix
from sklearn.base import BaseEstimator
from sklearn.model_selection import LeaveOneOut
fr... | 23,785 | 30.174312 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_deprecation.py | """Test for the deprecation helper"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import pytest
from imblearn.utils.deprecation import deprecate_parameter
class Sampler:
def __init__(self):
self.a = "something"
self.b = "something"
def test_deprecate_parameter():
... | 554 | 24.227273 | 65 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_show_versions.py | """Test for the show_versions helper. Based on the sklearn tests."""
# Author: Alexander L. Hayes <hayesall@iu.edu>
# License: MIT
from imblearn.utils._show_versions import _get_deps_info, show_versions
def test_get_deps_info():
_deps_info = _get_deps_info()
assert "pip" in _deps_info
assert "setuptools"... | 1,818 | 28.819672 | 78 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_estimator_checks.py | import numpy as np
import pytest
from sklearn.base import BaseEstimator
from sklearn.utils.multiclass import check_classification_targets
from imblearn.base import BaseSampler
from imblearn.over_sampling.base import BaseOverSampler
from imblearn.utils import check_target_type as target_check
from imblearn.utils.estima... | 3,546 | 27.837398 | 85 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_docstring.py | """Test utilities for docstring."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import pytest
from imblearn.utils import Substitution
from imblearn.utils._docstring import _n_jobs_docstring, _random_state_docstring
func_docstring = """A function.
Parameters
----------
xxx
... | 1,604 | 18.337349 | 80 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_validation.py | """Test for the validation helper"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter, OrderedDict
import numpy as np
import pytest
from sklearn.cluster import KMeans
from sklearn.neighbors import NearestNeighbors
from sklearn.neighbors._... | 13,629 | 34.587467 | 90 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_min_dependencies.py | """Tests for the minimum dependencies in the README.rst file."""
import os
import platform
import re
from pathlib import Path
import pytest
from sklearn.utils.fixes import parse_version
import imblearn
from imblearn._min_dependencies import dependent_packages
@pytest.mark.skipif(
platform.system() == "Windows",... | 1,594 | 29.673077 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/utils/tests/test_testing.py | """Test for the testing module"""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
from sklearn.neighbors._base import KNeighborsMixin
from imblearn.base import SamplerMixin
from imblearn.utils.testing import _CustomNearestNeighbors, all... | 1,692 | 32.86 | 84 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/_forest.py | """Forest classifiers trained on balanced boostrasp samples."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT
import numbers
from copy import deepcopy
from warnings import warn
import numpy as np
import sklearn
from numpy import float32 as DTYPE
from numpy import float64 as DOUBLE
from scipy.... | 33,610 | 37.677791 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/_bagging.py | """Bagging classifier trained on balanced bootstrap samples."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import copy
import inspect
import numbers
import warnings
import numpy as np
import sklearn
from sklearn.base import clone
from sklearn.ensemble import Bagg... | 17,943 | 35.177419 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/_easy_ensemble.py | """Class to perform under-sampling using easy ensemble."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import copy
import inspect
import numbers
import warnings
import numpy as np
import sklearn
from sklearn.base import clone
from sklearn.ensemble import AdaBoostC... | 14,078 | 33.507353 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/_weight_boosting.py | import copy
import inspect
import numbers
import warnings
from copy import deepcopy
import numpy as np
import sklearn
from sklearn.base import clone
from sklearn.ensemble import AdaBoostClassifier
from sklearn.ensemble._base import _set_random_states
from sklearn.tree import DecisionTreeClassifier
from sklearn.utils i... | 16,255 | 35.44843 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/__init__.py | """
The :mod:`imblearn.ensemble` module include methods generating
under-sampled subsets combined inside an ensemble.
"""
from ._bagging import BalancedBaggingClassifier
from ._easy_ensemble import EasyEnsembleClassifier
from ._forest import BalancedRandomForestClassifier
from ._weight_boosting import RUSBoostClassifi... | 465 | 26.411765 | 62 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/_common.py | from numbers import Integral, Real
from sklearn.tree._criterion import Criterion
from ..utils._param_validation import (
HasMethods,
Hidden,
Interval,
RealNotInt,
StrOptions,
)
def _estimator_has(attr):
"""Check if we can delegate a method to the underlying estimator.
First, we check the... | 3,455 | 31.914286 | 83 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/tests/test_bagging.py | """Test the module ensemble classifiers."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
from collections import Counter
import numpy as np
import pytest
import sklearn
from sklearn.cluster import KMeans
from sklearn.datasets import load_iris, make_classification, m... | 20,190 | 31.724473 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/tests/test_forest.py | import numpy as np
import pytest
import sklearn
from sklearn.datasets import load_iris, make_classification
from sklearn.model_selection import GridSearchCV, train_test_split
from sklearn.utils._testing import assert_allclose, assert_array_equal
from sklearn.utils.fixes import parse_version
from imblearn.ensemble impo... | 8,447 | 31.367816 | 88 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/tests/test_easy_ensemble.py | """Test the module easy ensemble."""
# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# Christos Aridas
# License: MIT
import numpy as np
import pytest
import sklearn
from sklearn.datasets import load_iris, make_hastie_10_2
from sklearn.ensemble import AdaBoostClassifier
from sklearn.feature_selection i... | 8,276 | 31.845238 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/imblearn/ensemble/tests/test_weight_boosting.py | import numpy as np
import pytest
import sklearn
from sklearn.datasets import load_iris, make_classification
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.utils._testing import assert_array_equal
from sklearn.utils.fixes import parse_version
from imble... | 4,138 | 34.681034 | 87 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tensorflow/_generator.py | """Implement generators for ``tensorflow`` which will balance the data."""
from scipy.sparse import issparse
from sklearn.base import clone
from sklearn.utils import _safe_indexing, check_random_state
from ..under_sampling import RandomUnderSampler
from ..utils import Substitution
from ..utils._docstring import _rand... | 3,294 | 32.622449 | 83 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tensorflow/__init__.py | """The :mod:`imblearn.tensorflow` provides utilities to deal with imbalanced
dataset in tensorflow."""
from ._generator import balanced_batch_generator
__all__ = ["balanced_batch_generator"]
| 193 | 26.714286 | 76 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tensorflow/tests/test_generator.py | from distutils.version import LooseVersion
import numpy as np
import pytest
from scipy import sparse
from sklearn.datasets import load_iris
from imblearn.datasets import make_imbalance
from imblearn.over_sampling import RandomOverSampler
from imblearn.tensorflow import balanced_batch_generator
from imblearn.under_sam... | 5,406 | 30.254335 | 82 | py |
imbalanced-learn | imbalanced-learn-master/imblearn/tensorflow/tests/__init__.py | 0 | 0 | 0 | py | |
imbalanced-learn | imbalanced-learn-master/doc/conf.py | # -*- coding: utf-8 -*-
#
# imbalanced-learn documentation build configuration file, created by
# sphinx-quickstart on Mon Jan 18 14:44:12 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated fi... | 10,651 | 30.514793 | 87 | py |
imbalanced-learn | imbalanced-learn-master/doc/sphinxext/github_link.py | import inspect
import os
import subprocess
import sys
from functools import partial
from operator import attrgetter
REVISION_CMD = "git rev-parse --short HEAD"
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subprocess.CalledProcessError, OSError... | 2,616 | 30.154762 | 85 | py |
imbalanced-learn | imbalanced-learn-master/doc/sphinxext/sphinx_issues.py | # -*- coding: utf-8 -*-
"""A Sphinx extension for linking to your project's issue tracker.
Copyright 2014 Steven Loria
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, includi... | 8,183 | 35.535714 | 82 | py |
ML-Doctor | ML-Doctor-main/demo.py | import os
import sys
import torch
import argparse
import torch.nn as nn
import torchvision.models as models
from doctor.meminf import *
from doctor.modinv import *
from doctor.attrinf import *
from doctor.modsteal import *
from demoloader.train import *
from demoloader.DCGAN import *
from utils.define_models import *
... | 10,614 | 41.290837 | 183 | py |
ML-Doctor | ML-Doctor-main/demoloader/dataloader.py | import os
import torch
import pandas
import torchvision
torch.manual_seed(0)
import torch.nn as nn
import PIL.Image as Image
import torchvision.transforms as transforms
from functools import partial
from typing import Any, Callable, List, Optional, Union, Tuple
class CNN(nn.Module):
def __init__(self, input_chann... | 9,806 | 33.900356 | 184 | py |
ML-Doctor | ML-Doctor-main/demoloader/train.py | import torch
import numpy as np
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
np.set_printoptions(threshold=np.inf)
from opacus import PrivacyEngine
from torch.optim import lr_scheduler
def GAN_init(m):
classname = m.__class__.__name__
... | 11,748 | 37.270358 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.