Skip to content

Commit

Permalink
Fix the mistake shown in landscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Lemaitre committed May 20, 2016
1 parent aa6761a commit 1e53be0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
6 changes: 3 additions & 3 deletions unbalanced_dataset/ensemble/balance_cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ def transform(self, X, y):
idx_under.append(np.concatenate((idx_min, idx_sel_from_maj),
axis=0))

if (not ((self.classifier_name == 'knn') or
(self.classifier_name == 'linear-svm')) and
self.bootstrap):
if (not (self.classifier_name == 'knn' or
self.classifier_name == 'linear-svm') and
self.bootstrap):
# Apply a bootstrap on x_data
curr_sample_weight = np.ones((y_data.size,), dtype=np.float64)
indices = np.random.randint(0, y_data.size, y_data.size)
Expand Down
2 changes: 0 additions & 2 deletions unbalanced_dataset/ensemble/ensemble_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from __future__ import print_function
from __future__ import division

from collections import Counter

from abc import ABCMeta, abstractmethod

from ..base_sampler import BaseSampler
Expand Down
6 changes: 2 additions & 4 deletions unbalanced_dataset/over_sampling/smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ def transform(self, X, y):

# Start by separating minority class features and target values.
X_min = X[y == self.min_c_]
y_min = y[y == self.min_c_]

# If regular SMOTE is to be performed
if self.kind == 'regular':
Expand Down Expand Up @@ -448,8 +447,7 @@ def transform(self, X, y):

return X_resampled, y_resampled

if (self.kind == 'borderline1' or
self.kind == 'borderline2'):
if self.kind == 'borderline1' or self.kind == 'borderline2':

if self.verbose:
print("Finding the {} nearest neighbours...".format(self.m))
Expand Down Expand Up @@ -638,7 +636,7 @@ def transform(self, X, y):

# Concatenate the newly generated samples to the original data set
if (np.count_nonzero(danger_bool) > 0 and
np.count_nonzero(safety_bool) > 0):
np.count_nonzero(safety_bool) > 0):
X_resampled = np.concatenate((X, X_new_1, X_new_2), axis=0)
y_resampled = np.concatenate((y, y_new_1, y_new_2), axis=0)
# not any support vectors in danger
Expand Down
2 changes: 0 additions & 2 deletions unbalanced_dataset/under_sampling/nearmiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from __future__ import print_function
from __future__ import division

import multiprocessing

import numpy as np

from collections import Counter
Expand Down
4 changes: 2 additions & 2 deletions unbalanced_dataset/under_sampling/tomek_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def transform(self, X, y):
# Check if the indices of the samples selected should be returned too
if self.return_indices:
# Return the indices of interest
return X[np.logical_not(links)], y[np.logical_not(links)],
np.nonzero(np.logical_not(links))[0]
return (X[np.logical_not(links)], y[np.logical_not(links)],
np.nonzero(np.logical_not(links))[0])
else:
# Return data set without majority Tomek links.
return X[np.logical_not(links)], y[np.logical_not(links)]

0 comments on commit 1e53be0

Please sign in to comment.