In [2]:
from IPython.core.display import HTML
HTML("<style>.container { width:100% !important; }</style>")
HTML("<style>div.prompt {display:none}</style>")
Out[2]:

Recomendacion de articulos basados en su contenido

In [3]:
import pandas as pd
import sys
sys.path.append('./Scripts') 
import ContendBased as CB
# Autorecarga los modulos
%load_ext autoreload
%autoreload 2

Importamos los datos

In [4]:
datos = pd.read_csv("BD/people_wiki.csv")
datos.head(3)
Out[4]:
URI name text
0 <http://dbpedia.org/resource/Gigi_Rigamonti> Gigi Rigamonti gigi rigamonti born 8 april 1949 is an italian...
1 <http://dbpedia.org/resource/Steve_Anderson_(m... Steve Anderson (musician) steve anderson was briefly a member of the ban...
2 <http://dbpedia.org/resource/Tenzin_Delek_Rinp... Tenzin Delek Rinpoche lithang tulku tenzin delek rinpoche or tenzing...

Entrenamos el modelo

In [22]:
content_based = CB.ContentBased()
content_based.fit(datos,columna_descripcion='text')

Ejemplo de busqueda

Vamos a buscar los actores que han podido ganar algun oscar: https://en.wikipedia.org/wiki/Academy_Award_for_Best_Actor

Se puede comprobar que de los 5, 4 de ellos ha ganado por lo menos un oscar !!!!

In [23]:
content_based.predict(['Award Actor Oscar'])
Out[23]:
URI name text
185 <http://dbpedia.org/resource/Al_Pacino> Al Pacino alfredo james al pacino ptino born april 25 19...
10267 <http://dbpedia.org/resource/Ethan_Hawke> Ethan Hawke ethan green hawke born november 6 1970 is an a...
12795 <http://dbpedia.org/resource/Ralph_Fiennes> Ralph Fiennes ralph nathaniel twisletonwykehamfiennes ref fa...
3474 <http://dbpedia.org/resource/Daniel_Day-Lewis> Daniel Day-Lewis sir daniel michael blake daylewis kt born 29 a...
4677 <http://dbpedia.org/resource/Michael_Keaton> Michael Keaton michael john douglas born september 5 1951 bet...

Ejemplo de similitud

In [24]:
content_based.predict(datos.query('name == "Al Pacino"').text)
Out[24]:
URI name text
185 <http://dbpedia.org/resource/Al_Pacino> Al Pacino alfredo james al pacino ptino born april 25 19...
12795 <http://dbpedia.org/resource/Ralph_Fiennes> Ralph Fiennes ralph nathaniel twisletonwykehamfiennes ref fa...
10267 <http://dbpedia.org/resource/Ethan_Hawke> Ethan Hawke ethan green hawke born november 6 1970 is an a...
3474 <http://dbpedia.org/resource/Daniel_Day-Lewis> Daniel Day-Lewis sir daniel michael blake daylewis kt born 29 a...
460 <http://dbpedia.org/resource/Jeff_Daniels> Jeff Daniels jeffrey warren jeff daniels born february 19 1...