-
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.
- Loading branch information
1 parent
37c1977
commit fb436c6
Showing
5 changed files
with
94 additions
and
16 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
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,48 @@ | ||
import numpy as np | ||
from sklearn.datasets import make_blobs | ||
import matplotlib.pyplot as plt | ||
import path | ||
import sys | ||
|
||
# directory reach | ||
directory = path.Path(__file__).abspath() | ||
|
||
print(directory.parent) | ||
# setting path | ||
sys.path.append(directory.parent.parent) | ||
|
||
from fusion.FusionART import FusionART | ||
from elementary.FuzzyART import FuzzyART, prepare_data | ||
|
||
|
||
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) | ||
|
||
data_channel_a = data[:,0].reshape((-1,1)) | ||
data_channel_b = data[:,1].reshape((-1,1)) | ||
|
||
X_channel_a = prepare_data(data_channel_a) | ||
X_channel_b = prepare_data(data_channel_b) | ||
|
||
X = np.hstack([X_channel_a, X_channel_b]) | ||
print("Prepared data has shape:", X.shape) | ||
|
||
params = { | ||
"rho": 0.5, | ||
"alpha": 0.0, | ||
"beta": 1.0 | ||
} | ||
art_a = FuzzyART(params) | ||
art_b = FuzzyART(params) | ||
cls = FusionART([art_a, art_b], gamma_values=[0.5, 0.5], channel_dims=[2,2]) | ||
y = cls.fit_predict(X) | ||
|
||
print(f"{cls.n_clusters} clusters found") | ||
|
||
cls.visualize(data, y) | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
cluster_blobs() |
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