We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove visualizer tests in type checking
Many of the type checking utilities, e.g. `is_classifier`, `is_regressor`, etc. have a note to remove lines of code that are unnecessary after #90 is implemented. 

For example see: [yellowbrick/utils/types.py#L64](https://github.com/DistrictDataLabs/yellowbrick/blob/develop/yellowbrick/utils/types.py#L64):

```python
def is_classifier(estimator):
    """
    Returns True if the given estimator is (probably) a classifier.

    Parameters
    ----------
    estimator : class or instance
        The object to test if it is a Scikit-Learn clusterer, especially a
        Scikit-Learn estimator or Yellowbrick visualizer

    See also
    --------
    is_classifier
        `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_
    """
    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
    # wrappers as in Issue #90, these three lines become unnecessary.
    # NOTE: This must be imported here to avoid recursive import.
    from yellowbrick.base import Visualizer
    if isinstance(estimator, Visualizer):
        return is_classifier(estimator.estimator)

    # Test the _estimator_type property
    return getattr(estimator, "_estimator_type", None) == "classifier"

# Alias for closer name to isinstance and issubclass
isclassifier = is_classifier
```

We should remove these lines of code and **ensure the tests have correct coverage**. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yellowbrick/utils/types.py`
Content:
```
1 # yellowbrick.utils.types
2 # Detection utilities for Scikit-Learn and Numpy types for flexibility
3 #
4 # Author:   Benjamin Bengfort <bbengfort@districtdatalabs.com>
5 # Created:  Fri May 19 10:51:13 2017 -0700
6 #
7 # Copyright (C) 2017 District Data Labs
8 # For license information, see LICENSE.txt
9 #
10 # ID: types.py [79cd8cf] benjamin@bengfort.com $
11 
12 """
13 Detection utilities for Scikit-Learn and Numpy types for flexibility
14 """
15 
16 ##########################################################################
17 ## Imports
18 ##########################################################################
19 
20 import inspect
21 import numpy as np
22 
23 from sklearn.base import BaseEstimator
24 
25 
26 ##########################################################################
27 ## Model Type checking utilities
28 ##########################################################################
29 
30 def is_estimator(model):
31     """
32     Determines if a model is an estimator using issubclass and isinstance.
33 
34     Parameters
35     ----------
36     estimator : class or instance
37         The object to test if it is a Scikit-Learn clusterer, especially a
38         Scikit-Learn estimator or Yellowbrick visualizer
39     """
40     if inspect.isclass(model):
41         return issubclass(model, BaseEstimator)
42 
43     return isinstance(model, BaseEstimator)
44 
45 # Alias for closer name to isinstance and issubclass
46 isestimator = is_estimator
47 
48 
49 def is_classifier(estimator):
50     """
51     Returns True if the given estimator is (probably) a classifier.
52 
53     Parameters
54     ----------
55     estimator : class or instance
56         The object to test if it is a Scikit-Learn clusterer, especially a
57         Scikit-Learn estimator or Yellowbrick visualizer
58 
59     See also
60     --------
61     is_classifier
62         `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_
63     """
64     # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
65     # wrappers as in Issue #90, these three lines become unnecessary.
66     # NOTE: This must be imported here to avoid recursive import.
67     from yellowbrick.base import Visualizer
68     if isinstance(estimator, Visualizer):
69         return is_classifier(estimator.estimator)
70 
71     # Test the _estimator_type property
72     return getattr(estimator, "_estimator_type", None) == "classifier"
73 
74 # Alias for closer name to isinstance and issubclass
75 isclassifier = is_classifier
76 
77 
78 def is_regressor(estimator):
79     """
80     Returns True if the given estimator is (probably) a regressor.
81 
82     Parameters
83     ----------
84     estimator : class or instance
85         The object to test if it is a Scikit-Learn clusterer, especially a
86         Scikit-Learn estimator or Yellowbrick visualizer
87 
88     See also
89     --------
90     is_regressor
91         `sklearn.is_regressor() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L531>`_
92     """
93     # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
94     # wrappers as in Issue #90, these three lines become unnecessary.
95     # NOTE: This must be imported here to avoid recursive import.
96     from yellowbrick.base import Visualizer
97     if isinstance(estimator, Visualizer):
98         return is_regressor(estimator.estimator)
99 
100     # Test the _estimator_type property
101     return getattr(estimator, "_estimator_type", None) == "regressor"
102 
103 # Alias for closer name to isinstance and issubclass
104 isregressor = is_regressor
105 
106 
107 def is_clusterer(estimator):
108     """
109     Returns True if the given estimator is a clusterer.
110 
111     Parameters
112     ----------
113     estimator : class or instance
114         The object to test if it is a Scikit-Learn clusterer, especially a
115         Scikit-Learn estimator or Yellowbrick visualizer
116     """
117     # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
118     # wrappers as in Issue #90, these three lines become unnecessary.
119     # NOTE: This must be imported here to avoid recursive import.
120     from yellowbrick.base import Visualizer
121     if isinstance(estimator, Visualizer):
122         return is_clusterer(estimator.estimator)
123 
124     # Test the _estimator_type property
125     return getattr(estimator, "_estimator_type", None) == "clusterer"
126 
127 # Alias for closer name to isinstance and issubclass
128 isclusterer = is_clusterer
129 
130 
131 def is_gridsearch(estimator):
132     """
133     Returns True if the given estimator is a clusterer.
134 
135     Parameters
136     ----------
137     estimator : class or instance
138         The object to test if it is a Scikit-Learn clusterer, especially a
139         Scikit-Learn estimator or Yellowbrick visualizer
140     """
141     # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
142     # wrappers as in Issue #90, these three lines become unnecessary.
143     # NOTE: This must be imported here to avoid recursive import.
144     from yellowbrick.base import Visualizer
145     if isinstance(estimator, Visualizer):
146         return is_gridsearch(estimator.estimator)
147 
148     from sklearn.model_selection import GridSearchCV, RandomizedSearchCV
149 
150     if inspect.isclass(estimator):
151         return issubclass(estimator, (GridSearchCV, RandomizedSearchCV))
152 
153     return isinstance(estimator, (GridSearchCV, RandomizedSearchCV))
154 
155 
156 # Alias for closer name to isinstance and issubclass
157 isgridsearch = is_gridsearch
158 
159 
160 def is_probabilistic(estimator):
161     """
162     Returns True if the given estimator returns a y_score for it's decision
163     function, e.g. has ``predict_proba`` or ``decision_function`` methods.
164 
165     Parameters
166     ----------
167     estimator : class or instance
168         The object to test if is probabilistic, especially a Scikit-Learn
169         estimator or Yellowbrick visualizer.
170     """
171     return any([
172         hasattr(estimator, 'predict_proba'),
173         hasattr(estimator, 'decision_function'),
174     ])
175 
176 # Alias for closer name to isinstance and issubclass
177 isprobabilistic = is_probabilistic
178 
179 
180 ##########################################################################
181 ## Data Type checking utilities
182 ##########################################################################
183 
184 def is_dataframe(obj):
185     """
186     Returns True if the given object is a Pandas Data Frame.
187 
188     Parameters
189     ----------
190     obj: instance
191         The object to test whether or not is a Pandas DataFrame.
192     """
193     try:
194         # This is the best method of type checking
195         from pandas import DataFrame
196         return isinstance(obj, DataFrame)
197     except ImportError:
198         # Pandas is not a dependency, so this is scary
199         return obj.__class__.__name__ == "DataFrame"
200 
201 # Alias for closer name to isinstance and issubclass
202 isdataframe = is_dataframe
203 
204 
205 def is_series(obj):
206     """
207     Returns True if the given object is a Pandas Series.
208 
209     Parameters
210     ----------
211     obj: instance
212         The object to test whether or not is a Pandas Series.
213     """
214     try:
215         # This is the best method of type checking
216         from pandas import Series
217         return isinstance(obj, Series)
218     except ImportError:
219         # Pandas is not a dependency, so this is scary
220         return obj.__class__.__name__ == "Series"
221 
222 # Alias for closer name to isinstance and issubclass
223 isseries = is_series
224 
225 
226 def is_structured_array(obj):
227     """
228     Returns True if the given object is a Numpy Structured Array.
229 
230     Parameters
231     ----------
232     obj: instance
233         The object to test whether or not is a Numpy Structured Array.
234     """
235     if isinstance(obj, np.ndarray) and hasattr(obj, 'dtype'):
236         if obj.dtype.names is not None:
237             return True
238     return False
239 
240 
241 # Alias for closer name to isinstance and issubclass
242 isstructuredarray = is_structured_array
243
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/yellowbrick/utils/types.py b/yellowbrick/utils/types.py
--- a/yellowbrick/utils/types.py
+++ b/yellowbrick/utils/types.py
@@ -61,12 +61,6 @@
     is_classifier
         `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_
     """
-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
-    # wrappers as in Issue #90, these three lines become unnecessary.
-    # NOTE: This must be imported here to avoid recursive import.
-    from yellowbrick.base import Visualizer
-    if isinstance(estimator, Visualizer):
-        return is_classifier(estimator.estimator)
 
     # Test the _estimator_type property
     return getattr(estimator, "_estimator_type", None) == "classifier"
@@ -90,12 +84,6 @@
     is_regressor
         `sklearn.is_regressor() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L531>`_
     """
-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
-    # wrappers as in Issue #90, these three lines become unnecessary.
-    # NOTE: This must be imported here to avoid recursive import.
-    from yellowbrick.base import Visualizer
-    if isinstance(estimator, Visualizer):
-        return is_regressor(estimator.estimator)
 
     # Test the _estimator_type property
     return getattr(estimator, "_estimator_type", None) == "regressor"
@@ -114,12 +102,6 @@
         The object to test if it is a Scikit-Learn clusterer, especially a
         Scikit-Learn estimator or Yellowbrick visualizer
     """
-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
-    # wrappers as in Issue #90, these three lines become unnecessary.
-    # NOTE: This must be imported here to avoid recursive import.
-    from yellowbrick.base import Visualizer
-    if isinstance(estimator, Visualizer):
-        return is_clusterer(estimator.estimator)
 
     # Test the _estimator_type property
     return getattr(estimator, "_estimator_type", None) == "clusterer"
@@ -138,12 +120,6 @@
         The object to test if it is a Scikit-Learn clusterer, especially a
         Scikit-Learn estimator or Yellowbrick visualizer
     """
-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through
-    # wrappers as in Issue #90, these three lines become unnecessary.
-    # NOTE: This must be imported here to avoid recursive import.
-    from yellowbrick.base import Visualizer
-    if isinstance(estimator, Visualizer):
-        return is_gridsearch(estimator.estimator)
 
     from sklearn.model_selection import GridSearchCV, RandomizedSearchCV

{"golden_diff": "diff --git a/yellowbrick/utils/types.py b/yellowbrick/utils/types.py\n--- a/yellowbrick/utils/types.py\n+++ b/yellowbrick/utils/types.py\n@@ -61,12 +61,6 @@\n     is_classifier\n         `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_\n     \"\"\"\n-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n-    # wrappers as in Issue #90, these three lines become unnecessary.\n-    # NOTE: This must be imported here to avoid recursive import.\n-    from yellowbrick.base import Visualizer\n-    if isinstance(estimator, Visualizer):\n-        return is_classifier(estimator.estimator)\n \n     # Test the _estimator_type property\n     return getattr(estimator, \"_estimator_type\", None) == \"classifier\"\n@@ -90,12 +84,6 @@\n     is_regressor\n         `sklearn.is_regressor() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L531>`_\n     \"\"\"\n-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n-    # wrappers as in Issue #90, these three lines become unnecessary.\n-    # NOTE: This must be imported here to avoid recursive import.\n-    from yellowbrick.base import Visualizer\n-    if isinstance(estimator, Visualizer):\n-        return is_regressor(estimator.estimator)\n \n     # Test the _estimator_type property\n     return getattr(estimator, \"_estimator_type\", None) == \"regressor\"\n@@ -114,12 +102,6 @@\n         The object to test if it is a Scikit-Learn clusterer, especially a\n         Scikit-Learn estimator or Yellowbrick visualizer\n     \"\"\"\n-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n-    # wrappers as in Issue #90, these three lines become unnecessary.\n-    # NOTE: This must be imported here to avoid recursive import.\n-    from yellowbrick.base import Visualizer\n-    if isinstance(estimator, Visualizer):\n-        return is_clusterer(estimator.estimator)\n \n     # Test the _estimator_type property\n     return getattr(estimator, \"_estimator_type\", None) == \"clusterer\"\n@@ -138,12 +120,6 @@\n         The object to test if it is a Scikit-Learn clusterer, especially a\n         Scikit-Learn estimator or Yellowbrick visualizer\n     \"\"\"\n-    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n-    # wrappers as in Issue #90, these three lines become unnecessary.\n-    # NOTE: This must be imported here to avoid recursive import.\n-    from yellowbrick.base import Visualizer\n-    if isinstance(estimator, Visualizer):\n-        return is_gridsearch(estimator.estimator)\n \n     from sklearn.model_selection import GridSearchCV, RandomizedSearchCV\n", "issue": "Remove visualizer tests in type checking\nMany of the type checking utilities, e.g. `is_classifier`, `is_regressor`, etc. have a note to remove lines of code that are unnecessary after #90 is implemented. \r\n\r\nFor example see: [yellowbrick/utils/types.py#L64](https://github.com/DistrictDataLabs/yellowbrick/blob/develop/yellowbrick/utils/types.py#L64):\r\n\r\n```python\r\ndef is_classifier(estimator):\r\n    \"\"\"\r\n    Returns True if the given estimator is (probably) a classifier.\r\n\r\n    Parameters\r\n    ----------\r\n    estimator : class or instance\r\n        The object to test if it is a Scikit-Learn clusterer, especially a\r\n        Scikit-Learn estimator or Yellowbrick visualizer\r\n\r\n    See also\r\n    --------\r\n    is_classifier\r\n        `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_\r\n    \"\"\"\r\n    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\r\n    # wrappers as in Issue #90, these three lines become unnecessary.\r\n    # NOTE: This must be imported here to avoid recursive import.\r\n    from yellowbrick.base import Visualizer\r\n    if isinstance(estimator, Visualizer):\r\n        return is_classifier(estimator.estimator)\r\n\r\n    # Test the _estimator_type property\r\n    return getattr(estimator, \"_estimator_type\", None) == \"classifier\"\r\n\r\n# Alias for closer name to isinstance and issubclass\r\nisclassifier = is_classifier\r\n```\r\n\r\nWe should remove these lines of code and **ensure the tests have correct coverage**. \n", "before_files": [{"content": "# yellowbrick.utils.types\n# Detection utilities for Scikit-Learn and Numpy types for flexibility\n#\n# Author:   Benjamin Bengfort <bbengfort@districtdatalabs.com>\n# Created:  Fri May 19 10:51:13 2017 -0700\n#\n# Copyright (C) 2017 District Data Labs\n# For license information, see LICENSE.txt\n#\n# ID: types.py [79cd8cf] benjamin@bengfort.com $\n\n\"\"\"\nDetection utilities for Scikit-Learn and Numpy types for flexibility\n\"\"\"\n\n##########################################################################\n## Imports\n##########################################################################\n\nimport inspect\nimport numpy as np\n\nfrom sklearn.base import BaseEstimator\n\n\n##########################################################################\n## Model Type checking utilities\n##########################################################################\n\ndef is_estimator(model):\n    \"\"\"\n    Determines if a model is an estimator using issubclass and isinstance.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n    if inspect.isclass(model):\n        return issubclass(model, BaseEstimator)\n\n    return isinstance(model, BaseEstimator)\n\n# Alias for closer name to isinstance and issubclass\nisestimator = is_estimator\n\n\ndef is_classifier(estimator):\n    \"\"\"\n    Returns True if the given estimator is (probably) a classifier.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n\n    See also\n    --------\n    is_classifier\n        `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_\n    \"\"\"\n    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n    # wrappers as in Issue #90, these three lines become unnecessary.\n    # NOTE: This must be imported here to avoid recursive import.\n    from yellowbrick.base import Visualizer\n    if isinstance(estimator, Visualizer):\n        return is_classifier(estimator.estimator)\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"classifier\"\n\n# Alias for closer name to isinstance and issubclass\nisclassifier = is_classifier\n\n\ndef is_regressor(estimator):\n    \"\"\"\n    Returns True if the given estimator is (probably) a regressor.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n\n    See also\n    --------\n    is_regressor\n        `sklearn.is_regressor() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L531>`_\n    \"\"\"\n    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n    # wrappers as in Issue #90, these three lines become unnecessary.\n    # NOTE: This must be imported here to avoid recursive import.\n    from yellowbrick.base import Visualizer\n    if isinstance(estimator, Visualizer):\n        return is_regressor(estimator.estimator)\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"regressor\"\n\n# Alias for closer name to isinstance and issubclass\nisregressor = is_regressor\n\n\ndef is_clusterer(estimator):\n    \"\"\"\n    Returns True if the given estimator is a clusterer.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n    # wrappers as in Issue #90, these three lines become unnecessary.\n    # NOTE: This must be imported here to avoid recursive import.\n    from yellowbrick.base import Visualizer\n    if isinstance(estimator, Visualizer):\n        return is_clusterer(estimator.estimator)\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"clusterer\"\n\n# Alias for closer name to isinstance and issubclass\nisclusterer = is_clusterer\n\n\ndef is_gridsearch(estimator):\n    \"\"\"\n    Returns True if the given estimator is a clusterer.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n    # TODO: once we make ScoreVisualizer and ModelVisualizer pass through\n    # wrappers as in Issue #90, these three lines become unnecessary.\n    # NOTE: This must be imported here to avoid recursive import.\n    from yellowbrick.base import Visualizer\n    if isinstance(estimator, Visualizer):\n        return is_gridsearch(estimator.estimator)\n\n    from sklearn.model_selection import GridSearchCV, RandomizedSearchCV\n\n    if inspect.isclass(estimator):\n        return issubclass(estimator, (GridSearchCV, RandomizedSearchCV))\n\n    return isinstance(estimator, (GridSearchCV, RandomizedSearchCV))\n\n\n# Alias for closer name to isinstance and issubclass\nisgridsearch = is_gridsearch\n\n\ndef is_probabilistic(estimator):\n    \"\"\"\n    Returns True if the given estimator returns a y_score for it's decision\n    function, e.g. has ``predict_proba`` or ``decision_function`` methods.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if is probabilistic, especially a Scikit-Learn\n        estimator or Yellowbrick visualizer.\n    \"\"\"\n    return any([\n        hasattr(estimator, 'predict_proba'),\n        hasattr(estimator, 'decision_function'),\n    ])\n\n# Alias for closer name to isinstance and issubclass\nisprobabilistic = is_probabilistic\n\n\n##########################################################################\n## Data Type checking utilities\n##########################################################################\n\ndef is_dataframe(obj):\n    \"\"\"\n    Returns True if the given object is a Pandas Data Frame.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Pandas DataFrame.\n    \"\"\"\n    try:\n        # This is the best method of type checking\n        from pandas import DataFrame\n        return isinstance(obj, DataFrame)\n    except ImportError:\n        # Pandas is not a dependency, so this is scary\n        return obj.__class__.__name__ == \"DataFrame\"\n\n# Alias for closer name to isinstance and issubclass\nisdataframe = is_dataframe\n\n\ndef is_series(obj):\n    \"\"\"\n    Returns True if the given object is a Pandas Series.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Pandas Series.\n    \"\"\"\n    try:\n        # This is the best method of type checking\n        from pandas import Series\n        return isinstance(obj, Series)\n    except ImportError:\n        # Pandas is not a dependency, so this is scary\n        return obj.__class__.__name__ == \"Series\"\n\n# Alias for closer name to isinstance and issubclass\nisseries = is_series\n\n\ndef is_structured_array(obj):\n    \"\"\"\n    Returns True if the given object is a Numpy Structured Array.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Numpy Structured Array.\n    \"\"\"\n    if isinstance(obj, np.ndarray) and hasattr(obj, 'dtype'):\n        if obj.dtype.names is not None:\n            return True\n    return False\n\n\n# Alias for closer name to isinstance and issubclass\nisstructuredarray = is_structured_array\n", "path": "yellowbrick/utils/types.py"}], "after_files": [{"content": "# yellowbrick.utils.types\n# Detection utilities for Scikit-Learn and Numpy types for flexibility\n#\n# Author:   Benjamin Bengfort <bbengfort@districtdatalabs.com>\n# Created:  Fri May 19 10:51:13 2017 -0700\n#\n# Copyright (C) 2017 District Data Labs\n# For license information, see LICENSE.txt\n#\n# ID: types.py [79cd8cf] benjamin@bengfort.com $\n\n\"\"\"\nDetection utilities for Scikit-Learn and Numpy types for flexibility\n\"\"\"\n\n##########################################################################\n## Imports\n##########################################################################\n\nimport inspect\nimport numpy as np\n\nfrom sklearn.base import BaseEstimator\n\n\n##########################################################################\n## Model Type checking utilities\n##########################################################################\n\ndef is_estimator(model):\n    \"\"\"\n    Determines if a model is an estimator using issubclass and isinstance.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n    if inspect.isclass(model):\n        return issubclass(model, BaseEstimator)\n\n    return isinstance(model, BaseEstimator)\n\n# Alias for closer name to isinstance and issubclass\nisestimator = is_estimator\n\n\ndef is_classifier(estimator):\n    \"\"\"\n    Returns True if the given estimator is (probably) a classifier.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n\n    See also\n    --------\n    is_classifier\n        `sklearn.is_classifier() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L518>`_\n    \"\"\"\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"classifier\"\n\n# Alias for closer name to isinstance and issubclass\nisclassifier = is_classifier\n\n\ndef is_regressor(estimator):\n    \"\"\"\n    Returns True if the given estimator is (probably) a regressor.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n\n    See also\n    --------\n    is_regressor\n        `sklearn.is_regressor() <https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L531>`_\n    \"\"\"\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"regressor\"\n\n# Alias for closer name to isinstance and issubclass\nisregressor = is_regressor\n\n\ndef is_clusterer(estimator):\n    \"\"\"\n    Returns True if the given estimator is a clusterer.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n\n    # Test the _estimator_type property\n    return getattr(estimator, \"_estimator_type\", None) == \"clusterer\"\n\n# Alias for closer name to isinstance and issubclass\nisclusterer = is_clusterer\n\n\ndef is_gridsearch(estimator):\n    \"\"\"\n    Returns True if the given estimator is a clusterer.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if it is a Scikit-Learn clusterer, especially a\n        Scikit-Learn estimator or Yellowbrick visualizer\n    \"\"\"\n\n    from sklearn.model_selection import GridSearchCV, RandomizedSearchCV\n\n    if inspect.isclass(estimator):\n        return issubclass(estimator, (GridSearchCV, RandomizedSearchCV))\n\n    return isinstance(estimator, (GridSearchCV, RandomizedSearchCV))\n\n\n# Alias for closer name to isinstance and issubclass\nisgridsearch = is_gridsearch\n\n\ndef is_probabilistic(estimator):\n    \"\"\"\n    Returns True if the given estimator returns a y_score for it's decision\n    function, e.g. has ``predict_proba`` or ``decision_function`` methods.\n\n    Parameters\n    ----------\n    estimator : class or instance\n        The object to test if is probabilistic, especially a Scikit-Learn\n        estimator or Yellowbrick visualizer.\n    \"\"\"\n    return any([\n        hasattr(estimator, 'predict_proba'),\n        hasattr(estimator, 'decision_function'),\n    ])\n\n# Alias for closer name to isinstance and issubclass\nisprobabilistic = is_probabilistic\n\n\n##########################################################################\n## Data Type checking utilities\n##########################################################################\n\ndef is_dataframe(obj):\n    \"\"\"\n    Returns True if the given object is a Pandas Data Frame.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Pandas DataFrame.\n    \"\"\"\n    try:\n        # This is the best method of type checking\n        from pandas import DataFrame\n        return isinstance(obj, DataFrame)\n    except ImportError:\n        # Pandas is not a dependency, so this is scary\n        return obj.__class__.__name__ == \"DataFrame\"\n\n# Alias for closer name to isinstance and issubclass\nisdataframe = is_dataframe\n\n\ndef is_series(obj):\n    \"\"\"\n    Returns True if the given object is a Pandas Series.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Pandas Series.\n    \"\"\"\n    try:\n        # This is the best method of type checking\n        from pandas import Series\n        return isinstance(obj, Series)\n    except ImportError:\n        # Pandas is not a dependency, so this is scary\n        return obj.__class__.__name__ == \"Series\"\n\n# Alias for closer name to isinstance and issubclass\nisseries = is_series\n\n\ndef is_structured_array(obj):\n    \"\"\"\n    Returns True if the given object is a Numpy Structured Array.\n\n    Parameters\n    ----------\n    obj: instance\n        The object to test whether or not is a Numpy Structured Array.\n    \"\"\"\n    if isinstance(obj, np.ndarray) and hasattr(obj, 'dtype'):\n        if obj.dtype.names is not None:\n            return True\n    return False\n\n\n# Alias for closer name to isinstance and issubclass\nisstructuredarray = is_structured_array\n", "path": "yellowbrick/utils/types.py"}]}