import numpy as np
from Orange.data import Table, Domain, ContinuousVariable

data = np.array(in_data.X)

haar = [[r.mean(), r.std(), r.max() - r.min(), np.sqrt((r ** 2).sum())] for r in data]

domain = Domain([ContinuousVariable(f"Haar_{i+1}") for i in range(4)])

out_data = Table(domain, np.array(haar))

print("Haar transform done")


fin_error---line6

import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import AgglomerativeClustering
from Orange.data import Table

data = Table("your_dataset.csv")  # Example: Table("iris")
X = np.array(data.X)  # Convert Orange data table to NumPy array

def divisive(X, n_clusters=3):
    clusters = [X]
    while len(clusters) < n_clusters:

        c = max(clusters, key=len)
        clusters.remove(c)

        if len(c) < 2:
            clusters.append(c)
            continue

        labels = AgglomerativeClustering(n_clusters=2).fit_predict(c)

        clusters.append(c[labels == 0])
        clusters.append(c[labels == 1])

    return clusters

clusters = divisive(X, n_clusters=3)

plt.figure(figsize=(7, 5))
colors = ['red', 'green', 'blue', 'orange', 'purple', 'cyan']

for c, col in zip(clusters, colors):
    if c.shape[0] > 0:
        plt.scatter(c[:, 0], c[:, 1], color=col, label=f'Cluster {colors.index(col)+1}')

plt.xlabel('Feature 1')
plt.ylabel('Feature 2')
plt.title('Divisive Clustering')
plt.legend()
plt.show()

fin_error---line9