    def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash']     def assert_in(x, container):
    def assert_not_in(x, container):
    def assert_raises_regex(expected_exception, expected_regexp,
                            callable_obj=None, *args, **kwargs):
def _assert_less(a, b, msg=None):
def _assert_greater(a, b, msg=None):
def assert_less_equal(a, b, msg=None):
def assert_greater_equal(a, b, msg=None):
def assert_warns(warning_class, func, *args, **kw):
def assert_warns_message(warning_class, message, func, *args, **kw):
def assert_no_warnings(func, *args, **kw):
def ignore_warnings(obj=None):
def _ignore_warnings(fn):
    def wrapper(*args, **kwargs):
    def __init__(self):
    def __repr__(self):
    def __enter__(self):
            def showwarning(*args, **kwargs):
    def __exit__(self, *exc_info):
def _assert_allclose(actual, desired, rtol=1e-7, atol=0,
                     err_msg='', verbose=True):
def assert_raise_message(exception, message, function, *args, **kwargs):
def fake_mldata(columns_dict, dataname, matfile, ordering=None):
    def __init__(self, mock_datasets):
    def __call__(self, urlname):
def install_mldata_mock(mock_datasets):
def uninstall_mldata_mock():
def all_estimators(include_meta_estimators=False, include_other=False,
                   type_filter=None, include_dont_test=False):
    def is_abstract(c):
def set_random_state(estimator, random_state=0):
def if_matplotlib(func):
    def run_test(*args, **kwargs):
def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    def decorator(func):
            def func(*args, **kwargs):
def clean_warning_registry():
def check_skip_network():
def check_skip_travis():
class _IgnoreWarnings(object):
class mock_mldata_urlopen(object):
META_ESTIMATORS = ["OneVsOneClassifier",
                   "OutputCodeClassifier", "OneVsRestClassifier", "RFE",
                   "RFECV", "BaseEnsemble"]
OTHER = ["Pipeline", "FeatureUnion", "GridSearchCV", "RandomizedSearchCV"]
DONT_TEST = ['SparseCoder', 'EllipticEnvelope', 'DictVectorizer',
             'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer',
             'TfidfTransformer', 'IsotonicRegression', 'OneHotEncoder',
             'RandomTreesEmbedding', 'FeatureHasher', 'DummyClassifier',
             'DummyRegressor', 'TruncatedSVD', 'PolynomialFeatures',
             'GaussianRandomProjectionHash'] def assert_warns(warning_class, func, *args, **kw):
    """Test that a certain warning occurs.

    Parameters
    ----------
    warning_class : the warning class
        The class to test for, e.g. UserWarning.

    func : callable
        Calable object to trigger warnings.

    *args : the positional arguments to `func`.

    **kw : the keyword arguments to `func`

    Returns
    -------

    result : the return value of `func`

    """

    # very important to avoid uncontrolled state propagation
    clean_warning_registry()
    with warnings.catch_warnings(record=True) as w:
        # Cause all warnings to always be triggered.
        warnings.simplefilter("always")
        # Trigger a warning.
        result = func(*args, **kw)
        if hasattr(np, 'VisibleDeprecationWarning'):
            # Filter out numpy-specific warnings in numpy >= 1.9
            w = [e for e in w
                 if e.category is not np.VisibleDeprecationWarning]

        # Verify some things
        if not len(w) > 0:
            raise AssertionError("No warning raised when calling %s"
                                 % func.__name__)

        found = any(warning.category is warning_class for warning in w)
        if not found:
            raise AssertionError("%s did not give warning: %s( is %s)"
                                 % (func.__name__, warning_class, w))
    return result def if_not_mac_os(versions=('10.7', '10.8', '10.9'),
                  message='Multi-process bug in Mac OS X >= 10.7 '
                          '(see issue #636)'):
    """Test decorator that skips test if OS is Mac OS X and its
    major version is one of ``versions``.
    """
    mac_version, _, _ = platform.mac_ver()
    skip = '.'.join(mac_version.split('.')[:2]) in versions

    def decorator(func):
        if skip:
            @wraps(func)
            def func(*args, **kwargs):
                raise SkipTest(message)
        return func
    return decorator
import sys
import numpy as np
from scipy import sparse as sp
from sklearn.utils.testing import assert_equal
from sklearn.utils.testing import assert_array_equal
from sklearn.utils.testing import assert_array_almost_equal
from sklearn.utils.testing import SkipTest
from sklearn.utils.testing import assert_almost_equal
from sklearn.utils.testing import assert_raises
from sklearn.utils.testing import assert_raises_regexp
from sklearn.utils.testing import assert_true
from sklearn.utils.testing import assert_greater
from sklearn.utils.testing import assert_less
from sklearn.utils.testing import assert_warns
from sklearn.utils.testing import if_not_mac_os
from sklearn.utils.extmath import row_norms
from sklearn.metrics.cluster import v_measure_score
from sklearn.cluster import KMeans, k_means
from sklearn.cluster import MiniBatchKMeans
from sklearn.cluster.k_means_ import _labels_inertia
from sklearn.cluster.k_means_ import _mini_batch_step
from sklearn.datasets.samples_generator import make_blobs
from sklearn.externals.six.moves import cStringIO as StringIO
    from numpy.distutils.system_info import get_info
    km = KMeans(init=array_init, n_clusters=3, random_state=42, n_init=1)
    km.fit(my_X)

    # centers must not been collapsed
    assert_equal(len(np.unique(km.labels_)), 3)

    centers = km.cluster_centers_
    assert_true(np.linalg.norm(centers[0] - centers[1]) >= 0.1)
    assert_true(np.linalg.norm(centers[0] - centers[2]) >= 0.1)
    assert_true(np.linalg.norm(centers[1] - centers[2]) >= 0.1)


def test_predict():
    km = KMeans(n_clusters=n_clusters, random_state=42)

    km.fit(X)

    # sanity check: predict centroid labels
    pred = km.predict(km.cluster_centers_)
    assert_array_equal(pred, np.arange(n_clusters))

    # sanity check: re-predict labeling for training set samples
    pred = km.predict(X)
    assert_array_equal(pred, km.labels_)

    # re-predict labels for training set using fit_predict
    pred = km.fit_predict(X)
    assert_array_equal(pred, km.labels_)


def test_score():
    km1 = KMeans(n_clusters=n_clusters, max_iter=1, random_state=42)
    s1 = km1.fit(X).score(X)
    km2 = KMeans(n_clusters=n_clusters, max_iter=10, random_state=42)
    s2 = km2.fit(X).score(X)
    assert_greater(s2, s1)


def test_predict_minibatch_dense_input():
    mb_k_means = MiniBatchKMeans(n_clusters=n_clusters, random_state=40).fit(X)

    # sanity check: predict centroid labels
    pred = mb_k_means.predict(mb_k_means.cluster_centers_)
    assert_array_equal(pred, np.arange(n_clusters))

    # sanity check: re-predict labeling for training set samples
    pred = mb_k_means.predict(X)
    assert_array_equal(mb_k_means.predict(X), mb_k_means.labels_)


def test_predict_minibatch_kmeanspp_init_sparse_input():
    mb_k_means = MiniBatchKMeans(n_clusters=n_clusters, init='k-means++',
                                 n_init=10).fit(X_csr)

    # sanity check: re-predict labeling for training set samples
    assert_array_equal(mb_k_means.predict(X_csr), mb_k_means.labels_)

    # sanity check: predict centroid labels
    pred = mb_k_means.predict(mb_k_means.cluster_centers_)
    assert_array_equal(pred, np.arange(n_clusters))

    # check that models trained on sparse input also works for dense input at
    # predict time
    assert_array_equal(mb_k_means.predict(X), mb_k_means.labels_)


def test_predict_minibatch_random_init_sparse_input():
    mb_k_means = MiniBatchKMeans(n_clusters=n_clusters, init='random',
                                 n_init=10).fit(X_csr)

    # sanity check: re-predict labeling for training set samples
    assert_array_equal(mb_k_means.predict(X_csr), mb_k_means.labels_)

    # sanity check: predict centroid labels
    pred = mb_k_means.predict(mb_k_means.cluster_centers_)
    assert_array_equal(pred, np.arange(n_clusters))

    # check that models trained on sparse input also works for dense input at
    # predict time
    assert_array_equal(mb_k_means.predict(X), mb_k_means.labels_)


def test_input_dtypes():
    X_list = [[0, 0], [10, 10], [12, 9], [-1, 1], [2, 0], [8, 10]]
    X_int = np.array(X_list, dtype=np.int32)
    X_int_csr = sp.csr_matrix(X_int)
    init_int = X_int[:2]

    fitted_models = [
        KMeans(n_clusters=2).fit(X_list),
        KMeans(n_clusters=2).fit(X_int),
        KMeans(n_clusters=2, init=init_int, n_init=1).fit(X_list),
        KMeans(n_clusters=2, init=init_int, n_init=1).fit(X_int),
        # mini batch kmeans is very unstable on such a small dataset hence
        # we use many inits
        MiniBatchKMeans(n_clusters=2, n_init=10, batch_size=2).fit(X_list),
        MiniBatchKMeans(n_clusters=2, n_init=10, batch_size=2).fit(X_int),
        MiniBatchKMeans(n_clusters=2, n_init=10, batch_size=2).fit(X_int_csr),
        MiniBatchKMeans(n_clusters=2, batch_size=2,
                        init=init_int, n_init=1).fit(X_list),
        MiniBatchKMeans(n_clusters=2, batch_size=2,
                        init=init_int, n_init=1).fit(X_int),
        MiniBatchKMeans(n_clusters=2, batch_size=2,
                        init=init_int, n_init=1).fit(X_int_csr),
    ]
    expected_labels = [0, 1, 1, 0, 0, 1]
    scores = np.array([v_measure_score(expected_labels, km.labels_)
                       for km in fitted_models])
    assert_array_equal(scores, np.ones(scores.shape[0]))


def test_transform():
    km = KMeans(n_clusters=n_clusters)
    km.fit(X)
    X_new = km.transform(km.cluster_centers_)

    for c in range(n_clusters):
        assert_equal(X_new[c, c], 0)
        for c2 in range(n_clusters):
            if c != c2:

                assert_greater(X_new[c, c2], 0)