sample.py 619 B

1234567891011121314151617
  1. from sklearn.datasets import make_classification
  2. from collections import Counter
  3. from imblearn.over_sampling import RandomOverSampler
  4. X, y = make_classification(n_samples=5000, n_features=2, n_informative=2,
  5. n_redundant=0, n_repeated=0, n_classes=3,
  6. n_clusters_per_class=1,
  7. weights=[0.01, 0.05, 0.94],
  8. class_sep=0.8, random_state=0)
  9. # Counter(y)
  10. print(X)
  11. print(y)
  12. ros = RandomOverSampler(random_state=0)
  13. X_resampled, y_resampled = ros.fit_sample(X, y)
  14. print(X_resampled)
  15. # sorted(Counter(y_resampled).items())