This file contains 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
{ | |
"dev": { | |
"app_function": "app.app", | |
"profile_name": null, | |
"project_name": "moviebot", | |
"runtime": "python3.6", | |
"s3_bucket": "sugges" | |
}, | |
"production": { | |
"app_function": "app.app", |
This file contains 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
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 = [] |
This file contains 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
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']) |
This file contains 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 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.