Skip to content
Snippets Groups Projects
Unverified Commit 07e635c6 authored by Siraj R Aizlewood's avatar Siraj R Aizlewood
Browse files

Merge branch 'simple_classification' of...

Merge branch 'simple_classification' of https://github.com/aurelio-labs/semantic-layer into simple_classification
parents 79e9c54b 029f41f0
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,14 @@ class DecisionLayer: ...@@ -15,14 +15,14 @@ class DecisionLayer:
for decision in decisions: for decision in decisions:
self._add_decision(decision=decision) self._add_decision(decision=decision)
def __call__(self, text: str, _tan=False, _threshold=0.5):
def __call__(self, text: str, _tan: bool=True, _threshold: float=0.5):
results = self._query(text) results = self._query(text)
predicted_class, scores_by_class = self.simple_classify(results, _tan=_tan, _threshold=_threshold) decision = self._semantic_classify(results, apply_tan=_tan, threshold=_threshold)
return predicted_class # return decision
return decision
def add(self, decision: Decision):
def add(self, decision: Decision, dimensiona):
self._add_decision(devision=decision) self._add_decision(devision=decision)
def _add_decision(self, decision: Decision): def _add_decision(self, decision: Decision):
...@@ -59,8 +59,9 @@ class DecisionLayer: ...@@ -59,8 +59,9 @@ class DecisionLayer:
{"decision": d, "score": s.item()} for d, s in zip(decisions, scores) {"decision": d, "score": s.item()} for d, s in zip(decisions, scores)
] ]
def simple_classify(self, query_results: dict, _tan: bool=False, _threshold=0.5):
"""Given some text, categorises it based on the scores from _query.""" def _semantic_classify(self, query_results: dict, apply_tan: bool=True, threshold: float=0.5):
"""Given some text, categorizes."""
# apply the scoring system to the results and group by category # apply the scoring system to the results and group by category
scores_by_class = {} scores_by_class = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment