This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from googleapiclient.discovery import build | |
# developer keys for Youtube V3 API | |
DEVELOPER_KEY = 'YOUR_API_KEY' | |
YOUTUBE_API_SERVICE_NAME = "youtube" | |
YOUTUBE_API_VERSION = "v3" | |
# creating youtube resource object for interacting with api | |
youtube = build(YOUTUBE_API_SERVICE_NAME, | |
YOUTUBE_API_VERSION, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
import cv2 | |
import pandas as pd | |
import numpy as np | |
import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maxlen = 75 | |
output_size = y_train.shape[1] | |
max_features= output_size | |
embed_size = 50 | |
input_size = (maxlen, 1,) | |
def get_model(): | |
global input_size, output_size | |
inp = Input(shape=input_size) | |
x = Embedding(max_features, embed_size)(inp) | |
x = CuDNNGRU(50, return_sequences=True)(inp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
item_index = { str(i):i for i in range(931)} | |
embeddings_index={} | |
f = open( 'data/item_vectors.txt') | |
for line in f: | |
values = line.split() | |
word = values[0] | |
coefs = np.asarray(values[1:], dtype='float32') | |
embeddings_index[word] = coefs | |
f.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gensim.models import Word2Vec | |
model = Word2Vec(item_list, size=50, window=5, min_count=5, workers=10, sg=0) | |
model.wv.save_word2vec_format('data/item_vectors.txt') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from spotlight.sequence.implicit import ImplicitSequenceModel | |
sequential_interaction = implicit_interactions.to_sequence() | |
implicit_sequence_model = ImplicitSequenceModel() | |
implicit_sequence_model.fit(sequential_interaction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from spotlight.factorization.implicit import ImplicitFactorizationModel | |
implicit_model = ImplicitFactorizationModel() | |
implicit_model.fit(implicit_interactions) | |
implicit_model.predict(user_ids, item_ids=None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from spotlight.interactions import Interactions | |
implicit_interactions = Interactions(user_ids, item_ids) | |
explicit_interactions = Interactions(user_ids, item_ids, ratings) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_ted.wv.most_similar("Gastroenteritis") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_ted.wv.most_similar(“shht”) |