Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,8 @@ def do_train(n_samples, n_new_data):
|
|
90 |
X_new, y_new = make_blobs(
|
91 |
n_samples=N_NEW_DATA, centers=[(-7, -1), (-2, 4), (3, 6)], random_state=RANDOM_STATE
|
92 |
)
|
93 |
-
|
|
|
94 |
fig2, axes2 = plt.subplots()
|
95 |
axes2.scatter(X[:, 0], X[:, 1], c=cluster_labels, alpha=0.5, edgecolor="k")
|
96 |
axes2.scatter(X_new[:, 0], X_new[:, 1], c="black", alpha=1, edgecolor="k")
|
@@ -105,7 +106,7 @@ def do_train(n_samples, n_new_data):
|
|
105 |
probable_clusters = inductive_learner.predict(X_new)
|
106 |
fig3, axes3 = plt.subplots()
|
107 |
disp = DecisionBoundaryDisplay.from_estimator(
|
108 |
-
inductive_learner,
|
109 |
)
|
110 |
disp.ax_.set_title("Classify unknown instances with known clusters")
|
111 |
disp.ax_.scatter(X[:, 0], X[:, 1], c=cluster_labels, alpha=0.5, edgecolor="k")
|
@@ -114,7 +115,6 @@ def do_train(n_samples, n_new_data):
|
|
114 |
|
115 |
# recomputing clustering and classify boundary
|
116 |
t2 = time.time()
|
117 |
-
X_all = np.concatenate((X, X_new), axis=0)
|
118 |
clusterer = AgglomerativeClustering(n_clusters=3)
|
119 |
y = clusterer.fit_predict(X_all)
|
120 |
classifier = RandomForestClassifier(random_state=RANDOM_STATE).fit(X_all, y)
|
|
|
90 |
X_new, y_new = make_blobs(
|
91 |
n_samples=N_NEW_DATA, centers=[(-7, -1), (-2, 4), (3, 6)], random_state=RANDOM_STATE
|
92 |
)
|
93 |
+
X_all = np.concatenate((X, X_new), axis=0)
|
94 |
+
|
95 |
fig2, axes2 = plt.subplots()
|
96 |
axes2.scatter(X[:, 0], X[:, 1], c=cluster_labels, alpha=0.5, edgecolor="k")
|
97 |
axes2.scatter(X_new[:, 0], X_new[:, 1], c="black", alpha=1, edgecolor="k")
|
|
|
106 |
probable_clusters = inductive_learner.predict(X_new)
|
107 |
fig3, axes3 = plt.subplots()
|
108 |
disp = DecisionBoundaryDisplay.from_estimator(
|
109 |
+
inductive_learner, X_all, response_method="predict", alpha=0.4, ax=axes3
|
110 |
)
|
111 |
disp.ax_.set_title("Classify unknown instances with known clusters")
|
112 |
disp.ax_.scatter(X[:, 0], X[:, 1], c=cluster_labels, alpha=0.5, edgecolor="k")
|
|
|
115 |
|
116 |
# recomputing clustering and classify boundary
|
117 |
t2 = time.time()
|
|
|
118 |
clusterer = AgglomerativeClustering(n_clusters=3)
|
119 |
y = clusterer.fit_predict(X_all)
|
120 |
classifier = RandomForestClassifier(random_state=RANDOM_STATE).fit(X_all, y)
|