2章 その13

p.29より、今度はアイテムベースの協調フィルタリングで推薦をする


irb

>> itemsim = c.calculateSimilarItems(prefs,50)
100/1664
200/1664
300/1664

1664件読み込むのに3分ぐらいかかる


87番のユーザに推薦

>> pp c.getRecommendedItems(prefs, itemsim, '87')[0..30]
[{5.0=>"Jason's Lyric (1994)"},
 {5.0=>"Oscar & Lucinda (1997)"},
 {5.0=>"War at Home, The (1996)"},
 {4.89698307579102=>"Mr. Wonderful (1993)"},
 {4.85943279901356=>"Total Eclipse (1995)"},
 {4.77544367982615=>"Steal Big, Steal Little (1995)"},
 {4.76470588235294=>"Love Is All There Is (1996)"},
 {4.69283276450512=>"Original Gangstas (1996)"},
 {4.67307692307692=>"Wooden Man's Bride, The (Wu Kui) (1994)"},
 {4.65999053777007=>"Paper, The (1994)"},
 {4.65853658536585=>"Half Baked (1998)"},
 {4.64996315401621=>"Withnail and I (1987)"},
 {4.64318266161954=>"Unforgettable (1996)"},
 {4.6349866189525=>"Trial by Jury (1994)"},
 {4.60698884097275=>"Looking for Richard (1996)"},
 {4.60182602762241=>"Year of the Horse (1997)"},
 {4.56497175141243=>"Kicking and Screaming (1995)"},
 {4.53947368421053=>"Wild Things (1998)"},
 {4.53684210526316=>"Innocents, The (1961)"},
 {4.52777777777778=>"Assignment, The (1997)"},
 {4.52550741575386=>"Gaslight (1944)"},
 {4.52380952380952=>"Wonderland (1997)"},
 {4.52072860588567=>"Angus (1995)"},
 {4.52=>"Grace of My Heart (1996)"},
 {4.50752214916384=>"Winter Guest, The (1997)"},
 {4.5=>"Modern Affair, A (1995)"},
 {4.49397590361446=>"Twelfth Night (1996)"},
 {4.48717948717949=>"Metro (1997)"},
 {4.48543902582396=>"Stupids, The (1996)"},
 {4.46835443037975=>"Mallrats (1995)"},
 {4.46731126893836=>"Vanya on 42nd Street (1994)"}]
=> nil


何人か推薦だしてみるが、たしかにgetRecommendedItemsの処理は重いところを先にやってある分はやい。

>> c.getRecommendedItems(prefs, itemsim, '50')[0..30]
=> [{5.0=>"Cutthroat Island (1995)"}, {5.0=>"Mask, The (1994)"}, {5.0=>"Unforgiven (1992)"}, {4.9122905656134=>"Starship Troopers (1997)"}, {4.90522392150414=>"GoodFellas (1990)"}, {4.88397550594014=>"Rocket Man (1997)"}, {4.85=>"Sting, The (1973)"}, {4.8121546961326=>"Aladdin (1992)"}, {4.77748460861917=>"Two Much (1996)"}, {4.74223363286264=>"Clueless (1995)"}, {4.74010327022375=>"Coneheads (1993)"}, {4.73248302136823=>"Spellbound (1945)"}, {4.70899470899471=>"12 Angry Men (1957)"}, {4.68281938325991=>"Graduate, The (1967)"}, {4.6734693877551=>"Demolition Man (1993)"}, {4.64179104477612=>"D3: The Mighty Ducks (1996)"}, {4.625=>"Love and Death on Long Island (1997)"}, {4.62025316455696=>"White Squall (1996)"}, {4.61971830985915=>"My Best Friend's Wedding (1997)"}, {4.60981468404334=>"Addams Family Values (1993)"}, {4.60294117647059=>"Sabrina (1995)"}, {4.58379438728532=>"Nightmare Before Christmas, The (1993)"}, {4.55714285714286=>"Professional, The (1994)"}, {4.54482428878795=>"Game, The (1997)"}, {4.53435972907606=>"Strange Days (1995)"}, {4.53378671278148=>"So I Married an Axe Murderer (1993)"}, {4.51823563971618=>"Life Less Ordinary, A (1997)"}, {4.51111111111111=>"Man Without a Face, The (1993)"}, {4.51037797684073=>"What's Eating Gilbert Grape (1993)"}, {4.48913043478261=>"Fantasia (1940)"}, {4.45015105740181=>"Wonderland (1997)"}]
>> c.getRecommendedItems(prefs, itemsim, '33')[0..30]
=> [{5.0=>"With Honors (1994)"}, {5.0=>"Kim (1950)"}, {4.83333333333333=>"Colonel Chabert, Le (1994)"}, {4.75=>"Wooden Man's Bride, The (Wu Kui) (1994)"}, {4.68965517241379=>"Fall (1997)"}, {4.62962962962963=>"Man from Down Under, The (1943)"}, {4.48387096774194=>"Madame Butterfly (1995)"}, {4.31818181818182=>"Heaven's Prisoners (1996)"}, {4.29808374733854=>"Tango Lesson, The (1997)"}, {4.22727272727273=>"Getting Away With Murder (1996)"}, {4.20361990950226=>"Candidate, The (1972)"}, {4.10975328568135=>"Blink (1994)"}, {4.07352941176471=>"Good Man in Africa, A (1994)"}, {4.06562901231916=>"Blue Angel, The (Blaue Engel, Der) (1930)"}, {4.04443969272555=>"Audrey Rose (1977)"}, {4.02358223169543=>"Braindead (1992)"}, {4.01726618705036=>"Harlem (1993)"}, {4.01158214155874=>"Chungking Express (1994)"}, {4.0=>"Pest, The (1997)"}, {3.96085861299851=>"My Family (1995)"}, {3.95493778916578=>"Until the End of the World (Bis ans Ende der Welt) (1991)"}, {3.92176990636611=>"Jane Eyre (1996)"}, {3.91015252454701=>"Speechless (1994)"}, {3.90855803048066=>"Little Rascals, The (1994)"}, {3.90670778720123=>"Sixth Man, The (1997)"}, {3.88607847351314=>"Apple Dumpling Gang, The (1975)"}, {3.88111888111888=>"D3: The Mighty Ducks (1996)"}, {3.85881491523458=>"Washington Square (1997)"}, {3.84247612775766=>"Spellbound (1945)"}, {3.83809344487183=>"Sabrina (1995)"}, {3.83442838370565=>"Fearless (1993)"}]
>> c.getRecommendedItems(prefs, itemsim, '3')[0..30]
=> [{5.0=>"unknown"}, {5.0=>"Band Wagon, The (1953)"}, {4.5=>"Truth About Cats & Dogs, The (1996)"}, {4.35593220338983=>"Bad Boys (1995)"}, {4.33875890132248=>"Gordy (1995)"}, {4.33031510322347=>"Great White Hype, The (1996)"}, {4.27027027027027=>"Colonel Chabert, Le (1994)"}, {4.23076923076923=>"French Twist (Gazon maudit) (1995)"}, {4.09090909090909=>"Tin Drum, The (Blechtrommel, Die) (1979)"}, {4.05882352941176=>"Stargate (1994)"}, {4.05153076689906=>"If Lucy Fell (1996)"}, {4.04211456331576=>"Killing Fields, The (1984)"}, {4.04160267211428=>"Clockwork Orange, A (1971)"}, {4.01075268817204=>"Kids in the Hall: Brain Candy (1996)"}, {4.00986528528783=>"Aladdin and the King of Thieves (1996)"}, {4.0=>"Phantoms (1998)"}, {3.93856570948451=>"Tango Lesson, The (1997)"}, {3.8514335360556=>"Jungle Book, The (1994)"}, {3.82917497994529=>"Sixth Man, The (1997)"}, {3.82608695652174=>"Cutthroat Island (1995)"}, {3.7625558413429=>"Assignment, The (1997)"}, {3.73913043478261=>"World of Apu, The (Apur Sansar) (1959)"}, {3.73333333333333=>"Peacemaker, The (1997)"}, {3.71737486421949=>"Money Talks (1997)"}, {3.687563642426=>"Fatal Instinct (1993)"}, {3.68428153811558=>"Winter Guest, The (1997)"}, {3.65924383130112=>"Braindead (1992)"}, {3.63309307622703=>"Demolition Man (1993)"}, {3.63257265913226=>"Blue Angel, The (Blaue Engel, Der) (1930)"}, {3.62765957446809=>"Saint, The (1997)"}, {3.58884626181342=>"Murder in the First (1995)"}]