.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_cluster_dl85.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_plot_cluster_dl85.py: =================================== DL8.5 default predictive clustering =================================== This example illustrates how to use the DL85Cluster class for predictive clustering. A second implementation of predictive clustering is provided in the plot_cluster_user.py example. .. GENERATED FROM PYTHON SOURCE LINES 9-45 .. rst-class:: sphx-glr-script-out .. code-block:: none #################################################################### # DL8.5 default clustering # #################################################################### Model building... Model built. Duration of building = 4.8635 #################################################################### # DL8.5 default predictive clustering # #################################################################### Model building... Model built. Duration of building = 2.6191 X_desc is used to describe data while X_err is used to compute errors | .. code-block:: default import numpy as np from sklearn.model_selection import train_test_split import time from pydl85 import DL85Cluster dataset = np.genfromtxt("../datasets/anneal.txt", delimiter=' ') X = dataset[:, 1:] X_train, X_test = train_test_split(X, test_size=0.2, random_state=0) print("####################################################################\n" "# DL8.5 default clustering #\n" "####################################################################") clf = DL85Cluster(max_depth=2, time_limit=600) start = time.perf_counter() print("Model building...") clf.fit(X_train) duration = time.perf_counter() - start print("Model built. Duration of building =", round(duration, 4), "\n\n\n") predicted = clf.predict(X_test) print("####################################################################\n" "# DL8.5 default predictive clustering #\n" "####################################################################") X_desc = X_train[:X_test.shape[0], :] X_err = X_test clf = DL85Cluster(max_depth=2, time_limit=600) start = time.perf_counter() print("Model building...") clf.fit(X_desc, X_err) duration = time.perf_counter() - start print("Model built. Duration of building =", round(duration, 4)) print("X_desc is used to describe data while X_err is used to compute errors") predicted = clf.predict(X_err) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 7.523 seconds) .. _sphx_glr_download_auto_examples_plot_cluster_dl85.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cluster_dl85.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cluster_dl85.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_