From feeeaf2df42d9445958079495e8345838652c106 Mon Sep 17 00:00:00 2001 From: Pipat Saengow Date: Sun, 27 Aug 2023 19:31:58 +0700 Subject: [PATCH] reduce model size --- cgrcompute/components/courserecommendation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cgrcompute/components/courserecommendation.py b/cgrcompute/components/courserecommendation.py index bae5f6e..66da861 100644 --- a/cgrcompute/components/courserecommendation.py +++ b/cgrcompute/components/courserecommendation.py @@ -27,7 +27,7 @@ def train(observations: list[set[Hashable]]) -> 'CosineSimRecommendationModel': neigh = [] for c in sim.getrow(i).nonzero()[1]: neigh.append((items[c], sim[i, c])) - neigh = sorted(neigh, key=lambda x: x[1])[-300:] + neigh = sorted(neigh, key=lambda x: x[1])[-100:] ccmtx[cid] = dict(neigh) return CosineSimRecommendationModel(ccmtx) @@ -42,7 +42,7 @@ def infer(self, selected_item: list[Hashable]) -> dict[Hashable, float]: d[pcid] += scr except KeyError: pass - return dict(sorted(d.items(), key=lambda x: x[1])[-300:]) + return dict(sorted(d.items(), key=lambda x: x[1])[-100:]) class CourseRecommendationModel: @@ -60,7 +60,7 @@ def populate(self): def infer(self, selected_courses): res = self.model.infer(selected_courses) res = sorted(res.items(), key=lambda x:-x[1]) - return [course for course, score in res][:300] + return [course for course, score in res][:100] def downloadobsvdata(self, es: ElasticService): self.logger.info('Download observation') @@ -77,7 +77,7 @@ def downloadobsvdata(self, es: ElasticService): cnt += 1 if cnt % 10000 == 0: self.logger.info("Downloaded {} observations".format(cnt)) - if cnt >= 900000: + if cnt >= 100000: break self.logger.info('Received {} observations'.format(cnt)) obsv = [l for _, l in obsv.items() if len(l) > 4]