Closed
Description
Describe the bug
ENN and RENN accept integers in the init parameter n_neighbors, to indicate the number of neighbours for the KNN algorithm
The default is 3. However, a 4 KNN is trained instead.
Steps/Code to Reproduce
import pandas as pd
from sklearn.datasets import make_classification
from imblearn.under_sampling import EditedNearestNeighbours
def make_data(sep):
# returns arrays
X, y = make_classification(n_samples=1000,
n_features=2,
n_redundant=0,
n_clusters_per_class=1,
weights=[0.99],
class_sep=sep,# how separate the classes are
random_state=1)
# trasform arrays into pandas df and series
X = pd.DataFrame(X, columns =['varA', 'varB'])
y = pd.Series(y)
return X, y
X, y = make_data(sep=2)
enn = EditedNearestNeighbours(
sampling_strategy='auto',
n_neighbors=3, **# I expect a 3 KNN**
kind_sel='all',
n_jobs=4,
)
X_resampled, y_resampled = enn.fit_resample(X, y)
enn.nn_
>>> NearestNeighbors(n_jobs=4, n_neighbors=4)
Expected Results
enn.nn_
NearestNeighbors(n_jobs=4, n_neighbors=3)
Actual Results
NearestNeighbors(n_jobs=4, n_neighbors=4)
Metadata
Metadata
Assignees
Labels
No labels