What I’m trying to do:
I am building a movie recommendation system with Jupyter but now i would like to use Anvil as my user interface .
What I’ve tried and what’s not working:
I have tried to link it with the uplink and pip installed anvil, but my biggest problem is the coding aspect. I dont know what i am doing wrong…somebody help me pleaseeeeeeeee…what am i doing wrong!
So i imported a .csv table from excel with movies and ratings, using cosine similarity which i imported into jupyter, i want to recommend movies to people using the movie title’ they input in Anvil and show them their recommendations on anvil not on Jupyter.
Code Sample:
# code snippet
import pandas as pd
import numpy as np
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.feature_extraction.text import CountVectorizer
df = pd.read_csv(r"C:\Users\Administrator\Desktop\Movie_data.csv")
columns = ['Actors', 'Director', 'Genre', 'Title']
def get_important_features(data):
important_features = []
for i in range(0, data.shape[0]):
important_features.append(
data['Actors'][i] + ' ' + data['Director'][i] + ' ' + data['Genre'][i] + ' ' + data['Title'][i])
return important_features
df['important_features'] = get_important_features(df)
cm = CountVectorizer().fit_transform(df['important_features'])
cs = cosine_similarity(cm)
title = input()
movie_id = df[df.Title == title]['Rank'].values[0]
scores = list(enumerate(cs[movie_id]))
sorted_scores = sorted(scores, key=lambda x: x[1], reverse=True)
sorted_scores = sorted_scores[1:]
```import anvil.server
anvil.server.connect("R6SRBVR4NBPZCVOG6DCMY7NL-6RH3VF3YI5END64F")
@anvil.server.callable
def here(title):
j=0
print('The top 10 most recommended movies to', title, 'are:\n')
for item in sorted_scores:
movie_title= df[df.Rank == item[0]]['Title'].values[0]
b=j+1, movie_title
print(b)
j= j+1
if j>9:
break
return b
anvil.server.wait_forever()
Clone link:
*share a copy of your app*
https://anvil.works/build#clone:6RH3VF3YI5END64F=PXCH46JSQXKLIDSXXM5FXY4K