.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/trees/plot_douglas_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_trees_plot_douglas_example.py: ================================================================== Building a differentiable unsupervised tree: DOUGLAS ================================================================== This example shows how to use the Douglas tree for a dataset with few features. The DOUGLAS model builds a differentiable tree by associating different constructed binnings of the data per feature to clusters. The thresholds are learnt by GEMINI maximisation. .. GENERATED FROM PYTHON SOURCE LINES 11-15 .. code-block:: Python from sklearn import datasets, metrics from gemclus.tree import Douglas .. GENERATED FROM PYTHON SOURCE LINES 16-18 Load the dataset -------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 20-25 .. code-block:: Python iris = datasets.load_iris() X = iris["data"] y = iris["target"] .. GENERATED FROM PYTHON SOURCE LINES 26-28 Create the douglas tree and fit it -------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-36 .. code-block:: Python model = Douglas(n_clusters=3, gemini="mmd_ova", max_iter=100, n_cuts=1) y_pred_linear = model.fit_predict(X) print("Score of model is: ", model.score(X)) print("ARI of model is: ", metrics.adjusted_rand_score(y, y_pred_linear)) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/circleci/.local/lib/python3.10/site-packages/sklearn/base.py:474: FutureWarning: `BaseEstimator._validate_data` is deprecated in 1.6 and will be removed in 1.7. Use `sklearn.utils.validation.validate_data` instead. This function becomes public and is part of the scikit-learn developer API. warnings.warn( Score of model is: 1.4741506860502334 ARI of model is: 0.5681159420289855 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.137 seconds) .. _sphx_glr_download_auto_examples_trees_plot_douglas_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_douglas_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_douglas_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_douglas_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_