Note
Go to the end to download the full example code.
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.
from sklearn import datasets, metrics
from gemclus.tree import Douglas
Load the dataset¶
Create the douglas tree and fit it¶
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))
Score of model is: 1.4741506860502334
ARI of model is: 0.5681159420289855
Total running time of the script: (0 minutes 1.174 seconds)