-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from NiklasMelton/add-gif-mode
add fit_gif method
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from sklearn.datasets import make_blobs | ||
import matplotlib.pyplot as plt | ||
|
||
from artlib import FuzzyART | ||
|
||
|
||
def cluster_blobs(): | ||
data, target = make_blobs( | ||
n_samples=150, | ||
centers=3, | ||
cluster_std=0.50, | ||
random_state=0, | ||
shuffle=False, | ||
) | ||
print("Data has shape:", data.shape) | ||
|
||
params = {"rho": 0.5, "alpha": 0.0, "beta": 1.0} | ||
cls = FuzzyART(**params) | ||
|
||
X = cls.prepare_data(data) | ||
print("Prepared data has shape:", X.shape) | ||
|
||
cls = cls.fit_gif(X, filename="fit_gif_FuzzyART.gif", n_cluster_estimate=3) | ||
y = cls.labels_ | ||
|
||
print(f"{cls.n_clusters} clusters found") | ||
|
||
cls.visualize(X, y) | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
cluster_blobs() |