<jupyter_start><jupyter_text>Input Beer Recommender Engine  In this notebook we make an item based recommender system to input a BEER which likes one user and GET the TOP 5 SIMILAR BEERS<jupyter_code>import pandas as pd
import numpy as np
from matplotlib import pyplot
%matplotlib inline
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
df = pd.read_csv('df_to_recommender.csv')
df.shape
rated = df.num_rated_beers
stats = rated.describe()
stats
df=df[['user_id', 'profile_name', 'Id', 'names', 'num_rated_beers', 'style','overall']].copy()
ratings = df.pivot_table(values='overall', index='user_id', columns='names')
ratings.fillna(0, inplace=True)
beer_index = ratings.columns
ratings.shape
ratings.head()
corr_matrix= np.corrcoef(ratings.T)
corr_matrix.shape
def get_top_beers (a):
    favoured_beer_index = list(beer_index).index(a)
    P = corr_matrix[favoured_beer_index]
#solo devolvemos las cervezas con la mayor correlación con bearded Pat's Barleywin
    return(list(beer_index[(P>0.5) & (P<1.0)][:5]))<jupyter_output><empty_output><jupyter_text>Check the function<jupyter_code>get_top_beers(' Orange Blossom')<jupyter_output><empty_output><jupyter_text>Make a dropdown list application  Select a beer in the dropdown list below, and get your top 5 recommendations!<jupyter_code>import ipywidgets as widgets
from ipywidgets import interactive
 
items = sorted(df['names'].unique().tolist())

def view(x=''):
    if x==x: return(get_top_beers(x))
     
    
w = widgets.Select(options=items)
interactive(view, x=w)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11674150096215523, 'fraction_numerical': 0.005772931366260423, 'mean_word_length': 6.878787878787879, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '368386', 'license': 'MIT', 'n_tokens_mistral': 569, 'n_tokens_neox': 551, 'n_words': 134, 'path': 'Recommender engine/recommender_beer_input.ipynb', 'repo_name': 'alejandronotario/recommender-system', 'size': '1559'}