    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
"""Testing for K-means"""





# non centered, sparse centers to check the
centers = np.array([
    [0.0, 5.0, 0.0, 0.0, 0.0],
    [1.0, 1.0, 4.0, 0.0, 0.0],
    [1.0, 0.0, 0.0, 5.0, 1.0],
])
n_samples = 100
n_clusters, n_features = centers.shape
X, true_labels = make_blobs(n_samples=n_samples, centers=centers,
                            cluster_std=1., random_state=42)
X_csr = sp.csr_matrix(X)


def test_kmeans_dtype():
    rnd = np.random.RandomState(0)
    X = rnd.normal(size=(40, 2))
    X = (X * 10).astype(np.uint8)
    km = KMeans(n_init=1).fit(X)
    pred_x = assert_warns(RuntimeWarning, km.predict, X)
    assert_array_equal(km.labels_, pred_x)


def test_labels_assignment_and_inertia():
    # pure numpy implementation as easily auditable reference gold
    # implementation
    rng = np.random.RandomState(42)
    noisy_centers = centers + rng.normal(size=centers.shape)
    labels_gold = - np.ones(n_samples, dtype=np.int)
    mindist = np.empty(n_samples)
    mindist.fill(np.infty)
    for center_id in range(n_clusters):
        dist = np.sum((X - noisy_centers[center_id]) ** 2, axis=1)
        labels_gold[dist < mindist] = center_id
        mindist = np.minimum(dist, mindist)
    inertia_gold = mindist.sum()
    assert_true((mindist >= 0.0).all())
    assert_true((labels_gold != -1).all())

    # perform label assignment using the dense array input
    x_squared_norms = (X ** 2).sum(axis=1)
    labels_array, inertia_array = _labels_inertia(
        X, x_squared_norms, noisy_centers)
    assert_array_almost_equal(inertia_array, inertia_gold)
    assert_array_equal(labels_array, labels_gold)

    # perform label assignment using the sparse CSR input
    x_squared_norms_from_csr = row_norms(X_csr, squared=True)
    labels_csr, inertia_csr = _labels_inertia(
        X_csr, x_squared_norms_from_csr, noisy_centers)
    assert_array_almost_equal(inertia_csr, inertia_gold)
    assert_array_equal(labels_csr, labels_gold)


def test_minibatch_update_consistency():
    """Check that dense and sparse minibatch update give the same results"""
    rng = np.random.RandomState(42)
    old_centers = centers + rng.normal(size=centers.shape)

    new_centers = old_centers.copy()
    new_centers_csr = old_centers.copy()

    counts = np.zeros(new_centers.shape[0], dtype=np.int32)
    counts_csr = np.zeros(new_centers.shape[0], dtype=np.int32)

    x_squared_norms = (X ** 2).sum(axis=1)
    x_squared_norms_csr = row_norms(X_csr, squared=True)

    buffer = np.zeros(centers.shape[1], dtype=np.double)
    buffer_csr = np.zeros(centers.shape[1], dtype=np.double)

    # extract a small minibatch
    X_mb = X[:10]
    X_mb_csr = X_csr[:10]
    x_mb_squared_norms = x_squared_norms[:10]
    x_mb_squared_norms_csr = x_squared_norms_csr[:10]

    # step 1: compute the dense minibatch update
    old_inertia, incremental_diff = _mini_batch_step(
        X_mb, x_mb_squared_norms, new_centers, counts,
        buffer, 1, None, random_reassign=False)
    assert_greater(old_inertia, 0.0)

    # compute the new inertia on the same batch to check that it decreased
    labels, new_inertia = _labels_inertia(
        X_mb, x_mb_squared_norms, new_centers)
    assert_greater(new_inertia, 0.0)
    assert_less(new_inertia, old_inertia)

    # check that the incremental difference computation is matching the
    # final observed value
    effective_diff = np.sum((new_centers - old_centers) ** 2)
    assert_almost_equal(incremental_diff, effective_diff)

    # step 2: compute the sparse minibatch update
    old_inertia_csr, incremental_diff_csr = _mini_batch_step(
        X_mb_csr, x_mb_squared_norms_csr, new_centers_csr, counts_csr,
        buffer_csr, 1, None, random_reassign=False)
    assert_greater(old_inertia_csr, 0.0)

    # compute the new inertia on the same batch to check that it decreased
    labels_csr, new_inertia_csr = _labels_inertia(
        X_mb_csr, x_mb_squared_norms_csr, new_centers_csr)
    assert_greater(new_inertia_csr, 0.0)

    assert_less(new_inertia_csr, old_inertia_csr)