yotarazona / scikit-eo

A Python package for Remote Sensing Data Analysis
https://yotarazona.github.io/scikit-eo/
Other
192 stars 20 forks source link

Add plotting of calkmeans results #37

Open robmarkcole opened 1 month ago

robmarkcole commented 1 month ago

Description

Would help users to review results. Not sure where best to put these utility plot functions? Alternatively add to an example notebook/documentation

Source code

# Plot inertia vs. number of clusters to find the "elbow point"
results = calkmeans(img, k=None, algo=('lloyd', 'elkan'), n_iter=10)

cluster_range = range(1, 11)
plt.figure(figsize=(8, 6))
for algorithm in results:
    plt.plot(cluster_range, results[algorithm], marker='o', label=f'Algorithm: {algorithm}')
plt.title('Inertia vs Number of Clusters')
plt.xlabel('Number of Clusters')
plt.ylabel('Inertia')
plt.legend()
plt.show()

Output example:

image
yotarazona commented 1 month ago

Hi @robmarkcole, thank you again for your contribution to improve scikit-eo. This implementation can take some time considering that I am writing an article related to my PhD. In case you decide to contribute, I will be grateful. This function could be inside process.py or inside calkmeans.py, maybe.

yotarazona commented 1 month ago

or maybe inside plot.py, could be.