import numpy as np
from sklearn.datasets import make_blobs as _make_blobs
from sklearn.utils import check_random_state, shuffle as _shuffle

__all__ = ['make_blobs']


def make_blobs(
    centers=5, center_box=(-10., 10.), cluster_std=1., contamination=0.02,
    n_features=25, n_samples=500, random_state=None, shuffle=True
):
    """Generate isotropic Gaussian blobs with outliers.

    Parameters
    ----------
    centers : int or array-like of shape (n_centers, n_features), default 5
        Number of centers to generate, or the fixed center locations.

    center_box : pair of floats (min, max), default (-10.0, 10.0)
        Bounding box for each cluster center when centers are generated at
        random.

    cluster_std : float or array-like of shape (n_centers,), default 1.0
        Standard deviation of the clusters.

    contamination : float, default 0.02
        Proportion of outliers in the data set.

    n_features : int, default 25
        Number of features for each sample.

    n_samples : int, default 500
        Number of samples.

    random_state : int, RandomState instance, default None
        Seed of the pseudo random number generator.

    shuffle : bool, default True
        If True, shuffle samples.

    Returns
    -------
    X : array-like of shape (n_samples, n_features)
        Generated data.

    y : array-like of shape (n_samples,)
        Return -1 for outliers and +1 for inliers.

    References
    ----------
    .. [#kriegel11] Kriegel, H.-P., Kroger, P., Schubert E., and Zimek, A.,
        "Interpreting and unifying outlier scores,"
        In Proceedings of SDM, pp. 13-24, 2011.

    Examples
    --------
    >>> from kenchi.datasets import make_blobs
    >>> X, y = make_blobs(n_samples=10, n_features=2, contamination=0.1)
    >>> X.shape
    (10, 2)
    >>> y.shape
    (10,)
    """

    rnd              = check_random_state(random_state)

    n_inliers        = int(np.round((1. - contamination) * n_samples))
    X_inliers, _     = _make_blobs(
        centers      = centers,
        center_box   = center_box,
        cluster_std  = cluster_std,
        n_features   = n_features,
        n_samples    = n_inliers,
        random_state = rnd,
        shuffle      = False
    )

    n_outliers       = n_samples - n_inliers
    X_outliers       = rnd.uniform(
        low          = np.min(X_inliers, axis=0),
        high         = np.max(X_inliers, axis=0),
        size         = (n_outliers, n_features)
    )

    X                = np.concatenate([X_outliers, X_inliers])
    y                = np.ones(n_samples, dtype=np.int)
    y[:n_outliers]   = -1

    if shuffle:
        X, y         = _shuffle(X, y, random_state=rnd)

    return X, y

@@ -134,16 +134,56 @@
 huffle%0A%0A
+from .base import NEG_LABEL, POS_LABEL%0A%0A
 __all__ 
@@ -1519,18 +1519,18 @@
 #kriegel
-11
+08
 %5D Kriege
@@ -1542,20 +1542,8 @@
 -P.,
- Kroger, P.,
  Sch
@@ -1547,18 +1547,19 @@
 Schubert
- E
+, M
 ., and Z
@@ -1581,97 +1581,279 @@
    %22
-Interpreting and unifying outlier scores,%22%0A        In Proceedings of SDM, pp. 13-24
+Angle-based outlier detection in high-dimensional data,%22%0A        In Proceedings of SIGKDD, pp. 444-452, 2008.%0A%0A    .. %5B#sugiyama13%5D Sugiyama, M., and Borgwardt, K.,%0A        %22Rapid distance-based outlier detection via sampling,%22%0A        Advances in NIPS, pp. 467-475
 , 201
-1
+3
 .%0A%0A 
@@ -2060,16 +2060,166 @@
    %22%22%22%0A%0A
+    if not 0. %3C contamination %3C= 0.5:%0A        raise ValueError(%0A            f'contamination must be in (0.0, 0.5%5D but was %7Bcontamination%7D'%0A        )%0A%0A
     rnd 
@@ -2354,12 +2354,12 @@
 lier
-s
 , _
+ 
     
@@ -2660,33 +2660,33 @@
 rs%0A    X_outlier
-s
+ 
        = rnd.uni
@@ -2721,33 +2721,32 @@
  np.min(X_inlier
-s
 , axis=0),%0A     
@@ -2778,17 +2778,16 @@
 X_inlier
-s
 , axis=0
@@ -2892,17 +2892,16 @@
 _outlier
-s
 , X_inli
@@ -2902,17 +2902,16 @@
 X_inlier
-s
 %5D)%0A    y
@@ -2935,12 +2935,13 @@
  np.
-ones
+empty
 (n_s
@@ -2954,19 +2954,16 @@
 , dtype=
-np.
 int)%0A   
@@ -2968,19 +2968,18 @@
    y%5B:n_
-out
+in
 liers%5D  
@@ -2983,12 +2983,53 @@
 %5D   
+ 
 = 
--1
+POS_LABEL%0A    y%5Bn_inliers:%5D    = NEG_LABEL
 %0A%0A  

fix make_blobs function