Skip to content

Error with under_sampling.CondensedNearestNeighbour #676

@WafaMribah

Description

@WafaMribah

I am trying to balance my data by reducing the number of samples of the class 0 but every time I specify the ratio ( via the sampling_strategy parameter, I get the following error :

Code

import matplotlib.pyplot as plt
import numpy as np

from sklearn.decomposition import PCA
from imblearn.under_sampling import (CondensedNearestNeighbour,
                                     EditedNearestNeighbours, AllKNN)

print(__doc__)

pca = PCA(n_components=2)

sampling_strategy = {0: 3500, 1:171}
cnn = CondensedNearestNeighbour(sampling_strategy)
X_resampled, y_resampled = cnn.fit_sample(X_train, Y_train)

ValueError: 'sampling_strategy' as a dict for cleaning methods is not supported. Please give a list of the classes to be targeted by the sampling. 

Remark

If the sampling strategy parameter is indeed removed as mentioned in the documentation then I would like to know if there is another way to specify the ratio.

Versions

Linux-4.9.119-44.140.amzn1.x86_64-x86_64-with-glibc2.9
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0]
NumPy 1.17.0
SciPy 1.3.1
Scikit-Learn 0.22.1
Imbalanced-Learn 0.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions