Skip to content

Instantly share code, notes, and snippets.

View srang992's full-sized avatar

Subhradeep Rang srang992

  • India
View GitHub Profile
@srang992
srang992 / import.py
Created April 16, 2022 07:57
importing necessary libraries for making a simple recommendation system
import pandas as pd
import numpy as np
import re
import nltk
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
nltk.download('stopwords')
nltk.download('punkt')
from nltk import word_tokenize
from nltk.corpus import stopwords
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
show_id,type,title,director,cast,country,date_added,release_year,rating,duration,listed_in,description
s1,Movie,Dick Johnson Is Dead,Kirsten Johnson,,United States,"September 25, 2021",2020,PG-13,90 min,Documentaries,"As her father nears the end of his life, filmmaker Kirsten Johnson stages his death in inventive and comical ways to help them both face the inevitable."
s2,TV Show,Blood & Water,,"Ama Qamata, Khosi Ngema, Gail Mabalane, Thabang Molaba, Dillon Windvogel, Natasha Thahane, Arno Greeff, Xolile Tshabalala, Getmore Sithole, Cindy Mahlangu, Ryle De Morny, Greteli Fincham, Sello Maake Ka-Ncube, Odwa Gwanya, Mekaila Mathys, Sandi Schultz, Duane Williams, Shamilla Miller, Patrick Mofokeng",South Africa,"September 24, 2021",2021,TV-MA,2 Seasons,"International TV Shows, TV Dramas, TV Mysteries","After crossing paths at a party, a Cape Town teen sets out to prove whether a private-school swimming star is her sister who was abducted at birth."
s3,TV Show,Ganglands,Julien Leclercq,"Sami Bouajila, Tracy Gotoas
@srang992
srang992 / clean_desc.py
Created April 16, 2022 09:10
function for cleaning data
def clean_desc(s):
s = str(s)
s = s.lower()
s = re.sub(r'[^a-zA-Z]', ' ', s)
return s
# make a copy of the main data and do the preprocessing steps on that data
netflix_data_copy['clean_desc'] = netflix_data_copy['description'].apply(cleaning)
#tokenizing the words for lemmatization and removing stopwords
@srang992
srang992 / tfidf.py
Created April 16, 2022 13:22
converting the words into vectors
# making an object of TfidfVectorizer in which words contains only in 1 document and word repeated in 70% of documents are ignored.
tfidf = TfidfVectorizer(min_df = 2, max_df = 0.7)
# fitting the cleaned text in TfidfVectorizer
X = tfidf.fit_transform(netflix_data_copy['clean_desc'])
# making a suitable dataframe for calculating the cosine similarity and save it
@srang992
srang992 / recommend.py
Created April 16, 2022 13:52
recommend movies
def recommend_table(list_of_movie_enjoyed, tfidf_data, movie_count=20):
"""
function for recommending movies
:param list_of_movie_enjoyed: list of movies
:param tfidf_data: self-explanatory
:param movie_count: no of movies to suggest
:return: dataframe containing suggested movie
"""
movie_enjoyed_df = tfidf_data.reindex(list_of_movie_enjoyed)
user_prof = movie_enjoyed_df.mean()
@srang992
srang992 / app.py
Created April 16, 2022 14:49
main streamlit app
"""
main streamlit app
"""
import pickle
import pandas as pd
import streamlit as st
from streamlit import session_state as session
from src.recommend.recommend import recommend_table
@srang992
srang992 / app_import.py
Created April 17, 2022 03:38
necessary modules for streamlit app
import pickle
import pandas as pd
import streamlit as st
from streamlit import session_state as session
from src.recommend.recommend import recommend_table
@srang992
srang992 / load_file.py
Created April 17, 2022 03:49
file load
@st.cache(persist=True, show_spinner=False, suppress_st_warning=True)
def load_data():
"""
load and cache data
:return: tfidf data
"""
tfidf_data = pd.read_csv("data/tfidf_data.csv", index_col=0)
return tfidf_data
@srang992
srang992 / app.py
Created April 17, 2022 03:57
main streamlit app
dataframe = None
st.title("""
Netflix Recommendation System
This is an Content Based Recommender System made on implicit ratings :smile:.
""")
st.text("")
st.text("")
st.text("")
@srang992
srang992 / test_web.html
Last active April 20, 2022 02:25
sample html
<html>
<body>
<div>
<p>Hello World!</p>
<div>
<p>Choose me!</p>
</div>
</div>
<div>
<p>Why are you not looking at me?</p>