ó
cÂY]c           @   sÉ  d  Z  d d l Z d d l Z d d l Z d d l m Z d d l j Z	 d d l
 m Z d d l m Z m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z e j j Z e j j Z d „  Z d d d d d d d d d d e d d e d d „ Z d d d d d e e d e d d „
 Z  d d d „ Z! d d d d d d d d e e d d „ Z" d e d d d d „ Z# d e d d d „ Z$ d d d d d5 e d d" „ Z% d d d d d# „ Z& d d d d$ „ Z' d d d d% „ Z( d d d d d d& „ Z) d d' „ Z* d d d d( „ Z+ d d) „ Z, d d* e d+ d, d d- „ Z- d d d d. „ Z. d d d d/ „ Z/ d d d d d0 e d d1 „ Z0 d d2 „ Z1 d d d e d d3 „ Z2 d d d e d d4 „ Z3 d S(6   s*   
Generate samples of synthetic data sets.
iÿÿÿÿN(   t   linalgi   (   t   MultiLabelBinarizer(   t   check_arrayt   check_random_state(   t   shuffle(   t	   _Iterable(   t   sample_without_replacement(   t   sixc         C   s«   | d k rD t  j | j d d |  | d f ƒt |  d | ƒ g ƒ St d | |  d | ƒj d d d t ƒ } t  j | j d ƒ ƒ j	 d ƒ d d … | d … f } | S(   s9   Returns distinct binary samples of length dimensions
    i   i   t   sizet   random_statet   dtypes   >u4t   copys   >u1iÿÿÿÿi    N(   iÿÿÿÿi    (
   t   npt   hstackt   randintt   _generate_hypercubeR   t   astypet   Falset
   unpackbitst   viewt   reshape(   t   samplest
   dimensionst   rngt   out(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyR      s    "	8id   i   i    g{®Gáz„?g      ð?g        c   !      C   s  t  | ƒ } | | | | k r/ t d ƒ ‚ n  | t j | | ƒ k  rW t d ƒ ‚ n  | rˆ t | ƒ | | d g k rˆ t d ƒ ‚ n  | | | | } | | } | rÚ t | ƒ | d k rÚ | d t | ƒ g } n  | d	 k rd | g | } d t | d  ƒ | d <n  g  } x7 t | ƒ D]) } | j t	 |  | | | | ƒ ƒ q%Wx2 t |  t | ƒ ƒ D] } | | | c d 7<qiWt j
 |  | f ƒ } t j
 |  d t j	 ƒ} t | | | ƒ j t ƒ } | d |	 9} | |	 8} |
 s| | j | d ƒ 9} | | j d | ƒ 9} n  | j |  | ƒ | d	 d	 … d	 | … f <d
 } x– t | ƒ D]ˆ \ } } | | | | } } | | | | | +| | | … d	 | … f } d | j | | ƒ d } t j | | ƒ | d <| | 7} qWW| d
 k rNd | j | | ƒ d } t j | d	 d	 … d	 | … f | ƒ | d	 d	 … | | | … f <n  | d
 k r¾| | } | d | j | ƒ d j t j ƒ } | d	 d	 … | f | d	 d	 … | | | … f <n  | d
 k rö| j |  | ƒ | d	 d	 … | d	 … f <n  | d k r9| j |  ƒ | k  }  | j | d |  j ƒ  ƒ| |  <n  | d	 k rcd | j | ƒ d |	 } n  | | 7} | d	 k r“d d | j | ƒ } n  | | 9} | r	t | | d | ƒ\ } } t j | ƒ } | j | ƒ | d	 d	 … | f | d	 d	 … d	 d	 … f <n  | | f S(   s  Generate a random n-class classification problem.

    This initially creates clusters of points normally distributed (std=1)
    about vertices of an ``n_informative``-dimensional hypercube with sides of
    length ``2*class_sep`` and assigns an equal number of clusters to each
    class. It introduces interdependence between these features and adds
    various types of further noise to the data.

    Without shuffling, ``X`` horizontally stacks features in the following
    order: the primary ``n_informative`` features, followed by ``n_redundant``
    linear combinations of the informative features, followed by ``n_repeated``
    duplicates, drawn randomly with replacement from the informative and
    redundant features. The remaining features are filled with random noise.
    Thus, without shuffling, all useful features are contained in the columns
    ``X[:, :n_informative + n_redundant + n_repeated]``.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=20)
        The total number of features. These comprise ``n_informative``
        informative features, ``n_redundant`` redundant features,
        ``n_repeated`` duplicated features and
        ``n_features-n_informative-n_redundant-n_repeated`` useless features
        drawn at random.

    n_informative : int, optional (default=2)
        The number of informative features. Each class is composed of a number
        of gaussian clusters each located around the vertices of a hypercube
        in a subspace of dimension ``n_informative``. For each cluster,
        informative features are drawn independently from  N(0, 1) and then
        randomly linearly combined within each cluster in order to add
        covariance. The clusters are then placed on the vertices of the
        hypercube.

    n_redundant : int, optional (default=2)
        The number of redundant features. These features are generated as
        random linear combinations of the informative features.

    n_repeated : int, optional (default=0)
        The number of duplicated features, drawn randomly from the informative
        and the redundant features.

    n_classes : int, optional (default=2)
        The number of classes (or labels) of the classification problem.

    n_clusters_per_class : int, optional (default=2)
        The number of clusters per class.

    weights : list of floats or None (default=None)
        The proportions of samples assigned to each class. If None, then
        classes are balanced. Note that if ``len(weights) == n_classes - 1``,
        then the last class weight is automatically inferred.
        More than ``n_samples`` samples may be returned if the sum of
        ``weights`` exceeds 1.

    flip_y : float, optional (default=0.01)
        The fraction of samples whose class are randomly exchanged. Larger
        values introduce noise in the labels and make the classification
        task harder.

    class_sep : float, optional (default=1.0)
        The factor multiplying the hypercube size.  Larger values spread
        out the clusters/classes and make the classification task easier.

    hypercube : boolean, optional (default=True)
        If True, the clusters are put on the vertices of a hypercube. If
        False, the clusters are put on the vertices of a random polytope.

    shift : float, array of shape [n_features] or None, optional (default=0.0)
        Shift features by the specified value. If None, then features
        are shifted by a random value drawn in [-class_sep, class_sep].

    scale : float, array of shape [n_features] or None, optional (default=1.0)
        Multiply features by the specified value. If None, then features
        are scaled by a random value drawn in [1, 100]. Note that scaling
        happens after shifting.

    shuffle : boolean, optional (default=True)
        Shuffle the samples and the features.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels for class membership of each sample.

    Notes
    -----
    The algorithm is adapted from Guyon [1] and was designed to generate
    the "Madelon" dataset.

    References
    ----------
    .. [1] I. Guyon, "Design of experiments for the NIPS 2003 variable
           selection benchmark", 2003.

    See also
    --------
    make_blobs: simplified variant
    make_multilabel_classification: unrelated generator for multilabel tasks
    si   Number of informative, redundant and repeated features must sum to less than the number of total featuressL   n_classes * n_clusters_per_class must be smaller or equal 2 ** n_informativei   s:   Weights specified but incompatible with number of classes.g      ð?iÿÿÿÿR
   i   Ni    .g      à?g        R   id   R	   (   R   t
   ValueErrorR   t   log2t   lent   sumt   Nonet   ranget   appendt   intt   zerosR   R   t   floatt   randt   randnt	   enumeratet   dott   intpR   t   util_shufflet   arangeR   (!   t	   n_samplest
   n_featurest   n_informativet   n_redundantt
   n_repeatedt	   n_classest   n_clusters_per_classt   weightst   flip_yt	   class_sept	   hypercubet   shiftt   scaleR   R	   t	   generatort	   n_uselesst
   n_clusterst   n_samples_per_clustert   kt   it   Xt   yt	   centroidst   stopt   centroidt   startt   X_kt   At   Bt   nt   indicest	   flip_mask(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_classification&   s|    v"
		
(E
'3,"

/i   i2   t   densec
            sí  t  |	 ƒ ‰ ˆ j | ƒ }
 |
 |
 j ƒ  :}
 t j |
 ƒ ‰ ˆ j ˆ | ƒ ‰ ˆ t j ˆ d d ƒ:‰ ‡  ‡ ‡ ‡ ‡ ‡ ‡ f d †  } t j d ƒ } t j d d g ƒ } g  } xP t |  ƒ D]B } | ƒ  \ } } | j | ƒ | j t	 | ƒ ƒ | j | ƒ q½ Wt j
 t	 | ƒ d t j ƒ} t j | | | f d |  ˆ f ƒ} | j ƒ  | sd| j ƒ  } n  | t d d f k r²t d	 | d k ƒ } | j t | ƒ g ƒ j | ƒ } n | t k	 rÍt d
 ƒ ‚ n  | rã| | |
 ˆ f S| | f S(   sÃ  Generate a random multilabel classification problem.

    For each sample, the generative process is:
        - pick the number of labels: n ~ Poisson(n_labels)
        - n times, choose a class c: c ~ Multinomial(theta)
        - pick the document length: k ~ Poisson(length)
        - k times, choose a word: w ~ Multinomial(theta_c)

    In the above process, rejection sampling is used to make sure that
    n is never zero or more than `n_classes`, and that the document length
    is never zero. Likewise, we reject classes which have already been chosen.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=20)
        The total number of features.

    n_classes : int, optional (default=5)
        The number of classes of the classification problem.

    n_labels : int, optional (default=2)
        The average number of labels per instance. More precisely, the number
        of labels per sample is drawn from a Poisson distribution with
        ``n_labels`` as its expected value, but samples are bounded (using
        rejection sampling) by ``n_classes``, and must be nonzero if
        ``allow_unlabeled`` is False.

    length : int, optional (default=50)
        The sum of the features (number of words if documents) is drawn from
        a Poisson distribution with this expected value.

    allow_unlabeled : bool, optional (default=True)
        If ``True``, some instances might not belong to any class.

    sparse : bool, optional (default=False)
        If ``True``, return a sparse feature matrix

        .. versionadded:: 0.17
           parameter to allow *sparse* output.

    return_indicator : 'dense' (default) | 'sparse' | False
        If ``dense`` return ``Y`` in the dense binary indicator format. If
        ``'sparse'`` return ``Y`` in the sparse binary indicator format.
        ``False`` returns a list of lists of labels.

    return_distributions : bool, optional (default=False)
        If ``True``, return the prior class probability and conditional
        probabilities of features given classes, from which the data was
        drawn.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The generated samples.

    Y : array or sparse CSR matrix of shape [n_samples, n_classes]
        The label sets.

    p_c : array, shape [n_classes]
        The probability of each class being drawn. Only returned if
        ``return_distributions=True``.

    p_w_c : array, shape [n_features, n_classes]
        The probability of each feature being drawn given each class.
        Only returned if ``return_distributions=True``.

    t   axisi    c             sa  ˆ j  \ }  } | d } x2 ˆ  r/ | d k s; | | k rM ˆ j ˆ ƒ } q Wt ƒ  } xH t | ƒ | k r¡ t j ˆ ˆ j | t | ƒ ƒ ƒ } | j | ƒ qZ Wt | ƒ } d } x | d k rÕ ˆ j ˆ ƒ } q· Wt | ƒ d k rˆ j	 ˆ d | ƒ} | | f Sˆ j
 | d d ƒj d d ƒ j ƒ  } | | d :} t j | ˆ j | ƒ ƒ } | | f S(   Ni   i    R   RK   iÿÿÿÿ(   t   shapet   poissont   setR   R   t   searchsortedR#   t   updatet   listR   t   takeR   t   cumsum(   t   _R/   t   y_sizeR>   t   ct   n_wordst   wordst   cumulative_p_w_sample(   t   allow_unlabeledt   cumulative_p_cR7   t   lengthR+   t   n_labelst   p_w_c(    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   sample_example\  s(    
"		
'R<   R
   RL   t   sparseRJ   t   sparse_outputs;   return_indicator must be either 'sparse', 'dense' or False.(   R   R#   R   R   RS   t   arrayR   t   extendR   R   t   onest   float64t   spt
   csr_matrixt   sum_duplicatest   toarrayt   TrueR   t   fitt	   transformR   R   (   R*   R+   R/   R]   R\   RZ   R`   t   return_indicatort   return_distributionsR	   t   p_cR_   t	   X_indicest   X_indptrt   YR<   RX   R>   t   X_dataR=   t   lb(    (   RZ   R[   R7   R\   R+   R]   R^   sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_multilabel_classification  s:    R!"
$ià.  c         C   su   t  | ƒ } |  d f } | j d | ƒ j | ƒ } | d j d d ƒ d k j t j ƒ } d | | d k <| | f S(	   s)  Generates data for binary classification used in
    Hastie et al. 2009, Example 10.2.

    The ten features are standard independent Gaussian and
    the target ``y`` is defined by::

      y[i] = 1 if np.sum(X[i] ** 2) > 9.34 else -1

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=12000)
        The number of samples.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 10]
        The input samples.

    y : array of shape [n_samples]
        The output values.

    References
    ----------
    .. [1] T. Hastie, R. Tibshirani and J. Friedman, "Elements of Statistical
           Learning Ed. 2", Springer, 2009.

    See also
    --------
    make_gaussian_quantiles: a generalization of this dataset approach
    i
   R   g       @RK   i   g®Gáz®"@g      ð¿g        (   R   t   normalR   R   R   R   Re   (   R*   R	   t   rsRL   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_hastie_10_2™  s    &(i
   i   g      à?c         C   s—  t  | | ƒ } t |
 ƒ } | d k r< | j |  | ƒ } n' t d |  d | d | d | d | ƒ } t j | | f ƒ } d | j | | ƒ | d | … d d … f <t j | | ƒ | } | d k rè | | j	 d	 | d
 | j
 ƒ 7} n  | r^t | | d | ƒ\ } } t j | ƒ } | j | ƒ | d d … | f | d d … d d … f <| | } n  t j | ƒ } |	 r‰| | t j | ƒ f S| | f Sd S(   s  Generate a random regression problem.

    The input set can either be well conditioned (by default) or have a low
    rank-fat tail singular profile. See :func:`make_low_rank_matrix` for
    more details.

    The output is generated by applying a (potentially biased) random linear
    regression model with `n_informative` nonzero regressors to the previously
    generated input and some gaussian centered noise with some adjustable
    scale.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=100)
        The number of features.

    n_informative : int, optional (default=10)
        The number of informative features, i.e., the number of features used
        to build the linear model used to generate the output.

    n_targets : int, optional (default=1)
        The number of regression targets, i.e., the dimension of the y output
        vector associated with a sample. By default, the output is a scalar.

    bias : float, optional (default=0.0)
        The bias term in the underlying linear model.

    effective_rank : int or None, optional (default=None)
        if not None:
            The approximate number of singular vectors required to explain most
            of the input data by linear combinations. Using this kind of
            singular spectrum in the input allows the generator to reproduce
            the correlations often observed in practice.
        if None:
            The input set is well conditioned, centered and gaussian with
            unit variance.

    tail_strength : float between 0.0 and 1.0, optional (default=0.5)
        The relative importance of the fat noisy tail of the singular values
        profile if `effective_rank` is not None.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise applied to the output.

    shuffle : boolean, optional (default=True)
        Shuffle the samples and the features.

    coef : boolean, optional (default=False)
        If True, the coefficients of the underlying linear model are returned.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The input samples.

    y : array of shape [n_samples] or [n_samples, n_targets]
        The output values.

    coef : array of shape [n_features] or [n_features, n_targets], optional
        The coefficient of the underlying linear model. It is returned only if
        coef is True.
    R*   R+   t   effective_rankt   tail_strengthR	   id   Ng        R6   R   (   t   minR   R   R$   t   make_low_rank_matrixR   R!   R#   R&   Rv   RL   R(   R)   R   t   squeeze(   R*   R+   R,   t	   n_targetst   biasRy   Rz   t   noiseR   t   coefR	   R7   R=   t   ground_truthR>   RG   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_regressionÉ  s2    L	 ",gš™™™™™é?c         C   s”  | d k s | d k  r' t  d ƒ ‚ n  |  d } |  | } t | ƒ } t j d d t j | d t ƒ} t j d d t j | d t ƒ}	 t j | ƒ }
 t j | ƒ } t j |	 ƒ | } t j |	 ƒ | } t j t j	 |
 | ƒ t j	 | | ƒ g ƒ j
 } t j t j | d t j ƒt j | d t j ƒg ƒ } | r\t | | d | ƒ\ } } n  | d
 k	 rŠ| | j d | d	 | j ƒ 7} n  | | f S(   s‡  Make a large circle containing a smaller circle in 2d.

    A simple toy dataset to visualize clustering and classification
    algorithms.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The total number of points generated. If odd, the inner circle will
        have one point more than the outer circle.

    shuffle : bool, optional (default=True)
        Whether to shuffle the samples.

    noise : double or None (default=None)
        Standard deviation of Gaussian noise added to the data.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset shuffling and noise.
        Pass an int for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    factor : 0 < double < 1 (default=.8)
        Scale factor between inner and outer circle.

    Returns
    -------
    X : array of shape [n_samples, 2]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels (0 or 1) for class membership of each sample.
    i   i    s#   'factor' has to be between 0 and 1.i   t   endpointR
   R	   R6   R   N(   R   R   R   t   linspacet   piR   t   cost   sint   vstackR   t   TR   R!   R'   Rd   R(   R   Rv   RL   (   R*   R   R€   R	   t   factort   n_samples_outt   n_samples_inR7   t   linspace_outt   linspace_int   outer_circ_xt   outer_circ_yt   inner_circ_xt   inner_circ_yR=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_circlesC  s(    &

"""c         C   su  |  d } |  | } t  | ƒ } t j t j d t j | ƒ ƒ } t j t j d t j | ƒ ƒ } d t j t j d t j | ƒ ƒ }	 d t j t j d t j | ƒ ƒ d }
 t j t j | |	 ƒ t j | |
 ƒ g ƒ j } t j	 t j
 | d t j ƒt j | d t j ƒg ƒ } | r=t | | d | ƒ\ } } n  | d	 k	 rk| | j d | d | j ƒ 7} n  | | f S(
   s¾  Make two interleaving half circles

    A simple toy dataset to visualize clustering and classification
    algorithms. Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The total number of points generated.

    shuffle : bool, optional (default=True)
        Whether to shuffle the samples.

    noise : double or None (default=None)
        Standard deviation of Gaussian noise added to the data.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset shuffling and noise.
        Pass an int for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 2]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels (0 or 1) for class membership of each sample.
    i   i    i   g      à?R
   R	   R6   R   N(   R   R   R‡   R…   R†   Rˆ   R‰   R   RŠ   R   R!   R'   Rd   R(   R   Rv   RL   (   R*   R   R€   R	   RŒ   R   R7   R   R‘   R’   R“   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt
   make_moons…  s     

!!%)"g      $Àg      $@c      
   C   s  t  | ƒ } t |  t j ƒ r | d k r3 d } n  t | t j ƒ rt | } | j | d | d d | | f ƒ} qdt | ƒ } | j d } | j d } nÇ t |  ƒ } | d k rÞ | j | d | d d | | f ƒ} n  y t | ƒ | k sù t	 ‚ WnN t
 k
 r"t d j | ƒ ƒ ‚ nB t	 k
 rJt d j |  | ƒ ƒ ‚ n Xt | ƒ } | j d } t | d ƒ r t | ƒ | k r t d j | | ƒ ƒ ‚ n  t | t j ƒ rÍt j t | ƒ | ƒ } n  g  }	 g  }
 t |  t ƒ rñ|  } nB t |  | ƒ g | } x( t |  | ƒ D] } | | c d 7<qWxi t t | | ƒ ƒ D]R \ } \ } } |	 j | j d	 | | d
 | d | | f ƒ ƒ |
 | g | 7}
 qIWt j |	 ƒ }	 t j |
 ƒ }
 | rt j |  ƒ } t j | ƒ } | j | ƒ |	 | }	 |
 | }
 n  |	 |
 f S(   sÐ  Generate isotropic Gaussian blobs for clustering.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int or array-like, optional (default=100)
        If int, it is the total number of points equally divided among
        clusters.
        If array-like, each element of the sequence indicates
        the number of samples per cluster.

    n_features : int, optional (default=2)
        The number of features for each sample.

    centers : int or array of shape [n_centers, n_features], optional
        (default=None)
        The number of centers to generate, or the fixed center locations.
        If n_samples is an int and centers is None, 3 centers are generated.
        If n_samples is array-like, centers must be
        either None or an array of length equal to the length of n_samples.

    cluster_std : float or sequence of floats, optional (default=1.0)
        The standard deviation of the clusters.

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

    shuffle : boolean, optional (default=True)
        Shuffle the samples.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels for cluster membership of each sample.

    Examples
    --------
    >>> from sklearn.datasets.samples_generator import make_blobs
    >>> X, y = make_blobs(n_samples=10, centers=3, n_features=2,
    ...                   random_state=0)
    >>> print(X.shape)
    (10, 2)
    >>> y
    array([0, 0, 1, 0, 2, 2, 2, 1, 1, 0])
    >>> X, y = make_blobs(n_samples=[3, 3, 4], centers=None, n_features=2,
    ...                   random_state=0)
    >>> print(X.shape)
    (10, 2)
    >>> y
    array([0, 1, 2, 0, 2, 2, 2, 1, 1, 0])

    See also
    --------
    make_classification: a more intricate variant
    i   i    i   R   s8   Parameter `centers` must be array-like. Got {!r} insteads`   Length of `n_samples` not consistent with number of centers. Got n_samples = {} and centers = {}t   __len__se   Length of `clusters_std` not consistent with number of centers. Got centers = {} and cluster_std = {}t   locR6   N(   R   t
   isinstancet   numberst   IntegralR   t   uniformR   RL   R   t   AssertionErrort	   TypeErrorR   t   formatt   hasattrt   RealR   t   fullt   IterableR    R   R%   t   zipR   Rv   t   concatenateRb   R   R)   R   (   R*   R+   t   centerst   cluster_stdt
   center_boxR   R	   R7   t	   n_centersR=   R>   t   n_samples_per_centerR<   RF   t   stdt   total_n_samplesRG   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt
   make_blobs¼  sd    C			!		(
c         C   sâ   | d k  r t  d ƒ ‚ n  t | ƒ } | j |  | ƒ } d t j t j | d d … d f | d d … d f ƒ d | d d … d f d	 d d | d d … d
 f d | d d … d f | | j |  ƒ } | | f S(   sM  Generate the "Friedman #1" regression problem

    This dataset is described in Friedman [1] and Breiman [2].

    Inputs `X` are independent features uniformly distributed on the interval
    [0, 1]. The output `y` is created according to the formula::

        y(X) = 10 * sin(pi * X[:, 0] * X[:, 1]) + 20 * (X[:, 2] - 0.5) ** 2 + 10 * X[:, 3] + 5 * X[:, 4] + noise * N(0, 1).

    Out of the `n_features` features, only 5 are actually used to compute
    `y`. The remaining features are independent of `y`.

    The number of features has to be >= 5.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=10)
        The number of features. Should be at least 5.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise applied to the output.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset noise. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The input samples.

    y : array of shape [n_samples]
        The output values.

    References
    ----------
    .. [1] J. Friedman, "Multivariate adaptive regression splines", The Annals
           of Statistics 19 (1), pages 1-67, 1991.

    .. [2] L. Breiman, "Bagging predictors", Machine Learning 24,
           pages 123-140, 1996.
    i   s!   n_features must be at least five.i
   Ni    i   i   i   g      à?i   i   (   R   R   R#   R   Rˆ   R†   R$   (   R*   R+   R€   R	   R7   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_friedman1J  s    2Ÿc         C   sI  t  | ƒ } | j |  d ƒ } | d d … d f c d 9<| d d … d f c d t j 9<| d d … d f c d t j 7<| d d … d f c d	 9<| d d … d f c d 7<| d d … d f d
 | d d … d f | d d … d
 f d | d d … d f | d d … d f d
 d | | j |  ƒ } | | f S(   s£  Generate the "Friedman #2" regression problem

    This dataset is described in Friedman [1] and Breiman [2].

    Inputs `X` are 4 independent features uniformly distributed on the
    intervals::

        0 <= X[:, 0] <= 100,
        40 * pi <= X[:, 1] <= 560 * pi,
        0 <= X[:, 2] <= 1,
        1 <= X[:, 3] <= 11.

    The output `y` is created according to the formula::

        y(X) = (X[:, 0] ** 2 + (X[:, 1] * X[:, 2]  - 1 / (X[:, 1] * X[:, 3])) ** 2) ** 0.5 + noise * N(0, 1).

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise applied to the output.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset noise. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 4]
        The input samples.

    y : array of shape [n_samples]
        The output values.

    References
    ----------
    .. [1] J. Friedman, "Multivariate adaptive regression splines", The Annals
           of Statistics 19 (1), pages 1-67, 1991.

    .. [2] L. Breiman, "Bagging predictors", Machine Learning 24,
           pages 123-140, 1996.
    i   Ni    id   i   i  i(   i   i
   i   g      à?(   R   R#   R   R†   R$   (   R*   R€   R	   R7   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_friedman2ˆ  s    1##\c         C   sF  t  | ƒ } | j |  d ƒ } | d d … d f c d 9<| d d … d f c d t j 9<| d d … d f c d t j 7<| d d … d f c d	 9<| d d … d f c d 7<t j | d d … d f | d d … d
 f d | d d … d f | d d … d f | d d … d f ƒ | | j |  ƒ } | | f S(   s—  Generate the "Friedman #3" regression problem

    This dataset is described in Friedman [1] and Breiman [2].

    Inputs `X` are 4 independent features uniformly distributed on the
    intervals::

        0 <= X[:, 0] <= 100,
        40 * pi <= X[:, 1] <= 560 * pi,
        0 <= X[:, 2] <= 1,
        1 <= X[:, 3] <= 11.

    The output `y` is created according to the formula::

        y(X) = arctan((X[:, 1] * X[:, 2] - 1 / (X[:, 1] * X[:, 3])) / X[:, 0]) + noise * N(0, 1).

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise applied to the output.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset noise. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 4]
        The input samples.

    y : array of shape [n_samples]
        The output values.

    References
    ----------
    .. [1] J. Friedman, "Multivariate adaptive regression splines", The Annals
           of Statistics 19 (1), pages 1-67, 1991.

    .. [2] L. Breiman, "Bagging predictors", Machine Learning 24,
           pages 123-140, 1996.
    i   Ni    id   i   i  i(   i   i
   i   (   R   R#   R   R†   t   arctanR$   (   R*   R€   R	   R7   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_friedman3É  s    1##pc         C   sõ   t  | ƒ } t |  | ƒ } t j | j |  | ƒ d d ƒ\ } } t j | j | | ƒ d d ƒ\ }	 } t j | d t j ƒ}
 d | t j d |
 | d ƒ } | t j d |
 | ƒ } t j	 | ƒ | | } t j
 t j
 | | ƒ |	 j ƒ S(   sÝ  Generate a mostly low rank matrix with bell-shaped singular values

    Most of the variance can be explained by a bell-shaped curve of width
    effective_rank: the low rank part of the singular values profile is::

        (1 - tail_strength) * exp(-1.0 * (i / effective_rank) ** 2)

    The remaining singular values' tail is fat, decreasing as::

        tail_strength * exp(-0.1 * i / effective_rank).

    The low rank part of the profile can be considered the structured
    signal part of the data while the tail can be considered the noisy
    part of the data that cannot be summarized by a low number of linear
    components (singular vectors).

    This kind of singular profiles is often seen in practice, for instance:
     - gray level pictures of faces
     - TF-IDF vectors of text documents crawled from the web

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=100)
        The number of features.

    effective_rank : int, optional (default=10)
        The approximate number of singular vectors required to explain most of
        the data by linear combinations.

    tail_strength : float between 0.0 and 1.0, optional (default=0.5)
        The relative importance of the fat noisy tail of the singular values
        profile.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The matrix.
    t   modet   economicR
   i   g      ð¿i   gš™™™™™¹¿(   R   R{   R    t   qrR$   R   R)   Re   t   expt   identityR&   RŠ   (   R*   R+   Ry   Rz   R	   R7   RF   t   uRT   t   vt   singular_indt   low_rankt   tailt   s(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyR|   	  s    2''c         C   sÚ   t  | ƒ } | j | | ƒ } | t j t j | d d d ƒƒ :} t j | |  f ƒ } xS t |  ƒ D]E } t j | ƒ }	 | j |	 ƒ |	 |  }	 | j | ƒ | |	 | f <qf Wt j	 | | ƒ }
 t
 t j |
 | | f ƒ S(   s  Generate a signal as a sparse combination of dictionary elements.

    Returns a matrix Y = DX, such as D is (n_features, n_components),
    X is (n_components, n_samples) and each column of X has exactly
    n_nonzero_coefs non-zero elements.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int
        number of samples to generate

    n_components :  int,
        number of components in the dictionary

    n_features : int
        number of features of the dataset to generate

    n_nonzero_coefs : int
        number of active (non-zero) coefficients in each sample

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    data : array of shape [n_features, n_samples]
        The encoded signal (Y).

    dictionary : array of shape [n_features, n_components]
        The dictionary with normalized components (D).

    code : array of shape [n_components, n_samples]
        The sparse code such that each column of this matrix has exactly
        n_nonzero_coefs non-zero items (X).

    i   RK   i    (   R   R$   R   t   sqrtR   R!   R   R)   R   R&   t   mapR}   (   R*   t   n_componentsR+   t   n_nonzero_coefsR	   R7   t   DR=   R<   t   idxRr   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_sparse_coded_signalN  s    *&
c         C   s³   t  | ƒ } | j d d d d d |  | f ƒ } | j d | d d … d f d | d d … d f d | d d … d f d | d d … d	 f d t j |  ƒ ƒ } | | f S(
   s«  Generate a random regression problem with sparse uncorrelated design

    This dataset is described in Celeux et al [1]. as::

        X ~ N(0, 1)
        y(X) = X[:, 0] + 2 * X[:, 1] - 2 * X[:, 2] - 1.5 * X[:, 3]

    Only the first 4 features are informative. The remaining features are
    useless.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of samples.

    n_features : int, optional (default=10)
        The number of features.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The input samples.

    y : array of shape [n_samples]
        The output values.

    References
    ----------
    .. [1] G. Celeux, M. El Anbari, J.-M. Marin, C. P. Robert,
           "Regularization in regression: comparing Bayesian and frequentist
           methods in a poorly informative situation", 2009.
    R—   i    R6   i   R   Ni   g      ø?i   (   R   Rv   R   Rd   (   R*   R+   R	   R7   R=   R>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_sparse_uncorrelatedŒ  s    ($	C-c         C   s}   t  | ƒ } | j |  |  ƒ } t j t j | j | ƒ ƒ \ } } } t j t j | d t j | j |  ƒ ƒ ƒ | ƒ } | S(   sm  Generate a random symmetric, positive-definite matrix.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_dim : int
        The matrix dimension.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_dim, n_dim]
        The random symmetric, positive-definite matrix.

    See also
    --------
    make_sparse_spd_matrix
    g      ð?(   R   R#   R    t   svdR   R&   RŠ   t   diag(   t   n_dimR	   R7   RD   t   UR»   t   VR=   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_spd_matrix¿  s
    '4gffffffî?gš™™™™™¹?gÍÌÌÌÌÌì?c         C   s  t  | ƒ } t j |  ƒ } | j |  |  ƒ } d | | | k  <| | | | j t j | | k ƒ ƒ | | | k <t j | d d ƒ} | j |  ƒ } | | j | } | | 7} t j | j | ƒ }	 | rt j	 |	 ƒ j
 d |	 j d ƒ }
 d t j |
 ƒ }
 |	 |
 9}	 |	 |
 j 9}	 n  |	 S(   s_  Generate a sparse symmetric definite positive matrix.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    dim : integer, optional (default=1)
        The size of the random matrix to generate.

    alpha : float between 0 and 1, optional (default=0.95)
        The probability that a coefficient is zero (see notes). Larger values
        enforce more sparsity.

    norm_diag : boolean, optional (default=False)
        Whether to normalize the output matrix to make the leading diagonal
        elements all 1

    smallest_coef : float between 0 and 1, optional (default=0.1)
        The value of the smallest coefficient.

    largest_coef : float between 0 and 1, optional (default=0.9)
        The value of the largest coefficient.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    prec : sparse matrix of shape (dim, dim)
        The generated matrix.

    Notes
    -----
    The sparsity is actually imposed on the cholesky factor of the matrix.
    Thus alpha does not translate directly into the filling fraction of
    the matrix itself.

    See also
    --------
    make_spd_matrix
    i    R;   iÿÿÿÿi   g      ð?(   R   R   t   eyeR#   R   t   trilt   permutationRŠ   R&   RÅ   R   RL   R¼   (   t   dimt   alphat	   norm_diagt   smallest_coeft   largest_coefR	   t   cholt   auxRÌ   t   prect   d(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_sparse_spd_matrixà  s$    .*
"
c   	      C   sÁ   t  | ƒ } d t j d d | j d |  ƒ } | t j | ƒ } d | j d |  ƒ } | t j | ƒ } t j | | | f ƒ } | | | j d |  ƒ 7} | j } t j	 | ƒ } | | f S(   s1  Generate a swiss roll dataset.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of sample points on the S curve.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 3]
        The points.

    t : array of shape [n_samples]
        The univariate position of the sample according to the main dimension
        of the points in the manifold.

    Notes
    -----
    The algorithm is from Marsland [1].

    References
    ----------
    .. [1] S. Marsland, "Machine Learning: An Algorithmic Perspective",
           Chapter 10, 2009.
           http://seat.massey.ac.nz/personal/s.r.marsland/Code/10/lle.py
    g      ø?i   i   i   i   (
   R   R   R†   R#   R‡   Rˆ   R¤   R$   RŠ   R}   (	   R*   R€   R	   R7   t   tt   xR>   t   zR=   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_swiss_roll*  s    %%	c   	      C   sÆ   t  | ƒ } d t j | j d |  ƒ d } t j | ƒ } d | j d |  ƒ } t j | ƒ t j | ƒ d } t j | | | f ƒ } | | | j d |  ƒ 7} | j	 } t j
 | ƒ } | | f S(   s%  Generate an S curve dataset.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    n_samples : int, optional (default=100)
        The number of sample points on the S curve.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, 3]
        The points.

    t : array of shape [n_samples]
        The univariate position of the sample according to the main dimension
        of the points in the manifold.
    i   i   g      à?g       @(   R   R   R†   R#   Rˆ   t   signR‡   R¤   R$   RŠ   R}   (	   R*   R€   R	   R7   R×   RØ   R>   RÙ   R=   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_s_curve^  s    ! 	i   c         C   sB  | | k  r t  d ƒ ‚ n  t | ƒ } |  d k rE t j | ƒ }  n t j |  ƒ }  | j |  | t j | ƒ | f ƒ } t j t j	 | |  t j
 d d … f d d d ƒƒ }	 | |	 d d … f } | | }
 t j t j t j | ƒ |
 ƒ t j | d | |
 | ƒ g ƒ } | r8t | | d | ƒ\ } } n  | | f S(   s  Generate isotropic Gaussian and label samples by quantile

    This classification dataset is constructed by taking a multi-dimensional
    standard normal distribution and defining classes separated by nested
    concentric multi-dimensional spheres such that roughly equal numbers of
    samples are in each class (quantiles of the :math:`\chi^2` distribution).

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    mean : array of shape [n_features], optional (default=None)
        The mean of the multi-dimensional normal distribution.
        If None then use the origin (0, 0, ...).

    cov : float, optional (default=1.)
        The covariance matrix will be this value times the unit matrix. This
        dataset only produces symmetric normal distributions.

    n_samples : int, optional (default=100)
        The total number of points equally divided among classes.

    n_features : int, optional (default=2)
        The number of features for each sample.

    n_classes : int, optional (default=3)
        The number of classes

    shuffle : boolean, optional (default=True)
        Shuffle the samples.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape [n_samples, n_features]
        The generated samples.

    y : array of shape [n_samples]
        The integer labels for quantile membership of each sample.

    Notes
    -----
    The dataset is from Zhu et al [1].

    References
    ----------
    .. [1] J. Zhu, H. Zou, S. Rosset, T. Hastie, "Multi-class AdaBoost", 2009.

    s$   n_samples must be at least n_classesNi   RK   i   R	   (   R   R   R   R   R!   Rb   t   multivariate_normalRµ   t   argsortR   t   newaxisR   t   repeatR)   R(   (   t   meant   covR*   R+   R/   R   R	   R7   R=   RÁ   t   stepR>   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_gaussian_quantilesˆ  s     89
$c         C   s`   t  | ƒ } |  j \ } } | j | ƒ } | j | ƒ } |  | d  d  … | f } | | | f S(   N(   R   RL   RÌ   (   t   dataR	   R7   t   n_rowst   n_colst   row_idxt   col_idxt   result(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   _shuffleÞ  s    c         C   sú  t  | ƒ } |  \ } }	 | j | | | ƒ }
 | j | t j d | | ƒ ƒ } | j |	 t j d | | ƒ ƒ } t j t d „  t t | ƒ | ƒ Dƒ ƒ ƒ } t j t d „  t t | ƒ | ƒ Dƒ ƒ ƒ } t j	 |  d t j
 ƒ} xF t | ƒ D]8 } t j | | k | | k ƒ } | | c |
 | 7<qò W| d k r\| | j d | d | j ƒ 7} n  | r‘t | | ƒ \ } } } | | } | | } n  t j g  t | ƒ D] } | | k ^ q¤ƒ } t j g  t | ƒ D] } | | k ^ qÒƒ } | | | f S(   s  Generate an array with constant block diagonal structure for
    biclustering.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    shape : iterable (n_rows, n_cols)
        The shape of the result.

    n_clusters : integer
        The number of biclusters.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise.

    minval : int, optional (default=10)
        Minimum value of a bicluster.

    maxval : int, optional (default=100)
        Maximum value of a bicluster.

    shuffle : boolean, optional (default=True)
        Shuffle the samples.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape `shape`
        The generated array.

    rows : array of shape (n_clusters, X.shape[0],)
        The indicators for cluster membership of each row.

    cols : array of shape (n_clusters, X.shape[1],)
        The indicators for cluster membership of each column.

    References
    ----------

    .. [1] Dhillon, I. S. (2001, August). Co-clustering documents and
        words using bipartite spectral graph partitioning. In Proceedings
        of the seventh ACM SIGKDD international conference on Knowledge
        discovery and data mining (pp. 269-274). ACM.

    See also
    --------
    make_checkerboard
    g      ð?c         s   s'   |  ] \ } } t  j | | ƒ Vq d  S(   N(   R   Rà   (   t   .0t   valt   rep(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pys	   <genexpr>*  s    c         s   s'   |  ] \ } } t  j | | ƒ Vq d  S(   N(   R   Rà   (   Rì   Rí   Rî   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pys	   <genexpr>,  s    R
   i    R6   R   (   R   R›   t   multinomialR   Rà   R   RQ   R£   R   R!   Re   t   outerRv   RL   Rë   R‰   (   RL   R9   R€   t   minvalt   maxvalR   R	   R7   Ræ   Rç   t   constst	   row_sizest	   col_sizest
   row_labelst
   col_labelsRê   R<   t   selectorRè   Ré   RV   t   rowst   cols(    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_biclustersç  s4    7		"
..c         C   sR  t  | ƒ } t | d ƒ r* | \ } }	 n
 | } }	 |  \ }
 } | j |
 t j d | | ƒ ƒ } | j | t j d |	 |	 ƒ ƒ } t j t d „  t t | ƒ | ƒ Dƒ ƒ ƒ } t j t d „  t t |	 ƒ | ƒ Dƒ ƒ ƒ } t j	 |  d t j
 ƒ} xe t | ƒ D]W } xN t |	 ƒ D]@ } t j | | k | | k ƒ } | | c | j | | ƒ 7<qWqW| d k rŽ| | j d | d | j ƒ 7} n  | rÃt | | ƒ \ } } } | | } | | } n  t j g  t | ƒ D]% } t |	 ƒ D] } | | k ^ qæqÖƒ } t j g  t | ƒ D]% } t |	 ƒ D] } | | k ^ q'qƒ } | | | f S(	   sÿ  Generate an array with block checkerboard structure for
    biclustering.

    Read more in the :ref:`User Guide <sample_generators>`.

    Parameters
    ----------
    shape : iterable (n_rows, n_cols)
        The shape of the result.

    n_clusters : integer or iterable (n_row_clusters, n_column_clusters)
        The number of row and column clusters.

    noise : float, optional (default=0.0)
        The standard deviation of the gaussian noise.

    minval : int, optional (default=10)
        Minimum value of a bicluster.

    maxval : int, optional (default=100)
        Maximum value of a bicluster.

    shuffle : boolean, optional (default=True)
        Shuffle the samples.

    random_state : int, RandomState instance or None (default)
        Determines random number generation for dataset creation. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    X : array of shape `shape`
        The generated array.

    rows : array of shape (n_clusters, X.shape[0],)
        The indicators for cluster membership of each row.

    cols : array of shape (n_clusters, X.shape[1],)
        The indicators for cluster membership of each column.


    References
    ----------

    .. [1] Kluger, Y., Basri, R., Chang, J. T., & Gerstein, M. (2003).
        Spectral biclustering of microarray data: coclustering genes
        and conditions. Genome research, 13(4), 703-716.

    See also
    --------
    make_biclusters
    R–   g      ð?c         s   s'   |  ] \ } } t  j | | ƒ Vq d  S(   N(   R   Rà   (   Rì   Rí   Rî   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pys	   <genexpr>‰  s    c         s   s'   |  ] \ } } t  j | | ƒ Vq d  S(   N(   R   Rà   (   Rì   Rí   Rî   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pys	   <genexpr>‹  s    R
   i    R6   R   (   R   RŸ   Rï   R   Rà   R   RQ   R£   R   R!   Re   Rð   R›   Rv   RL   Rë   R‰   (   RL   R9   R€   Rñ   Rò   R   R	   R7   t   n_row_clusterst   n_col_clustersRæ   Rç   Rô   Rõ   Rö   R÷   Rê   R<   t   jRø   Rè   Ré   t   labelRT   Rù   Rú   (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   make_checkerboardB  sB    7
		$"
	(	((   g      $Àg      $@(4   t   __doc__R™   Rb   t   numpyR   t   scipyR    t   scipy.sparseR`   Rf   t   preprocessingR   t   utilsR   R   R   R(   t   utils.fixesR   R¢   t   utils.randomR   t	   externalsR   t   movesR½   R£   R   R   Rj   RI   R   Ru   Rx   Rƒ   R”   R•   R¬   R­   R®   R°   R|   RÂ   RÃ   RÉ   RÖ   RÚ   RÜ   Rä   Rë   Rû   R   (    (    (    sA   lib/python2.7/site-packages/sklearn/datasets/samples_generator.pyt   <module>   sn   				Ù		’0		wA7>A@	E=3!	H4*	T	Z