<jupyter_start><jupyter_text>CONTENT BASED RECOMMENDATION<jupyter_code>showImage('success.jpg')
import re

def anime_title_cleaning(anime_title):
    anime_title = re.sub(r'&quot;','',anime_title)
    anime_title = re.sub(r'.hack//','',anime_title)
    anime_title = re.sub(r'&#039;','',anime_title)
    anime_title = re.sub(r'A&#039;s','',anime_title)
    anime_title = re.sub(r'I&#039;','',anime_title)
    anime_title = re.sub(r'&amp;','',anime_title)
    return anime_title
anime_raw_data['name'] = anime_raw_data['name'].apply(anime_title_cleaning)
from sklearn.feature_extraction.text import TfidfVectorizer
tfv = TfidfVectorizer(max_df=3, max_features=None, strip_accents='unicode', analyzer='word', token_pattern = r'\w{1,}', ngram_range=(1, 3), stop_words='english')
genres = anime_raw_data['genre'].str.split(',').astype(str)
tfv_matrix = tfv.fit_transform(genres)
tfv.get_feature_names_out()
from sklearn.metrics.pairwise import  sigmoid_kernel
sig = sigmoid_kernel(tfv_matrix,tfv_matrix)
indices = pd.Series(anime_raw_data.index, index = anime_raw_data['name'])
def give_content_recommendation(title,sig=sig):
    index = indices[title]

    #Pairwise similarity scores
    sig_scores = list(enumerate (sig[index]))

    #sort 
    sig_scores = sorted(sig_scores, key= lambda x:x[1], reverse = True)

    #top 10 similar
    sig_scores = sig_scores[1:11]
    anime_indices = [i[0] for i in sig_scores]

    return pd.DataFrame({'Anime name':anime_raw_data['name'].iloc[anime_indices].values, 'Rating':anime_raw_data['rating'].iloc[anime_indices].values })
give_content_recommendation('Shingeki no Kyojin')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14996964177292046, 'fraction_numerical': 0.012143290831815421, 'mean_word_length': 6.923076923076923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '597098', 'license': 'MIT', 'n_tokens_mistral': 644, 'n_tokens_neox': 623, 'n_words': 88, 'path': 'EDA.ipynb', 'repo_name': 'petreleven/Anime-Recommendation-Engine', 'size': '1647'}