Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')
|