Skip to content

Commit

Permalink
Update the formula
Browse files Browse the repository at this point in the history
  • Loading branch information
agb94 committed Jul 4, 2018
1 parent e5890f5 commit 0bfed64
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def analyzer(s: str):
curr_token += c
return tokens

def compute_score(TSNB, TSB, LS, TI, LI, TL, LL):
#def compute_score(TSNB, TSB, LS, TI, LI, TL, LL):
def compute_score(TSB, LS, TI, LI, TL, LL):
from math import sin, cos
from operator import add, sub, mul, neg

Expand All @@ -33,18 +34,17 @@ def protectedDiv(left, right):

div = lambda a, b: protectedDiv(a, b)

# GP-learned model (Learning-to-Rank)
# This is dummy, not the final one
return neg(add(mul(TSB, sub(sin(neg(add(TSNB, TSB))), LS)), LI))
# GP-learned Formula (Learning-to-Rank)
return neg(add(mul(TSB, sub(sin(neg(LI)), LS)), LI))

def predict_unit(ingredient: str, source: list):
assert type(ingredient) == str
assert type(source) == list and all(type(line) == str for line in source)

# Use sklearn's CountVectorizer for BOW
vectorizers = [
CountVectorizer(ngram_range=(1,1), lowercase=False, binary=False, analyzer=analyzer),
CountVectorizer(ngram_range=(1,1), lowercase=False, binary=True, analyzer=analyzer)
#CountVectorizer(ngram_range=(1,1), lowercase=False, binary=False, analyzer=analyzer), #TSNB
CountVectorizer(ngram_range=(1,1), lowercase=False, binary=True, analyzer=analyzer) #TSB
]

vectors = [ vectorizer.fit_transform([ingredient] + source).toarray() for vectorizer in vectorizers ]
Expand Down

0 comments on commit 0bfed64

Please sign in to comment.