<jupyter_start><jupyter_text><jupyter_code>from numpy import dot
from numpy.linalg import norm
import numpy as np
def cos_sim(A, B):
       return dot(A, B)/(norm(A)*norm(B))

doc1 = np.array([1,0,1,1,1,])
doc2 = np.array([2,1,0,1,1,])
doc3 = np.array([3,2,0,2,2,])
cos_sim(doc1, doc2)
cos_sim(doc1, doc3)

id : RmqV8FRJNSg2N91ykdKS
secret key : Vkqv9j1hmw
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
corpus = [
    'you know I want your love',
    'I like you',
    'what should I do ',    
]

tfidf = TfidfVectorizer()
tfidf.fit_transform(corpus).toarray()<jupyter_output><empty_output><jupyter_text>recommanded with cos simuliatydata from https://www.kaggle.com/rounakbanik/the-movies-dataset/version/7?select=movies_metadata.csv<jupyter_code>import pandas as pd
df_data = pd.read_csv('./movies_metadata.csv')
df_data.head(3)
df_data.columns
data = df_data.head(10000)
data = data.dropna()
data.info()
from sklearn.feature_extraction.text import TfidfVectorizer

tfidf = TfidfVectorizer()
tfidf_matrix = tfidf.fit_transform(data['overview'])
tfidf_matrix.shape
len(tfidf.vocabulary_)
print(tfidf_matrix[4].toarray())
from sklearn.metrics.pairwise import linear_kernel
cosin_sim = linear_kernel(tfidf_matrix, tfidf_matrix)
type(cosin_sim), cosin_sim.shape
cosin_sim[3]
indeces = pd.Series(data.index, index=data['title']).drop_duplicates()
indeces.head(5)
indeces['From Dusk T<NAME>']
list(cosin_sim[69])
cosin_list = list(enumerate(cosin_sim[69]))
cosin_list
cosin_index = sorted(list(cosin_list, key=lambda x:x[1], reverse=True)
# cosin_index[1:11]
data.iloc[]movie<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup