Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def avg_title_vec(record, lookup):
- avg_vec = []
- word_vectors = []
- for tag in record['all_titles']:
- titles = clean_token(tag).split()
- for word in titles:
- if word in lookup.value:
- word_vectors.append(lookup.value[word])
- if len(word_vectors):
- avg_vec = [
- float(val) for val in numpy.mean(
- numpy.array(word_vectors),
- axis=0)]
- output = (record['id'],
- ','.join([str(a) for a in avg_vec]))
- return output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement