Cloud Rocket
Seçkin Üye
import pandas as pd
import streamlit as st
st.header('ANIME RECOMMENDER')
df_anime = pd.read_csv('anime.csv')
df_notes = pd.read_csv('rating.csv')
df = pd.merge(df_notes, df_anime.drop('rating', axis=1), on='anime_id')
df.groupby('name')['rating'].count().sort_values(ascending=False).head(10)
notes = pd.DataFrame(df.groupby('name')['rating'].mean())
notes['number of reviews'] = pd.DataFrame(df.groupby('name')['rating'].count())
notes['average rating'] = pd.DataFrame(df.groupby('name')['rating'].mean().round(2))
genre = pd.DataFrame(data=df_anime[['name', 'genre']])
genre.set_index('name', inplace=True)
name_the_anime = st.sidebar.selectbox('Animes', df_anime['name'])
def verificar_genre(list_genre, string):
if any(x in string for x in list_genre):
return True
else:
return False
def recomendar_anime(name_the_anime, n):
genre_anime = genre.loc[name_do_anime].values[0].split(', ')
cols = df_anime[df_anime['genre'].apply(lambda x: verificar_genre(genre_anime, str(x)))]['name'].tolist()
matriz_de_animes = df[df['name'].isin(cols)].pivot_table(index='user_id', columns='name', values='rating')
anime_note = matriz_de_animes[name_the_anime]
anime_similar = matriz_de_animes.corrwith(anime_note)
anime_correlated = pd.DataFrame(anime_similar, columns=['correlated'])
anime_correlated = anime_correlated.join(notes[['number of reviews', 'average rating']])
anime_correlated.dropna(inplace=True)
animes_recommended = anime_correlated[anime_correlated['number of reviews'] > 3000].sort_values(
'correlated', ascending=False)
animes_recommended = animes_recommended.rename_axis('Animes recommended')
return animes_recommended.head(n + 1)
df_final = recomendar_anime(name_the_anime, 5)
st.write('recommended:')
st.dataframe(df_final)
what we need to do? xdNecessary libraries:
import pandas
import streamlit
NOTE : Code written to search for anime genres you like and watch constantly
Python:import pandas as pd import streamlit as st st.header('ANIME RECOMMENDER') df_anime = pd.read_csv('anime.csv') df_notes = pd.read_csv('rating.csv') df = pd.merge(df_notes, df_anime.drop('rating', axis=1), on='anime_id') df.groupby('name')['rating'].count().sort_values(ascending=False).head(10) notes = pd.DataFrame(df.groupby('name')['rating'].mean()) notes['number of reviews'] = pd.DataFrame(df.groupby('name')['rating'].count()) notes['average rating'] = pd.DataFrame(df.groupby('name')['rating'].mean().round(2)) genre = pd.DataFrame(data=df_anime[['name', 'genre']]) genre.set_index('name', inplace=True) name_the_anime = st.sidebar.selectbox('Animes', df_anime['name']) def verificar_genre(list_genre, string): if any(x in string for x in list_genre): return True else: return False def recomendar_anime(name_the_anime, n): genre_anime = genre.loc[name_do_anime].values[0].split(', ') cols = df_anime[df_anime['genre'].apply(lambda x: verificar_genre(genre_anime, str(x)))]['name'].tolist() matriz_de_animes = df[df['name'].isin(cols)].pivot_table(index='user_id', columns='name', values='rating') anime_note = matriz_de_animes[name_the_anime] anime_similar = matriz_de_animes.corrwith(anime_note) anime_correlated = pd.DataFrame(anime_similar, columns=['correlated']) anime_correlated = anime_correlated.join(notes[['number of reviews', 'average rating']]) anime_correlated.dropna(inplace=True) animes_recommended = anime_correlated[anime_correlated['number of reviews'] > 3000].sort_values( 'correlated', ascending=False) animes_recommended = animes_recommended.rename_axis('Animes recommended') return animes_recommended.head(n + 1) df_final = recomendar_anime(name_the_anime, 5) st.write('recommended:') st.dataframe(df_final)
Just install the libraries and run the code like pythonwhat we need to do? xd
oke what it gona do after i build it?Just install the libraries and run the code like python
I use a file in the same csv folder to do the analysisoke what it gona do after i build it?
thanks for the help i was kind of stuck in codeJust install the libraries and run the code like python
so why you are commenting broi don't know im doing the code and i don't know what is happening
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?