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
keras
keras-master/keras/mixed_precision/get_layer_policy.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
1,528
35.404762
80
py
keras
keras-master/keras/mixed_precision/loss_scale.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
2,071
33.533333
80
py
keras
keras-master/keras/mixed_precision/layer_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
18,563
41.774194
80
py
keras
keras-master/keras/mixed_precision/policy.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
24,502
40.601019
80
py
keras
keras-master/keras/mixed_precision/loss_scale_benchmark.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
6,177
39.379085
97
py
keras
keras-master/keras/mixed_precision/__init__.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
844
39.238095
80
py
keras
keras-master/keras/mixed_precision/autocast_variable.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
19,740
34.958106
146
py
keras
keras-master/keras/mixed_precision/get_layer_policy_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
1,650
34.12766
80
py
keras
keras-master/keras/mixed_precision/loss_scale_optimizer.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
51,264
40.611201
110
py
keras
keras-master/keras/mixed_precision/device_compatibility_check_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
5,467
37.507042
83
py
keras
keras-master/keras/mixed_precision/model_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
35,294
39.756351
80
py
keras
keras-master/keras/mixed_precision/layer_correctness_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
11,512
43.451737
80
py
keras
keras-master/keras/applications/mobilenet_v2.py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
20,697
38.05283
87
py
keras
keras-master/keras/applications/efficientnet.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
25,089
31.5
87
py
keras
keras-master/keras/applications/resnet.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
21,207
35.191126
87
py
keras
keras-master/keras/applications/vgg16.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
9,586
37.971545
87
py
keras
keras-master/keras/applications/densenet.py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
16,084
36.320186
87
py
keras
keras-master/keras/applications/imagenet_utils.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
15,197
33.778032
80
py
keras
keras-master/keras/applications/resnet_v2.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
6,741
32.879397
87
py
keras
keras-master/keras/applications/vgg19.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
9,818
38.276
87
py
keras
keras-master/keras/applications/inception_v3.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
16,038
36.562061
87
py
keras
keras-master/keras/applications/mobilenet_v3.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
23,489
38.412752
87
py
keras
keras-master/keras/applications/nasnet.py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
30,441
36.215159
87
py
keras
keras-master/keras/applications/__init__.py
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
765
46.875
80
py
keras
keras-master/keras/applications/imagenet_utils_test.py
# Copyright 2019 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
9,851
32.39661
80
py
keras
keras-master/keras/applications/applications_load_weight_test.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
4,840
40.732759
80
py
keras
keras-master/keras/applications/xception.py
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
13,000
38.159639
87
py
keras
keras-master/keras/applications/inception_resnet_v2.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
15,195
37.470886
87
py
keras
keras-master/keras/applications/mobilenet.py
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
19,722
42.157549
87
py
keras
keras-master/keras/applications/applications_test.py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
5,219
34.27027
80
py
keras
keras-master/keras/applications/efficientnet_weight_update_util.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
13,222
34.834688
80
py
ReCO
ReCO-master/test.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/23 下午1:43 @FileName: test.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import argparse import torch from model import Bert4ReCO from utils import * parser = argparse.ArgumentParser() parser.add_argument("--model_type", type=str, default='bert-base-chinese...
1,629
30.346154
110
py
ReCO
ReCO-master/prepare_data.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/23 上午10:15 @FileName: prepare_data.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import json import random from transformers import BertTokenizer from utils import * tokenizer = None def get_shuffled_answer(alternatives): answers_index = [0, 1, 2] ...
2,068
35.298246
87
py
ReCO
ReCO-master/utils.py
# -*- coding: utf-8 -*- """ @Time : 2019/11/20 下午6:14 @FileName: utils.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import os import pickle import re import numpy as np import multiprocessing from joblib import Parallel, delayed from tqdm import tqdm def multi_process(func, lst, num_cores=multiproc...
1,783
23.438356
95
py
ReCO
ReCO-master/model.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/23 上午10:13 @FileName: model.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import torch import torch.nn as nn import torch.nn.functional as F from transformers import AutoModel class Bert4ReCO(nn.Module): def __init__(self, model_type): super()....
1,073
28.833333
93
py
ReCO
ReCO-master/train.py
# -*- coding: utf-8 -*- """ @Time : 2019/11/21 下午7:14 @FileName: train.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import argparse import torch from model import Bert4ReCO from prepare_data import prepare_bert_data from utils import * import torch.distributed as dist torch.manual_seed(100) np.rand...
5,074
33.290541
114
py
ReCO
ReCO-master/BiDAF/inference.py
# -*- coding: utf-8 -*- import argparse import cPickle import codecs import torch from utils import * from preprocess import seg_data, transform_data_to_id parser = argparse.ArgumentParser(description='inference procedure, note you should train the data at first') parser.add_argument('--data', type=str, ...
2,636
34.635135
113
py
ReCO
ReCO-master/BiDAF/utils.py
# -*- coding: utf-8 -*- import numpy as np def pad_answer(batch): output = [] length_info = [len(x[0]) for x in batch] max_length = max(length_info) for one in batch: output.append([x + [0] * (max_length - len(x)) for x in one]) return output def get_model_parameters(model): total = ...
2,196
32.8
118
py
ReCO
ReCO-master/BiDAF/MwAN.py
# -*- coding: utf-8 -*- import torch from torch import nn from torch.nn import functional as F class MwAN(nn.Module): def __init__(self, vocab_size, embedding_size, encoder_size, drop_out=0.2): super(MwAN, self).__init__() self.drop_out=drop_out self.embedding = nn.Embedding(vocab_size + 1...
4,704
44.679612
108
py
ReCO
ReCO-master/BiDAF/__init__.py
# -*- coding: utf-8 -*-
24
11.5
23
py
ReCO
ReCO-master/BiDAF/train.py
# -*- coding: utf-8 -*- import argparse import cPickle import torch from MwAN import MwAN from preprocess import process_data from utils import * parser = argparse.ArgumentParser(description='PyTorch implementation for Multiway Attention Networks for Modeling ' 'Sentence P...
4,466
38.184211
120
py
ReCO
ReCO-master/BiDAF/preprocess.py
# -*- coding: utf-8 -*- import cPickle import json import jieba def seg_line(line): return list(jieba.cut(line)) def seg_data(path): print 'start process ', path data = [] with open(path, 'r') as f: for line in f: dic = json.loads(line, encoding='utf-8') question = d...
3,805
32.095652
117
py
ReCO
ReCO-master/BiDAF/BiDAF.py
# -*- coding: utf-8 -*- """ @Time : 2019/11/21 下午4:42 @FileName: BiDAF.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import torch import torch.nn as nn import torch.nn.functional as F class BiDAF(nn.Module): def __init__(self, vocab_size, embedding_size, encoder_size, drop_out=0.2): supe...
4,904
40.923077
109
py
ReCO
ReCO-master/InHouseBert/prepare_data.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/23 上午10:15 @FileName: prepare_data.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import json import random from transformers import BertTokenizer, AutoTokenizer, XLNetTokenizer from utils import * import sentencepiece as spm tokenizer = spm.SentencePiecePro...
2,106
35.327586
87
py
ReCO
ReCO-master/InHouseBert/model.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/24 下午6:18 @FileName: model.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import warnings import apex import torch import torch.nn as nn from apex.contrib.multihead_attn import SelfMultiheadAttn from apex.mlp import MLP from torch.nn import functional as F w...
4,192
37.118182
119
py
ReCO
ReCO-master/InHouseBert/__init__.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/24 下午6:10 @FileName: __init__.py.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """
139
19
37
py
ReCO
ReCO-master/InHouseBert/train.py
# -*- coding: utf-8 -*- """ @Time : 2020/6/24 下午6:16 @FileName: train.py @author: 王炳宁 @contact: wangbingning@sogou-inc.com """ import argparse import sys sys.path.append("../..") sys.path.append("..") from tasks.ReCO.model import BERT from utils import * import torch.distributed as dist torch.manual_seed(100)...
5,292
32.713376
114
py
mining-legal-arguments
mining-legal-arguments-main/importance_model.py
from sklearn.svm import SVC from sklearn.model_selection import GridSearchCV from sklearn.metrics import classification_report, confusion_matrix from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler import os import json from cassis import * from collections import Co...
13,432
39.098507
173
py
mining-legal-arguments
mining-legal-arguments-main/evaluate.py
#!/usr/bin/env python # coding: utf-8 from collections import Counter from prettytable import PrettyTable import os from transformers import AutoTokenizer import torch from torch.utils.data import Dataset import pandas as pd from datasets import load_dataset, load_metric import csv from ast import literal_eval impor...
20,634
44.855556
227
py
mining-legal-arguments
mining-legal-arguments-main/create_arg_mining_dataset.py
from cassis import * from collections import Counter from prettytable import PrettyTable import os import pandas as pd import numpy as np original_data = True id2label_argType = ['O', 'B-Subsumtion', 'I-Subsumtion', 'B-Entscheidung des EGMR', 'I-Entscheidung des EGMR', 'B-Vorherige Rechtsprechung des EG...
13,984
45.616667
140
py
mining-legal-arguments
mining-legal-arguments-main/create_confusion_matrix.py
#!/usr/bin/env python # coding: utf-8 import pandas as pd from ast import literal_eval from sklearn.metrics import confusion_matrix from confusion_matrix_pretty_print import pretty_plot_confusion_matrix id2label_argType = ['B-Distinguishing', 'B-Einschätzungsspielraum', 'B-Entscheidung des EGMR', 'B-Konsens der pr...
3,478
38.534091
195
py
mining-legal-arguments
mining-legal-arguments-main/multiTaskModel.py
#!/usr/bin/env python # coding: utf-8 from collections import Counter from prettytable import PrettyTable import os from transformers import AutoTokenizer import torch from torch.utils.data import Dataset import pandas as pd from datasets import load_dataset, load_metric import csv from ast import literal_eval import...
25,615
37.232836
144
py
mining-legal-arguments
mining-legal-arguments-main/compare_f1s.py
#!/usr/bin/env python # coding: utf-8 import pandas as pd import csv from ast import literal_eval from collections import Counter import numpy as np from tabulate import tabulate from multiTaskModel import compute_f1 id2label_argType = ['B-Distinguishing', 'B-Einschätzungsspielraum', 'B-Entscheidung des EGMR', ...
7,473
42.202312
175
py
mining-legal-arguments
mining-legal-arguments-main/confusion_matrix_pretty_print.py
# -*- coding: utf-8 -*- """ plot a pretty confusion matrix with seaborn Created on Mon Jun 25 14:17:37 2018 @author: Wagner Cipriano - wagnerbhbr - gmail - CEFETMG / MMC REFerences: https://www.mathworks.com/help/nnet/ref/plotconfusion.html https://stackoverflow.com/questions/28200786/how-to-plot-scikit-learn-class...
11,369
35.796117
265
py
imbalanced-learn
imbalanced-learn-master/conftest.py
# This file is here so that when running from the root folder # ./imblearn is added to sys.path by pytest. # See https://docs.pytest.org/en/latest/pythonpath.html for more details. # For example, this allows to build extensions in place and run pytest # doc/modules/clustering.rst and use imblearn from the local folder ...
798
32.291667
73
py
imbalanced-learn
imbalanced-learn-master/setup.py
#! /usr/bin/env python """Toolbox for imbalanced dataset in machine learning.""" import codecs import os from setuptools import find_packages, setup try: import builtins except ImportError: # Python 2 compat: just to be able to declare that Python >=3.7 is needed. import __builtin__ as builtins # This i...
2,646
32.0875
85
py
imbalanced-learn
imbalanced-learn-master/examples/pipeline/plot_pipeline_classification.py
""" ==================================== Usage of pipeline embedding samplers ==================================== An example of the :class:~imblearn.pipeline.Pipeline` object (or :func:`~imblearn.pipeline.make_pipeline` helper function) working with transformers and resamplers. """ # Authors: Christos Aridas # ...
2,006
25.407895
86
py
imbalanced-learn
imbalanced-learn-master/examples/evaluation/plot_metrics.py
""" ======================================= Metrics specific to imbalanced learning ======================================= Specific metrics have been developed to evaluate classifier which has been trained using imbalanced data. :mod:`imblearn` provides mainly two additional metrics which are not implemented in :mod:...
2,900
25.135135
88
py
imbalanced-learn
imbalanced-learn-master/examples/evaluation/plot_classification_report.py
""" ============================================= Evaluate classification by compiling a report ============================================= Specific metrics have been developed to evaluate classifier which has been trained using imbalanced data. :mod:`imblearn` provides a classification report similar to :mod:`sklea...
1,584
25.416667
84
py
imbalanced-learn
imbalanced-learn-master/examples/combine/plot_comparison_combine.py
""" ================================================== Compare sampler combining over- and under-sampling ================================================== This example shows the effect of applying an under-sampling algorithms after SMOTE over-sampling. In the literature, Tomek's link and edited nearest neighbours ar...
3,820
30.065041
88
py
imbalanced-learn
imbalanced-learn-master/examples/model_selection/plot_validation_curve.py
""" ========================== Plotting Validation Curves ========================== In this example the impact of the :class:`~imblearn.over_sampling.SMOTE`'s `k_neighbors` parameter is examined. In the plot you can see the validation scores of a SMOTE-CART classifier for different values of the :class:`~imblearn.ove...
3,153
24.435484
87
py
imbalanced-learn
imbalanced-learn-master/examples/api/plot_sampling_strategy_usage.py
""" ==================================================== How to use ``sampling_strategy`` in imbalanced-learn ==================================================== This example shows the different usage of the parameter ``sampling_strategy`` for the different family of samplers (i.e. over-sampling, under-sampling. or c...
6,099
30.443299
88
py
imbalanced-learn
imbalanced-learn-master/examples/datasets/plot_make_imbalance.py
""" ============================ Create an imbalanced dataset ============================ An illustration of the :func:`~imblearn.datasets.make_imbalance` function to create an imbalanced dataset from a balanced dataset. We show the ability of :func:`~imblearn.datasets.make_imbalance` of dealing with Pandas DataFrame...
2,474
23.264706
76
py
imbalanced-learn
imbalanced-learn-master/examples/over-sampling/plot_shrinkage_effect.py
""" ====================================================== Effect of the shrinkage factor in random over-sampling ====================================================== This example shows the effect of the shrinkage factor used to generate the smoothed bootstrap using the :class:`~imblearn.over_sampling.RandomOverSamp...
3,956
30.656
87
py
imbalanced-learn
imbalanced-learn-master/examples/over-sampling/plot_illustration_generation_sample.py
""" ============================================ Sample generator used in SMOTE-like samplers ============================================ This example illustrates how a new sample is generated taking into account the neighbourhood of this sample. A new sample is generated by selecting the randomly 2 samples of the sa...
2,010
26.547945
88
py
imbalanced-learn
imbalanced-learn-master/examples/over-sampling/plot_comparison_over_sampling.py
""" ============================== Compare over-sampling samplers ============================== The following example attends to make a qualitative comparison between the different over-sampling algorithms available in the imbalanced-learn package. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # License...
10,987
30.304843
86
py
imbalanced-learn
imbalanced-learn-master/examples/under-sampling/plot_illustration_nearmiss.py
""" ============================ Sample selection in NearMiss ============================ This example illustrates the different way of selecting example in :class:`~imblearn.under_sampling.NearMiss`. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # License: MIT # %% print(__doc__) import seaborn as sn...
5,767
25.827907
81
py
imbalanced-learn
imbalanced-learn-master/examples/under-sampling/plot_illustration_tomek_links.py
""" ============================================== Illustration of the definition of a Tomek link ============================================== This example illustrates what is a Tomek link. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # License: MIT # %% print(__doc__) import matplotlib.pyplot as pl...
3,180
22.389706
79
py
imbalanced-learn
imbalanced-learn-master/examples/under-sampling/plot_comparison_under_sampling.py
""" =============================== Compare under-sampling samplers =============================== The following example attends to make a qualitative comparison between the different under-sampling algorithms available in the imbalanced-learn package. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Lic...
9,708
30.11859
88
py
imbalanced-learn
imbalanced-learn-master/examples/ensemble/plot_bagging_classifier.py
""" ================================= Bagging classifiers using sampler ================================= In this example, we show how :class:`~imblearn.ensemble.BalancedBaggingClassifier` can be used to create a large variety of classifiers by giving different samplers. We will give several examples that have been p...
6,020
32.636872
88
py
imbalanced-learn
imbalanced-learn-master/examples/ensemble/plot_comparison_ensemble_classifier.py
""" ============================================= Compare ensemble classifiers using resampling ============================================= Ensemble classifiers have shown to improve classification performance compare to single learner. However, they will be affected by class imbalance. This example shows the benefi...
7,338
30.497854
85
py
imbalanced-learn
imbalanced-learn-master/examples/applications/plot_impact_imbalanced_classes.py
""" ========================================================== Fitting model on imbalanced datasets and how to fight bias ========================================================== This example illustrates the problem induced by learning on datasets having imbalanced classes. Subsequently, we compare different approac...
12,377
32.274194
87
py
imbalanced-learn
imbalanced-learn-master/examples/applications/porto_seguro_keras_under_sampling.py
""" ========================================================== Porto Seguro: balancing samples in mini-batches with Keras ========================================================== This example compares two strategies to train a neural-network on the Porto Seguro Kaggle data set [1]_. The data set is imbalanced and we...
8,747
32.776062
88
py
imbalanced-learn
imbalanced-learn-master/examples/applications/plot_topic_classication.py
""" ================================================= Example of topic classification in text documents ================================================= This example shows how to balance the text data before to train a classifier. Note that for this example, the data are slightly imbalanced but it can happen that fo...
3,358
30.101852
83
py
imbalanced-learn
imbalanced-learn-master/examples/applications/plot_multi_class_under_sampling.py
""" ============================================= Multiclass classification with under-sampling ============================================= Some balancing methods allow for balancing dataset with multiples classes. We provide an example to illustrate the use of those methods which do not differ from the binary case....
1,494
28.313725
85
py
imbalanced-learn
imbalanced-learn-master/examples/applications/plot_over_sampling_benchmark_lfw.py
""" ========================================================== Benchmark over-sampling methods in a face recognition task ========================================================== In this face recognition example two faces are used from the LFW (Faces in the Wild) dataset. Several implemented over-sampling methods ar...
4,750
29.651613
79
py
imbalanced-learn
imbalanced-learn-master/examples/applications/plot_outlier_rejections.py
""" =============================================================== Customized sampler to implement an outlier rejections estimator =============================================================== This example illustrates the use of a custom sampler to implement an outlier rejections estimator. It can be used easily wi...
4,353
34.688525
85
py
imbalanced-learn
imbalanced-learn-master/maint_tools/test_docstring.py
import importlib import inspect import pkgutil import re from inspect import signature from typing import Optional import pytest import imblearn from imblearn.utils.testing import all_estimators numpydoc_validation = pytest.importorskip("numpydoc.validate") # List of whitelisted modules and methods; regexp are supp...
8,925
29.360544
85
py
imbalanced-learn
imbalanced-learn-master/imblearn/base.py
"""Base class for sampling""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT from abc import ABCMeta, abstractmethod import numpy as np import sklearn from sklearn.base import BaseEstimator try: # scikit-learn >= 1.2 from sklearn.base import OneToOneFeature...
12,954
29.845238
88
py
imbalanced-learn
imbalanced-learn-master/imblearn/exceptions.py
""" The :mod:`imblearn.exceptions` module includes all custom warnings and error classes and functions used across imbalanced-learn. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # License: MIT def raise_isinstance_error(variable_name, possible_type, variable): """Raise consistent error message for ...
785
22.818182
76
py
imbalanced-learn
imbalanced-learn-master/imblearn/_config.py
"""This is copy of sklearn/_config.py # TODO: remove this file when scikit-learn minimum version is 1.3 We remove the array_api_dispatch for the moment. """ import os import threading from contextlib import contextmanager as contextmanager import sklearn from sklearn.utils import parse_version sklearn_version = parse...
13,655
38.582609
87
py
imbalanced-learn
imbalanced-learn-master/imblearn/_version.py
""" ``imbalanced-learn`` is a set of python methods to deal with imbalanced datset in machine learning and pattern recognition. """ # Based on NiLearn package # License: simplified BSD # PEP0440 compatible formatted version, see: # https://www.python.org/dev/peps/pep-0440/ # # Generic release markers: # X.Y # X.Y.Z # ...
629
23.230769
71
py
imbalanced-learn
imbalanced-learn-master/imblearn/_min_dependencies.py
"""All minimum dependencies for imbalanced-learn.""" import argparse NUMPY_MIN_VERSION = "1.17.3" SCIPY_MIN_VERSION = "1.5.0" PANDAS_MIN_VERSION = "1.0.5" SKLEARN_MIN_VERSION = "1.0.2" TENSORFLOW_MIN_VERSION = "2.4.3" KERAS_MIN_VERSION = "2.4.3" JOBLIB_MIN_VERSION = "1.1.1" THREADPOOLCTL_MIN_VERSION = "2.0.0" PYTEST_M...
2,240
36.35
86
py
imbalanced-learn
imbalanced-learn-master/imblearn/__init__.py
"""Toolbox for imbalanced dataset in machine learning. ``imbalanced-learn`` is a set of python methods to deal with imbalanced datset in machine learning and pattern recognition. Subpackages ----------- combine Module which provides methods based on over-sampling and under-sampling. ensemble Module which prov...
3,963
30.967742
83
py
imbalanced-learn
imbalanced-learn-master/imblearn/pipeline.py
""" The :mod:`imblearn.pipeline` module implements utilities to build a composite estimator, as a chain of transforms, samples and estimators. """ # Adapted from scikit-learn # Author: Edouard Duchesnay # Gael Varoquaux # Virgile Fritsch # Alexandre Gramfort # Lars Buitinck # C...
18,767
38.428571
85
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/base.py
""" Base class for the under-sampling method. """ # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # License: MIT import numbers from collections.abc import Mapping from ..base import BaseSampler from ..utils._param_validation import Interval, StrOptions class BaseUnderSampler(BaseSampler): """Base class ...
3,904
33.557522
100
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/__init__.py
""" The :mod:`imblearn.under_sampling` provides methods to under-sample a dataset. """ from ._prototype_generation import ClusterCentroids from ._prototype_selection import ( AllKNN, CondensedNearestNeighbour, EditedNearestNeighbours, InstanceHardnessThreshold, NearMiss, NeighbourhoodCleaningRu...
733
21.242424
67
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_edited_nearest_neighbours.py
"""Classes to perform under-sampling based on the edited nearest neighbour method.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Dayvid Oliveira # Christos Aridas # License: MIT import numbers from collections import Counter import numpy as np from sklearn.utils import _safe_indexing ...
21,490
33.440705
87
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_nearmiss.py
"""Class to perform under-sampling based on nearmiss methods.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numbers import warnings from collections import Counter import numpy as np from sklearn.utils import _safe_indexing from ...utils import Substituti...
11,121
34.307937
83
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_one_sided_selection.py
"""Class to perform under-sampling based on one-sided selection method.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numbers import warnings from collections import Counter import numpy as np from sklearn.base import clone from sklearn.neighbors import KN...
8,259
35.22807
88
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_tomek_links.py
"""Class to perform under-sampling by removing Tomek's links.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Fernando Nogueira # Christos Aridas # License: MIT import numbers import numpy as np from sklearn.neighbors import NearestNeighbors from sklearn.utils import _safe_indexing fro...
5,115
30.776398
79
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_instance_hardness_threshold.py
"""Class to perform under-sampling based on the instance hardness threshold.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Dayvid Oliveira # Christos Aridas # License: MIT import numbers from collections import Counter import numpy as np from sklearn.base import ClassifierMixin, clone...
6,500
30.712195
87
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/__init__.py
""" The :mod:`imblearn.under_sampling.prototype_selection` submodule contains methods that select samples in order to balance the dataset. """ from ._condensed_nearest_neighbour import CondensedNearestNeighbour from ._edited_nearest_neighbours import ( AllKNN, EditedNearestNeighbours, RepeatedEditedNearest...
928
28.967742
73
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_random_under_sampler.py
"""Class to perform random under-sampling.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numpy as np from sklearn.utils import _safe_indexing, check_random_state from ...utils import Substitution, check_target_type from ...utils._docstring import _random_s...
4,601
31.181818
79
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_condensed_nearest_neighbour.py
"""Class to perform under-sampling based on the condensed nearest neighbour method.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numbers import warnings from collections import Counter import numpy as np from scipy.sparse import issparse from sklearn.base...
9,474
35.583012
88
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/_neighbourhood_cleaning_rule.py
"""Class performing under-sampling based on the neighbourhood cleaning rule.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numbers import warnings from collections import Counter import numpy as np from sklearn.base import clone from sklearn.neighbors impo...
9,614
36.123552
88
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_edited_nearest_neighbours.py
"""Test the module edited nearest neighbour.""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numpy as np from sklearn.datasets import make_classification from sklearn.neighbors import NearestNeighbors from sklearn.utils._testing import assert_array_equal from...
4,212
28.879433
74
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_nearmiss.py
"""Test the module nearmiss.""" # 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_array_equal from imblearn.under_sampling import NearMiss X = np.array( [ ...
6,989
32.127962
75
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_repeated_edited_nearest_neighbours.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.neighbors import NearestNeighbors from sklearn.utils._testing import assert_array_equal from imblearn.under_sampling i...
8,727
24.746313
86
py
imbalanced-learn
imbalanced-learn-master/imblearn/under_sampling/_prototype_selection/tests/test_instance_hardness_threshold.py
"""Test the module .""" # Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com> # Christos Aridas # License: MIT import numpy as np from sklearn.ensemble import GradientBoostingClassifier, RandomForestClassifier from sklearn.naive_bayes import GaussianNB as NB from sklearn.utils._testing import assert_array_eq...
3,118
31.489583
79
py