Skip to content

Commit

Permalink
Make everything PEP8 admissible
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Lemaitre committed May 20, 2016
1 parent 1e53be0 commit fd80b44
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions unbalanced_dataset/combine/tests/test_smote_enn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.combine import SMOTEENN


def test_smote_enn():
"""Test the SMOTE ENN function."""

Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/combine/tests/test_smote_tomek.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.combine import SMOTETomek


def test_smote_tomek():
"""Test the SMOTE TOMEK function."""

Expand Down
7 changes: 4 additions & 3 deletions unbalanced_dataset/ensemble/balance_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ def transform(self, X, y):
# rate of the previous iteration
np.random.seed(self.rs_)
idx_sel_from_maj = np.random.choice(np.nonzero(b_sel_N)[0],
size=num_samples, replace=False)
size=num_samples,
replace=False)
idx_sel_from_maj = np.concatenate((idx_mis_class,
idx_sel_from_maj),
axis=0).astype(int)
Expand Down Expand Up @@ -313,8 +314,8 @@ def transform(self, X, y):
# Select the remaining data
idx_sel_from_maj = np.nonzero(b_sel_N)[0]
idx_sel_from_maj = np.concatenate((idx_mis_class,
idx_sel_from_maj),
axis=0).astype(int)
idx_sel_from_maj),
axis=0).astype(int)
# Select the final batch
x_data = np.concatenate((X_min, N_x[idx_sel_from_maj, :]),
axis=0)
Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/ensemble/tests/test_balance_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.ensemble import BalanceCascade


def test_balance_cascade():
"""Test the balance cascade function."""

Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/ensemble/tests/test_easy_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.ensemble import EasyEnsemble


def test_easy_ensemble():
"""Test the easy ensemble function."""

Expand Down
15 changes: 7 additions & 8 deletions unbalanced_dataset/over_sampling/smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ def __init__(self, ratio='auto', random_state=None, verbose=True,
n_candidates=500,
n_neighbors=m+1)


# --- Nearest Neighbours for noise and boundary (in danger)
# Before creating synthetic samples we must first decide if
# a given entry is noise or in danger. We use m nns in this step
Expand Down Expand Up @@ -244,7 +243,6 @@ def fit(self, X, y):

return self


def in_danger_noise(self, samples, y, kind='danger'):
"""Estimate if a set of sample are in danger or not.
Expand Down Expand Up @@ -432,11 +430,11 @@ def transform(self, X, y):
# --- Generating synthetic samples
# Use static method make_samples to generate minority samples
X_new, y_new = self.make_samples(X_min,
self.min_c_,
X_min,
nns,
num_samples,
1.0)
self.min_c_,
X_min,
nns,
num_samples,
1.0)

if self.verbose:
print("done!")
Expand Down Expand Up @@ -573,7 +571,8 @@ def transform(self, X, y):

# Remove noisy support vectors
support_vector = support_vector[np.logical_not(noise_bool)]
danger_bool = self.in_danger_noise(support_vector, y, kind='danger')
danger_bool = self.in_danger_noise(support_vector, y,
kind='danger')
safety_bool = np.logical_not(danger_bool)

if self.verbose:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.over_sampling import RandomOverSampler


def test_over_sampler():
"""Test the random over sampler function."""

Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/over_sampling/tests/test_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.over_sampling import SMOTE


def test_smote():
"""Test the SMOTE function."""

Expand Down
1 change: 0 additions & 1 deletion unbalanced_dataset/under_sampling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@
'OneSidedSelection',
'NeighbourhoodCleaningRule',
'EditedNearestNeighbours']

1 change: 0 additions & 1 deletion unbalanced_dataset/under_sampling/nearmiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def _selection_dist_based(self, X, y, dist_vec, num_samples, key,
return (X[y == key][sel_idx], y[y == key][sel_idx],
np.nonzero(y == key)[0][sel_idx])


def transform(self, X, y):
"""Resample the dataset.
Expand Down
1 change: 0 additions & 1 deletion unbalanced_dataset/under_sampling/one_sided_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def __init__(self, return_indices=False, random_state=None, verbose=True,
self.n_jobs = n_jobs
self.kwargs = kwargs


def fit(self, X, y):
"""Find the classes statistics before to perform sampling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import ClusterCentroids


def test_cluster_centroids():
"""Test the cluster centroids function."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import CondensedNearestNeighbour


def test_condensed_nearest_neighbour():
"""Test the condensed nearest neighbour function."""

Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/under_sampling/tests/test_nearmiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import NearMiss


def test_nearmiss():
"""Test the nearmiss function."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import NeighbourhoodCleaningRule


def test_neighbourhood_cleaning_rule():
"""Test the neighbourhood cleaning rule function."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import OneSidedSelection


def test_one_sided_selection():
"""Test the one sided selection function."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import RandomUnderSampler


def test_random_under_sampler():
"""Test the random under sampler function."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.under_sampling import TomekLinks


def test_tomek_links():
"""Test the Tomek links function."""

Expand Down
4 changes: 2 additions & 2 deletions unbalanced_dataset/under_sampling/under_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def __init__(self, ratio='auto', return_indices=True, random_state=None,
"""

super(UnderSampler, self).__init__(ratio=ratio,
random_state=random_state,
verbose=verbose)
random_state=random_state,
verbose=verbose)

self.return_indices = return_indices

Expand Down
1 change: 1 addition & 0 deletions unbalanced_dataset/utils/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from unbalanced_dataset.utils import Pipeline


def test_pipeline():
"""Test the pipeline function."""

Expand Down

0 comments on commit fd80b44

Please sign in to comment.