почему я получаю эту ошибку в комбинированных функциях, почему она появляется и показывает, почему df или локальные переменные присвоены
def recommendation(Movie):
Movie = Movie.lower()
try:
df.head()
cosine_sim.shape
except:
cosine_sim = recommender_sim()
if Movie not in df['title'].unique():
return('Search for another Movies')
else:
indices = pd.Series(df.index, index=df['title'])
# Get the index of the movie that matches the title
idx = indices[title]
# Get the pairwsie similarity scores of all movies with that movie
sim_scores = list(enumerate(cosine_sim[idx]))
# Sort the movies based on the similarity scores
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)
# Get the scores of the 10 most similar movies
sim_scores = sim_scores[1:11]
sim_scores = []
for i in range(len(sim_scores)):
movie_indices = sim_scores[i][0]
sim_scores.append(df['title'][movie_indices])
return sim_scores
def recommend(request):
if request.method == 'GET':
movie = request.GET['movie']
movies = recommendation(movie)
movie = movie.upper()
if type(movies) == type('string'):
return HttpResponse('recommend.html', movie=movie, movies=movies, t='s')
else:
return HttpResponse('recommend.html', movie=movie, movies=movies, t='sim_scores')
return render(request, 'recommend.html')