Skip to content

Instantly share code, notes, and snippets.

View steven-tey's full-sized avatar
👷
building infra for the next trillion links on the web @dubinc

Steven Tey steven-tey

👷
building infra for the next trillion links on the web @dubinc
View GitHub Profile
@steven-tey
steven-tey / model_zappa_settings.json
Created December 7, 2020 05:32
Zappa Settings file for NLP moviebot model
{
"dev": {
"app_function": "app.app",
"profile_name": null,
"project_name": "moviebot",
"runtime": "python3.6",
"s3_bucket": "sugges"
},
"production": {
"app_function": "app.app",
@steven-tey
steven-tey / model_get_recommendations.py
Created December 7, 2020 05:31
Main recommender driver function for model.py
def make_recommendation(query, metadata=metadata):
new_row = metadata.iloc[-1,:].copy()
new_row.iloc[-1] = query
metadata = metadata.append(new_row)
count = CountVectorizer(stop_words='english')
count_matrix = count.fit_transform(metadata['soup'])
cosine_sim2 = cosine_similarity(count_matrix, count_matrix)
sim_scores = list(enumerate(cosine_sim2[-1,:]))
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
ranked_titles = []
@steven-tey
steven-tey / model_connect_aws.py
Created December 7, 2020 05:30
Connecting to AWS S3 Bucket
bucket = "sugges"
s3 = boto3.client('s3', config=Config(connect_timeout=600, read_timeout=600, retries={'max_attempts': 10}))
metadata = pd.read_csv(s3.get_object(Bucket= bucket, Key="metadata.csv")['Body'])
credits_ = pd.read_csv(s3.get_object(Bucket= bucket, Key="credits.csv")['Body'])
keywords = pd.read_csv(s3.get_object(Bucket= bucket, Key="keywords.csv")['Body'])
@steven-tey
steven-tey / model_import_libraries.py
Created December 7, 2020 05:29
Importing libraries for model.py file for NLP Moviebot
from flask import Flask, jsonify, render_template, request
from flask_cors import CORS, cross_origin
import pandas as pd
from ast import literal_eval
import numpy as np
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import boto3
from botocore.config import Config
@steven-tey
steven-tey / CS110 Session 8.2 Pre-Class Work.ipynb
Last active October 30, 2019 19:19
CS110 Session 8.2 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steven-tey
steven-tey / CS146 Session 7.2 Pre-Class Work.ipynb
Last active October 24, 2019 12:25
CS146 Session 7.2 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steven-tey
steven-tey / CS110 Session 7.2 Pre-Class Work.ipynb
Last active October 23, 2019 17:11
CS110 Session 7.2 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steven-tey
steven-tey / CS146 Session 7.1 Pre-Class Work.ipynb
Last active October 22, 2019 12:25
CS146 Session 7.1 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steven-tey
steven-tey / CS110 Session 7.1 Pre-Class Work.ipynb
Last active October 21, 2019 17:07
CS110 Session 7.1 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@steven-tey
steven-tey / CS166 Session 6.2 Pre-Class Work.ipynb
Last active October 17, 2019 16:44
CS166 Session 6.2 Pre-Class Work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.