imblearn clustercentroids

Solutions on MaxInterview for imblearn clustercentroids by the best coders in the world

showing results for - "imblearn clustercentroids"
Julissa
03 Mar 2016
1>>> from collections import Counter
2>>> from sklearn.datasets import make_classification
3>>> from imblearn.under_sampling import ClusterCentroids 
4>>> X, y = make_classification(n_classes=2, class_sep=2,
5... weights=[0.1, 0.9], n_informative=3, n_redundant=1, flip_y=0,
6... n_features=20, n_clusters_per_class=1, n_samples=1000, random_state=10)
7>>> print('Original dataset shape %s' % Counter(y))
8Original dataset shape Counter({1: 900, 0: 100})
9>>> cc = ClusterCentroids(random_state=42)
10>>> X_res, y_res = cc.fit_resample(X, y)
11>>> print('Resampled dataset shape %s' % Counter(y_res))
12... 
13Resampled dataset shape Counter({...})
14