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.

Out:

####################################################################
#                      DL8.5 default clustering                    #
####################################################################
Model building...
Model built. Duration of building = 0.5268



####################################################################
#                DL8.5 default predictive clustering               #
####################################################################
Model building...
Model built. Duration of building = 0.1456
Xtrain1 is used to describe data while X_test is used to compute errors

import numpy as np
from sklearn.model_selection import train_test_split
import time
from dl85 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=1, 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_train1 = X_train[:X_test.shape[0], :]
clf = DL85Cluster(max_depth=1, time_limit=600)
start = time.perf_counter()
print("Model building...")
clf.fit(X_train1, X_test)
duration = time.perf_counter() - start
print("Model built. Duration of building =", round(duration, 4))
print("Xtrain1 is used to describe data while X_test is used to compute errors")
predicted = clf.predict(X_test)

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

Gallery generated by Sphinx-Gallery