Skip to content

Commit

Permalink
ensure we use knn from an instllable module so we can make the module…
Browse files Browse the repository at this point in the history
… portable

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Mar 25, 2022
1 parent 63ede8a commit a99fa2f
Show file tree
Hide file tree
Showing 8 changed files with 292,340 additions and 292,336 deletions.
9 changes: 6 additions & 3 deletions 2.online-ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

sys.path.insert(0, os.getcwd())
from helpers import process_text, write_json, read_errors
from knn import KNeighborsClassifier

# Note that knn.py here isn't used, we use this common module
# so that we can later import into spack monitor and install the same class
from online_ml_custom.creme.knn import KNeighbors


def get_parser():
Expand Down Expand Up @@ -102,7 +105,7 @@ def knn(self, model_name="spack-knn-errors", save_prefix="knn"):
"""
Build the knn model with a particular name.
"""
model = creme_features.TFIDF() | KNeighborsClassifier(
model = creme_features.TFIDF() | KNeighbors(
n_neighbors=5, window_size=10000, min_distance_keep=0.05
)

Expand All @@ -115,7 +118,7 @@ def knn(self, model_name="spack-knn-errors", save_prefix="knn"):
# I'm using the model directly since it takes an identifier
print("Training KNN model with modified creme...")
for sentence, uid in self.iter_sentences():
model.fit_one(x=sentence, identifier=uid)
model.fit_one(x=sentence, uid=uid)

# Save clusters to file under data/clusters/<prefix>
cluster_dir = os.path.join(self.datadir, "clusters", save_prefix)
Expand Down

0 comments on commit a99fa2f

Please sign in to comment.