.. note::
    :class: sphx-glr-download-link-note

    Click :ref:`here <sphx_glr_download_auto_examples_plot_vfi_classifier_dicision_boundaries.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_vfi_classifier_dicision_boundaries.py:


=============================
VFI Decision Regions
=============================

In this plot we can compare the decision regions among a VFI classifier against a CART, a Kernel SV model and a 3NN classifier.



.. image:: /auto_examples/images/sphx_glr_plot_vfi_classifier_dicision_boundaries_001.png
    :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    C:\Users\chris\Storage\work\projects\repos\github\chkoar\vfi\examples\plot_vfi_classifier_dicision_boundaries.py:60: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
      plt.show()





|


.. code-block:: default


    print(__doc__)

    from itertools import product

    import numpy as np
    import matplotlib.pyplot as plt

    import vfi
    from sklearn import datasets
    from sklearn.tree import DecisionTreeClassifier
    from sklearn.naive_bayes import GaussianNB
    from sklearn.neighbors import KNeighborsClassifier
    from sklearn.ensemble import VotingClassifier

    # Loading some example data
    iris = datasets.load_iris()
    X = iris.data[:, [0, 2]]
    y = iris.target

    # Training classifiers
    vfi = vfi.VFI()
    clf1 = DecisionTreeClassifier(random_state=0)
    clf2 = KNeighborsClassifier(n_neighbors=3)
    clf3 = GaussianNB()


    clf1.fit(X, y)
    clf2.fit(X, y)
    clf3.fit(X, y)
    vfi.fit(X, y)

    # Plotting decision regions
    x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
    y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
    xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1))

    f, axarr = plt.subplots(2, 2, sharex="col", sharey="row", figsize=(10, 8))

    for idx, clf, tt in zip(
        product([0, 1], [0, 1]),
        [vfi, clf1, clf2, clf3],
        ["VFI", "Decision Tree", "KNN (k=3)", "Naive Bayes"],
    ):

        Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])
        Z = Z.reshape(xx.shape)

        axarr[idx[0], idx[1]].contourf(xx, yy, Z, alpha=0.4)
        axarr[idx[0], idx[1]].scatter(X[:, 0], X[:, 1], c=y, s=20, edgecolor="k")
        axarr[idx[0], idx[1]].set_title(tt)

    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.437 seconds)


.. _sphx_glr_download_auto_examples_plot_vfi_classifier_dicision_boundaries.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download

     :download:`Download Python source code: plot_vfi_classifier_dicision_boundaries.py <plot_vfi_classifier_dicision_boundaries.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: plot_vfi_classifier_dicision_boundaries.ipynb <plot_vfi_classifier_dicision_boundaries.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
