jchen8000 commited on
Commit
30059ee
·
verified ·
1 Parent(s): 042a30c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -2,9 +2,16 @@ import pandas as pd
2
  from sklearn.feature_extraction.text import TfidfVectorizer
3
  from sklearn.metrics.pairwise import linear_kernel
4
  import gradio as gr
5
-
6
- # Load the MovieLens dataset
7
- movies = pd.read_csv('https://files.grouplens.org/datasets/movielens/ml-latest-small.zip', compression='zip')
 
 
 
 
 
 
 
8
 
9
  # Define a TF-IDF Vectorizer Object. Remove all english stop words such as 'the', 'a'
10
  tfidf = TfidfVectorizer(stop_words='english')
 
2
  from sklearn.feature_extraction.text import TfidfVectorizer
3
  from sklearn.metrics.pairwise import linear_kernel
4
  import gradio as gr
5
+ import zipfile
6
+ import requests
7
+ import io
8
+
9
+ # Download and extract the MovieLens dataset
10
+ url = 'https://files.grouplens.org/datasets/movielens/ml-latest-small.zip'
11
+ response = requests.get(url)
12
+ with zipfile.ZipFile(io.BytesIO(response.content)) as z:
13
+ with z.open('ml-latest-small/movies.csv') as f:
14
+ movies = pd.read_csv(f)
15
 
16
  # Define a TF-IDF Vectorizer Object. Remove all english stop words such as 'the', 'a'
17
  tfidf = TfidfVectorizer(stop_words='english')