Spaces:
Build error
Build error
Commit
·
0e83192
1
Parent(s):
d23d936
getting rid of some more problematic type hints
Browse files- cluster/clusterer.py +2 -4
- cluster/distance.py +1 -1
- cluster/opts.py +1 -1
- cluster/plot.py +2 -3
- neural_network/main.py +1 -1
- neural_network/plot.py +1 -2
cluster/clusterer.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
from dataclasses import dataclass
|
| 2 |
from typing import Callable
|
| 3 |
|
| 4 |
-
import numpy as np
|
| 5 |
-
|
| 6 |
|
| 7 |
@dataclass
|
| 8 |
class Clusterer:
|
|
@@ -11,8 +9,8 @@ class Clusterer:
|
|
| 11 |
|
| 12 |
def eval(
|
| 13 |
self,
|
| 14 |
-
pred_labels
|
| 15 |
-
true_labels
|
| 16 |
) -> None:
|
| 17 |
...
|
| 18 |
|
|
|
|
| 1 |
from dataclasses import dataclass
|
| 2 |
from typing import Callable
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
@dataclass
|
| 6 |
class Clusterer:
|
|
|
|
| 9 |
|
| 10 |
def eval(
|
| 11 |
self,
|
| 12 |
+
pred_labels,
|
| 13 |
+
true_labels,
|
| 14 |
) -> None:
|
| 15 |
...
|
| 16 |
|
cluster/distance.py
CHANGED
|
@@ -7,7 +7,7 @@ import numpy as np
|
|
| 7 |
def euclidean(
|
| 8 |
point: np.array,
|
| 9 |
data: np.array,
|
| 10 |
-
)
|
| 11 |
"""
|
| 12 |
Computed the euclidean distance
|
| 13 |
between a point and the rest
|
|
|
|
| 7 |
def euclidean(
|
| 8 |
point: np.array,
|
| 9 |
data: np.array,
|
| 10 |
+
):
|
| 11 |
"""
|
| 12 |
Computed the euclidean distance
|
| 13 |
between a point and the rest
|
cluster/opts.py
CHANGED
|
@@ -3,7 +3,7 @@ from cluster.kmedoids import Kmedoids
|
|
| 3 |
from cluster.kmeans import Kmeans
|
| 4 |
|
| 5 |
|
| 6 |
-
clustering_methods
|
| 7 |
"kmeans-clustering": Kmeans,
|
| 8 |
"kmedoids-clustering": Kmedoids,
|
| 9 |
}
|
|
|
|
| 3 |
from cluster.kmeans import Kmeans
|
| 4 |
|
| 5 |
|
| 6 |
+
clustering_methods = {
|
| 7 |
"kmeans-clustering": Kmeans,
|
| 8 |
"kmedoids-clustering": Kmedoids,
|
| 9 |
}
|
cluster/plot.py
CHANGED
|
@@ -4,13 +4,12 @@ import numpy as np
|
|
| 4 |
import matplotlib
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
import seaborn as sns
|
| 7 |
-
from cluster.clusterer import Clusterer
|
| 8 |
|
| 9 |
|
| 10 |
matplotlib.use("Agg")
|
| 11 |
sns.set()
|
| 12 |
|
| 13 |
-
def plot(clusterer
|
| 14 |
cluster_data = clusterer.to_dict(X)["clusters"]
|
| 15 |
# plot the clusters and data points
|
| 16 |
fig, ax = plt.subplots(figsize=(8, 6))
|
|
@@ -36,7 +35,7 @@ def plot(clusterer: Clusterer, X: np.array) -> None:
|
|
| 36 |
clusterer.plot = plt_bytes(fig)
|
| 37 |
|
| 38 |
|
| 39 |
-
def plt_bytes(fig)
|
| 40 |
buf = io.BytesIO()
|
| 41 |
fig.savefig(buf, format="png")
|
| 42 |
plt.close(fig)
|
|
|
|
| 4 |
import matplotlib
|
| 5 |
import matplotlib.pyplot as plt
|
| 6 |
import seaborn as sns
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
matplotlib.use("Agg")
|
| 10 |
sns.set()
|
| 11 |
|
| 12 |
+
def plot(clusterer, X) -> None:
|
| 13 |
cluster_data = clusterer.to_dict(X)["clusters"]
|
| 14 |
# plot the clusters and data points
|
| 15 |
fig, ax = plt.subplots(figsize=(8, 6))
|
|
|
|
| 35 |
clusterer.plot = plt_bytes(fig)
|
| 36 |
|
| 37 |
|
| 38 |
+
def plt_bytes(fig):
|
| 39 |
buf = io.BytesIO()
|
| 40 |
fig.savefig(buf, format="png")
|
| 41 |
plt.close(fig)
|
neural_network/main.py
CHANGED
|
@@ -6,7 +6,7 @@ from neural_network.backprop import bp
|
|
| 6 |
from neural_network.plot import plot
|
| 7 |
|
| 8 |
|
| 9 |
-
def init(X: np.array, hidden_size: int)
|
| 10 |
"""
|
| 11 |
returns a dictionary containing randomly initialized
|
| 12 |
weights and biases to start off the neural_network
|
|
|
|
| 6 |
from neural_network.plot import plot
|
| 7 |
|
| 8 |
|
| 9 |
+
def init(X: np.array, hidden_size: int):
|
| 10 |
"""
|
| 11 |
returns a dictionary containing randomly initialized
|
| 12 |
weights and biases to start off the neural_network
|
neural_network/plot.py
CHANGED
|
@@ -4,11 +4,10 @@ import io
|
|
| 4 |
import seaborn as sns
|
| 5 |
import matplotlib
|
| 6 |
import matplotlib.pyplot as plt
|
| 7 |
-
from neural_network.neural_network import NeuralNetwork
|
| 8 |
|
| 9 |
matplotlib.use("Agg")
|
| 10 |
|
| 11 |
-
def plot(model
|
| 12 |
sns.set()
|
| 13 |
fig, ax = plt.subplots()
|
| 14 |
sns.lineplot(
|
|
|
|
| 4 |
import seaborn as sns
|
| 5 |
import matplotlib
|
| 6 |
import matplotlib.pyplot as plt
|
|
|
|
| 7 |
|
| 8 |
matplotlib.use("Agg")
|
| 9 |
|
| 10 |
+
def plot(model) -> None:
|
| 11 |
sns.set()
|
| 12 |
fig, ax = plt.subplots()
|
| 13 |
sns.lineplot(
|