In [1]:
%matplotlib inline
import alpenglow as ag
import alpenglow.Getter as rs
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import alpenglow.experiments
import alpenglow.evaluation
In [2]:
data = pd.read_csv(
"python/test_alpenglow/test_data_4",
sep=' ',
header=None,
names=['time', 'user', 'item', 'id', 'score', 'eval']
)
In [3]:
exp = ag.OfflineModel()
In [4]:
exp.fit(data)
In [5]:
def predict(model, user, item):
rd = rs.RecDat()
rd.user = user
rd.item = item
return model.prediction(rd)
In [6]:
errors = [(1-predict(exp.model, u, i))**2 for (u,i) in data[['user','item']].values]
In [7]:
np.sqrt(pd.Series(errors)).mean()
Out[7]:
0.29222296412604876
In [8]:
exp.predict(data[['user','item']])
Out[8]:
[0.9668979386476292,
0.9417665718844833,
0.9933654125393688,
0.9848558523804352,
0.9817566774001023,
1.1661315139038164,
0.9887016690548583,
1.005446495808034,
0.998162584108844,
1.025667531262195,
0.9546953942929735,
1.0153770824302297,
1.0012088354291004,
0.987442505729575,
1.07442279064002,
1.1967690719512991,
0.9289185214383435,
1.3144657578380183,
0.5677282889661542,
0.9858796370953651,
0.9767453168603903,
0.9913658974393601,
0.9850473952762439,
1.0010229778103816,
0.9920124806074466,
0.9768897177062688,
1.0428739365006705,
0.8406116830662264,
1.0067363938924705,
0.9947762899930859,
1.0001232932472992,
0.9626645742068772,
1.0015976130870494,
1.0047549500765862,
1.0149210348663684,
1.0528142628370105,
1.022678696255703,
1.0668660082880184,
1.10756681460296,
1.129991901577677,
1.2217188047387706,
1.0173990626522456,
1.0243126505445133,
1.0110498874509384,
1.0047807377818927,
1.02934874723683,
1.2051516011534065,
0.9443268639004005,
1.0139688943313452,
0.9297978533393105,
1.0498196820074353,
1.1910601628477808,
1.181128319577348,
0.7955167025166885,
1.1545734879583494,
1.0086604468940812,
0.8517209189211262,
0.7979393919986282,
1.0011176997050715,
1.329608149510958,
0.968576363700838,
0.9934268200806663,
0.14090692194456075,
0.7334287086214033,
0.8619069651774763,
0.9767692732871204,
0.9004018581984069,
1.0301658486251144,
1.1245026751704468,
0.8141504862697765,
1.1017539003431724,
0.994961062700447,
0.8808643128248355,
1.1818768812213971,
0.994557568980589,
1.0619189495393324,
0.9980363458198626,
1.2325243811657574,
1.0111379699037921,
1.0309919311966673,
1.2718978980750668,
0.8878880672511008,
1.0048894091966631,
1.0041262439796446,
1.1619388749282926,
1.1388144904001634,
1.0280044293055293,
0.5180403578949422,
0.8362032376744525,
0.9940995023107049,
1.1452793927955778,
0.9036028917158961,
0.9954870664652663,
0.7156852461505194,
0.9851867679577496,
0.9903172218342943,
0.5599027722236564,
1.000705113555397,
1.0167000791993166,
0.7841111485304516,
0.999811564461526,
0.6842669924875352,
0.9865220294756671,
0.9735977201908889,
0.7632992550147092,
0.7700464490829491,
0.9278910011268477,
1.0306402511140556,
0.7465874989684936,
0.9378267411611338,
1.0248304424436767,
0.9956995526470441,
0.6252788203719136,
1.2672180196900684,
0.624218989639406,
0.7424666716542577,
1.222001809919349,
1.0160094538287283,
0.968065603300367,
0.8707511490880583,
1.0244052436780746,
0.995790874558099,
1.0102734707461383,
1.0169668036617452,
0.8439260989182114,
0.9942704587667761,
0.47962030015032947,
1.0222815121757072,
0.7420977719197046,
0.8418851004983643,
1.0239260783245645,
0.4571631664726956,
0.6770593717741222,
1.0190091665140577,
0.9147717861416718,
1.0011477126603288,
0.7972713460260588,
0.9909278352004742,
1.063188624134487,
0.9305335539209336,
1.0116052091203376,
0.4081221011208849,
0.8835413115094495,
0.8834866964570112,
0.6118514756455755,
0.7617259525226137,
1.034974367687762,
0.925706098102179,
0.9001604995933967,
0.8978729511728369,
0.7838230157433904,
0.8107751509168869,
0.9936127045303875,
0.962937191165287,
1.0253006353213994,
0.6278499493635025,
0.5003931011808083,
0.6410245084651937,
0.7655244282965342,
0.5678103172123311,
0.8804212887782576,
0.8627638014209753,
1.0163368297990967,
0.6291313295542504,
1.1643465534415445,
1.1046420640220203,
1.0041167754276872,
0.9769881520514165,
0.9914542825087487,
0.996293269628101,
0.8206845200913784,
0.8391164569570715,
0.9927153953201826,
1.003173700606979,
0.6274241370540626,
1.0592165527118902,
1.029301445526826,
0.9561512855822396,
0.636643840690182,
0.9874319077236287,
0.5044426130192147,
0.5478953408335214,
0.9925756649035233,
1.001151209572267,
1.2508108815299956,
1.2431623585283396,
0.994814500968998,
0.9927050563410778,
0.40437569521245686,
0.9895876397613277,
0.5115045388655762,
0.9912096244812107,
0.6114679739775993,
0.7824709434984155,
0.4128006890372931,
1.175165435124455,
0.996430429437069,
0.5950534490377226,
0.7252825738779571,
1.1075800778494798,
0.48422171462360947,
0.7635850308997817,
1.4160963496209902,
0.7722113224330106,
1.0083971180794848,
0.4812297946182207,
0.9799013230956237,
0.9849812702814409,
0.9905988782750331,
1.0115873004307492,
0.9928126367136921,
0.8186330311562665,
0.9955559903397772,
0.8190671687140811,
0.7824578314250202,
0.941200577187872,
0.9849548089847826,
0.9823289878114968,
0.9333114873247745,
0.9985245096476565,
0.7560142967517309,
1.3207889724573092,
0.9259810822815213,
0.8101312322292284,
0.9944565410047387,
0.9929405391965888,
0.9926862090970994,
0.9747417795412441,
0.8223013785805008,
0.9151342915285405,
0.7026163539278283,
0.38162652025074034,
0.6554166152544033,
0.9929143624366644,
0.893430577159698,
0.4445825176098178,
0.9363549305768065,
0.3588359525530993,
0.7726833263671435,
1.0340008321064866,
0.4922443236936404,
1.0081566515099945,
0.9929629595199511,
0.9794287670249792,
0.20590757591045314,
0.9915148956780787,
0.7815988084251069,
0.9885576328761778,
0.9951019579276861,
0.5401250138278265,
0.5764305209314831,
0.5813860283604577,
0.9295921901429682,
1.0409572984980193,
0.995549379237315,
0.6152924597282377,
1.25269868834454,
0.6544496832701182,
1.104025596710712,
1.0121866327205173,
0.5741845057523199,
0.7623236830401847,
0.4929869916161028,
0.939403304820931,
0.9869253801217361,
0.5490423057295514,
0.9999989857361814,
0.588689132566965,
0.7582978754890565,
0.4736736855419251,
1.139883017557731,
0.8264074566492269,
0.9943655036136014,
0.9909579705145205,
0.4611523902507778,
0.7808970711757292,
1.0085735329254972,
0.9969741848306202,
0.5567208753346444,
0.5779148820006459,
1.2782575520464474,
0.7027862308867202,
1.014679172806849,
0.5393112050141056,
0.7338878448343301,
0.8158896975771106,
0.9937534869180273,
0.7005873673439025,
0.8505634744863275,
0.9845616681400515,
0.9559932316374212,
0.6964093271935954,
0.2372265172956455,
0.7674776460763553,
1.25668863956612,
0.9671462679483644,
1.0085095769076415,
0.664429056955493,
1.0062005206709939,
1.0214652579828292,
0.4636979713670938,
0.24841585656080375,
1.0210437154624323,
0.4157586266301777,
0.980413327532856,
0.6579363092411338,
1.0230337788916217,
1.0822767515344711,
1.0028812807073053,
0.9961617710166245,
0.7229151210354425,
0.9569372543861427,
0.48403165519943236,
0.5998118770177243,
1.0196284862729341,
0.692261498069244,
1.018022150524315,
1.0339697633139293,
0.5538839747249926,
0.9911465753799502,
0.9692400237678122,
0.635105302760046,
0.701300432432054,
0.9928143449207437,
0.7743340400178346,
0.9919619648144967,
0.882458168130733,
1.0021880895399224,
0.8269643536864187,
0.9955085087308573,
0.8868461567260743,
1.0462581475007873,
0.5827822112677723,
0.4845029342699123,
0.7474558538666597,
0.9901235346924122,
1.0273257140917995,
0.8078950164254951,
0.5143498343847698,
0.6503671339843822,
0.6951650604986064,
1.0176279151250038,
0.9924602462323483,
0.6081174783080103,
0.6794615749039463,
0.11910665761694259,
0.7600311272589212,
0.9174949763186511,
1.020394414923931,
0.13731154108952198,
0.5594314669969243,
0.993168513588002,
0.4933070175554733,
0.9962748915267224,
0.9648319731459865,
0.9957885015299559,
1.0377209184545453,
0.44233001139913336,
0.7088959153569021,
1.2035755515958824,
0.4296258817042737,
0.49084423310045094,
0.11922869190610427,
0.9894126240591179,
1.0105696119992083,
0.29868347977151544,
0.620710937978606,
0.9930347933596273,
0.9796614764831939,
0.7774044019014547,
0.6063399857677886,
0.43271107595881875,
0.45181409208533674,
0.40708587086827097,
0.32197846249806494,
0.9832924764244655,
1.0884388977045336,
0.9997107493627494,
0.8795354832913714,
0.6834693562125742,
0.6201050357429738,
0.7480742920646166,
1.0823022689132713,
0.73578219451689,
0.8465894780651082,
0.3648271279540217,
0.6322249721058765,
0.9979053966131358,
0.3056572585802792,
0.5278248855269563,
0.9919927420585241,
1.0138916970614316,
0.9926286489832782,
0.9153613058460373,
0.8251883656559553,
0.5504572740361453,
1.0660756064304189,
0.8611555864289576,
0.49024009575762806,
0.6859583966558175,
0.6340441327702635,
0.9467487671576902,
0.8432682628420034,
0.9952891332177403,
0.6261048852027712,
0.7065584969876265,
0.5832988160683612,
0.15212086417940127,
0.9692368505275881,
0.37101110408397875,
0.7170290178067726,
0.9960919286622106,
0.9935595632634991,
0.8139568228184566,
0.45211848419494655,
0.9942497292075129,
0.6406067568405251,
0.9910246729771206,
0.9949656095703345,
0.10882972254422812,
0.7138707925290203,
0.994144563802043,
0.7902590983736617,
0.7719277406824916,
0.8192862629345518,
0.7969172745181972,
1.2287730254791536,
0.9949404668468763,
0.5027461346053405,
0.8917015001697172,
0.8546544162516576,
0.23838624439896688,
0.5903395608159484,
1.0316335803275314,
0.998547399554429,
0.47663154930183077,
0.8756610000697115,
0.784736584272907,
0.5812756601972621,
0.6452224890452201,
0.7664571334650818,
1.0015507970415165,
0.9930264654288679,
1.0001483147473413,
1.22536131132786,
0.3390055264015336,
0.131948501375094,
0.9153540145979084,
1.302192317352297,
0.7536706574417384,
0.8084624257617279,
0.46244213157911085,
0.9697080130838464,
1.4802616752465023,
0.5694930922586036,
0.3503085583703781,
0.8223208352621483,
0.23444715903768232,
0.4372787611802593,
0.3742397896215375,
0.8732951637969902,
0.2491070383576216,
0.6880224680543431,
0.9570738822677248,
0.9921276818487579,
0.7104094863925342,
0.7939499029972068,
0.36236554844947055,
0.9970194411857779,
0.48395638542539027,
0.6496552483160901,
0.5226841478064309,
0.23875898653759436,
0.909593035227269,
0.2622841171522623,
0.7903291728400352,
1.0734695867243749,
0.9913536830576402,
0.9114152479246257,
1.0060722231156478,
0.6983287133699405,
0.9933902527771573,
0.6222120695143282,
0.42048190513857864,
0.5763672435514863,
0.48536711816682787,
0.9915675075900311,
0.9941328347444273,
0.9949919540052701,
0.8860424510431131,
0.4787185268843402,
0.3226742329357719,
1.0282245177756253,
0.5589548668257036,
0.4137993044111544,
1.051278144603223,
0.9945349176371012,
0.8927347796919158,
0.5584510663025547,
0.3229354468606759,
0.5659032049503229,
0.6291074511646948,
0.9941303682287431,
1.0974690242939684,
0.2787324446222392,
1.008201548738091,
0.5626228239714046,
0.6769126760760327,
0.6886542842024763,
0.2557619904163428,
1.0230336323143054,
0.5833205447718715,
0.3646978687229872,
0.2238776116822787,
0.9961331409944685,
0.9397316985390511,
0.23614881488454767,
0.7766652921374498,
0.3228319622220781,
0.5743230613463323,
0.7275363374941132,
0.3971037771180726,
0.09633563462586735,
0.5197578683942442,
0.6227994177370587,
0.6869353616747491,
0.9940838535593288,
0.8544133845013484,
1.0387736368749354,
0.5669377474322583,
0.6306400382533658,
0.3614499453485479,
0.5355062466658618,
0.9901575126373081,
0.8131730007678086,
0.39257918112591556,
0.700674869934137,
0.583630652459832,
0.9914570176061263,
0.5413979167635314,
0.9920517289425983,
0.9932963251553221,
0.9598081730861556,
0.6935978464483968,
0.6119396328919758,
0.5859174509071852,
0.7365505397316126,
0.5145425894458513,
0.3146579089954367,
0.6791630291533487,
0.2851986953478226,
0.624607520452698,
0.32466512858825897,
0.7759452120566667,
1.0221240380012988,
0.40716835540486296,
0.5188121813451578,
0.5327827482742261,
0.7170249666014702,
0.7013633260953267,
0.5214609388751896,
0.6311205522589861,
1.0039634978100596,
0.5881755114418861,
0.5874631243067694,
0.7554101997100772,
0.6004774379371789,
0.6073717176104506,
0.5496085148429259,
0.9935557164943025,
0.38618721139820467,
0.9938373834968042,
0.4495884125951758,
0.5003119451560089,
0.5476322954700664,
0.9963710052503392,
0.5866154183381893,
0.7104100678109505,
0.3659794864314444,
0.9076543451845256,
0.9944329542903781,
0.3912871864967312,
0.9914196871376538,
0.5444291984165189,
0.81900898120909,
1.0180777468531028,
0.4466800220100937,
0.45522676955358854,
0.3431045369609377,
0.28852904460029954,
0.9950384931760504,
0.5999402624686274,
0.41278461703302827,
0.27814397726802115,
0.5307611666930843,
0.9952297599683464,
0.23361964592078688,
0.5002563346484132,
0.9938641498677602,
0.7467249221704548,
0.6212259452446474,
1.0179000078642744,
0.6708871631064665,
0.48590528485761864,
0.7540089245896937,
0.20143537104144552,
0.6228132111516869,
0.7382592020912494,
0.4611083319383724,
0.6218270273687649,
0.9923903657072033,
0.39105685930561357,
0.14400570468097992,
0.9794314661143138,
0.5465001301510551,
0.41342138040126597,
0.537849982364847,
0.9908966523263832,
0.5942633416737061,
0.49842642050635055,
0.4631382767421957,
0.8386639598532091,
0.9943888506654087,
0.12874063659574217,
0.8728294534326121,
0.9707289078644122,
0.9375384749679707,
0.9951671817742004,
0.9899358560718833,
0.5651855517539044,
0.5165302582522246,
0.4459068358086142,
0.5616165728710999,
0.5960007403789773,
0.40710379029791666,
0.33076286864393006,
0.658800451021776,
0.7138652206969645,
0.8420124705328695,
0.23817639576130376,
0.7513779024110705,
0.4304636478977268,
0.48595975507306177,
0.6251821544276857,
0.03223766003916849,
0.99369777808227,
0.2068778072431196,
0.9928039980604896,
1.3334923279789723,
0.7856321343539796,
0.5959157178162509,
0.9912437797271128,
0.3447921621873315,
0.29801944693475824,
0.4619139378868955,
1.1150540215400893,
0.16355759700462583,
0.9922930557203172,
0.5689291945306862,
0.7164827127123491,
0.9942196292685397,
1.1364148319118383,
0.47813875217775725,
0.2995150100199036,
0.277690524200533,
0.3626859225239481,
0.4586031833919535,
0.08056314147139933,
0.6536560706416813,
0.6372695917965714,
0.7084020559593186,
0.608237865961373,
0.9130442218729786,
0.9935689824140225,
0.7230541995516246,
0.27750639670333294,
1.0039044086536,
0.06910993330911828,
0.5372171071867065,
0.3719924598494384,
0.7252229740305955,
0.4811722184642709,
0.47970933471881216,
0.7951094757962199,
0.909875883241578,
0.9954502297754981,
0.8095709267738218,
0.5977451684163917,
0.9925163936066613,
0.2644847959474258,
0.9664180832326759,
0.6620168009348842,
0.7103518653392862,
0.21236096726162168,
0.6308116903933049,
0.9935202451339438,
0.25792119624479287,
0.7272387098671871,
0.7687195306584957,
0.7181574640223471,
0.7079856347602176,
0.3644927107106283,
0.7817793556514121,
0.6922214953872138,
0.6689967127054955,
0.7117716062961037,
0.992543480719216,
1.1157866568931347,
0.6671772396650105,
0.41581757717240997,
0.5189551547526736,
0.05450655594023559,
0.8571400867641998,
0.9956343218685672,
0.2985079503718906,
0.4909926849312424,
0.4372956316727346,
0.9097215339537147,
0.5522631876232973,
0.5816409258094362,
0.9935567256155452,
0.4971585080787668,
0.40405488248464433,
0.6806943459775465,
0.7307803715612374,
0.5789520428860501,
0.9950579289777237,
0.7505310016704005,
0.7775806405079226,
0.8543504309417497,
0.9938186066065836,
0.8616904301640509,
0.4105688343037995,
0.9349464501595548,
0.3346546613320382,
0.7273068983404928,
0.34124045770500966,
0.613724021400325,
0.3132812930944461,
0.7797565732548996,
0.4847614008382401,
0.5284722766476058,
0.8503608365864237,
0.8262853358888869,
0.4608143254570044,
0.4773359858400499,
0.664711761278808,
0.2018665047460244,
0.9952879225010319,
0.8042169966206982,
0.7936608694455264,
0.6002467302209181,
0.6834944880670579,
0.5425555122912001,
0.9914078386620112,
0.7617560514127468,
0.9848454829871749,
0.22653465418135202,
0.6083103741581191,
0.9365421535061715,
0.4807236727270948,
0.7941060223405716,
0.18581117650681994,
0.9918555280556091,
0.8241745515393184,
0.6893304070492371,
0.44852407696279883,
1.1269461477340803,
0.37644667533054504,
0.5504534237898309,
0.48422484132659954,
0.9959166472670373,
0.9892304290096905,
0.56324169053635,
0.5317722241248543,
0.5645719702183021,
0.7252433460406795,
0.9920480362739116,
0.6551030014845165,
0.9940852097770895,
0.9015238613474194,
0.42337982401776286,
1.0709694893900168,
0.45090114893059446,
0.6630878053179701,
0.23470623899261928,
0.091684773068847,
0.2506543392908341,
0.17778279862278337,
0.587774856549172,
0.461858576005941,
0.5788666071331854,
0.8030930373398002,
0.4811741848547142,
0.3223595892478394,
0.8901946272761536,
0.5079163220746603,
0.5062289892112122,
0.4057713041291733,
0.5078761009050569,
0.10473139185911276,
0.3948259753362592,
0.5496187136198555,
0.8466812718368556,
0.7293387644309931,
0.4763083741227085,
0.30436813666228113,
0.42851841441526345,
0.6049719251912037,
0.40655310183320664,
0.7679886625604273,
0.5758051358405618,
0.21520220501292542,
1.1864381921811877,
0.7859263484999899,
0.6590712442089142,
0.45350050006163867,
1.070386387487356,
0.3522740114908841,
0.5786315214821188,
0.7396138056807348,
0.9658270632499937,
0.7221811572535575,
0.43038290626405457,
0.9886248306697563,
0.6178402178217258,
0.4744443873652353,
0.4888533307128739,
0.6132948374809983,
1.0637161131374189,
1.1308922376982875,
0.4816046854160443,
0.5003337894739142,
0.5585322951558966,
0.5381801914528636,
0.8122541445659242,
0.3533072821915063,
0.5097325057934994,
0.6618766617254462,
0.8018331976053105,
0.30089184798033053,
0.26096545662131715,
0.6704870620581674,
0.9929591178063935,
0.9936703386336523,
0.8488263478969102,
0.7887606153725975,
0.516626685942295,
0.5225061000595935,
0.9973695100859479,
0.3821697081692576,
0.7285189925102216,
0.31503347216436955,
0.1883792039279331,
0.4950739521083153,
0.8718158130458709,
0.4799498797089861,
0.5600315806270872,
1.0188346107678241,
0.37497436143641755,
0.9921083213924276,
0.35778630126305166,
0.3495989872597073,
0.5550430083842889,
0.7288062976139977,
0.4627641258753461,
0.3117847536741448,
0.4866557406045209,
0.642937718109889,
0.22639117893523147,
0.4553345743817794,
0.7422929186360507,
0.4504916646922842,
0.30286558130073177,
0.995404870982279,
0.5202948918189393,
1.0153075748549079,
0.7082800052201612,
0.482340624099526,
0.33928085874445424,
0.7129748123478008,
0.4915152424485474,
0.3569048127685336,
0.33284765922747817,
0.907527295045581,
0.684485266717401,
0.2347770721581054,
0.08012648476644446,
0.6086591076866014,
0.8158060751208763,
0.9181498383534014,
0.46831651322306517,
0.9220134753895146,
0.6132592900522229,
0.45500672623309857,
0.9926410747530324,
0.38335092311794916,
0.48598827621349727,
0.7874436350593684,
0.3847932695008507,
0.08740298129029926,
0.16937849258362325,
0.6304627425387672,
0.6486017437880635,
0.7977110682119414,
1.0496049019129785,
0.9904356144403061,
0.6583656243508824,
0.31518897551602115,
0.49780600734476055,
0.5383591263066627,
0.9485578998012862,
0.6618502085951135,
0.5917832542098278,
0.4410164010294805,
0.28570559711466176,
0.5050274684393892,
0.0501600697351402,
0.6440847424759337,
0.18491585090500604,
0.5918529600834761,
0.9895109013996575,
0.38258469367439646,
0.5952282231504675,
0.4728359416976405,
0.9944799403101328,
0.4436808646909036,
0.7539669888062949,
0.06339574171038923,
0.46947917684918616,
0.9932192337137195,
0.7216485259935048,
0.6274722019251826,
0.6586233501910114,
0.30170692221009043,
0.4130511792573808,
0.9950724797978893,
0.412440810295081,
0.3705936426138471,
0.9919510633412855,
0.9960416066870093,
0.9923825117824091,
0.9953921724335213,
0.6872484059631494,
0.3564175620464834,
0.5439296904182321,
0.41254689235146264,
0.5558148172111058,
0.9807934601365277,
0.7134110477858728,
0.48785212509720205,
1.139828245290775,
0.9554825641758898,
0.5513276331204633,
0.5863633810699134,
1.0468958118859895,
0.40698802572251797,
0.9793083415137196,
0.9941458634310801,
0.7047668426633855,
0.8010907071977234,
0.2830207663384474,
0.4819115886824565,
0.562241869810363,
0.9182409406586161,
0.8152912492124861,
0.20247165918311763,
0.1642186244840756,
0.5531762870858873,
0.634165772526808,
0.5974331023539423,
0.6823018800986533,
0.46428244233002564,
0.2712244173656073,
0.7204463435727168,
0.6703538868016805,
0.2229572722916418,
0.865327630402202,
0.4562495417365665,
0.40253182636606394,
0.3453759317073886,
0.06749728666819357,
0.7396042535746459,
0.598344600686742,
0.40517948177334695,
0.4141082477615071,
0.9983816360703651,
0.8292563324705696,
0.36763254379512983,
1.2158829653136118,
0.5922733154893518,
0.01250609922172299,
0.6250386092204286,
0.5171928304880089,
0.4040585771910688,
0.4878426590788986,
0.3441277997217525,
0.24540729894859797,
0.3354703477695785,
0.9950011314696559]
In [9]:
predictor = rs.MassPredictor()
predictor.set_model(exp.model)
In [10]:
predictor.predict(data[['user','item']]['user'].tolist(),list([4,5,6]))
Out[10]:
[0.987442505729575, 0.9767692732871204, 0.9850473952762439]
In [11]:
type(list(data[['user','item']]['user']))
Out[11]:
list
In [12]:
type(list([1,2,34]))
Out[12]:
list
In [6]:
df = pd.DataFrame.from_records([
(1,[1,2,3,4]),
(2,[5,6,7,8])
], columns=["user","item"])
In [11]:
df['item'].apply(np.ravel)
Out[11]:
0 [1, 2, 3, 4]
1 [5, 6, 7, 8]
Name: item, dtype: object
In [2]:
experiment = alpenglow.experiments.AsymmetricFactorModelExperiment(
top_k=100,
seed=254938879,
dimension=10,
learning_rate=0.1,
negative_rate=10
)
rankings = experiment.run("python/test_alpenglow/test_data_4", experimentType="online_id", verbose=False)
print(rankings["rank"].fillna(101).tolist())
[101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 12.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 3.0, 101.0, 101.0, 4.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 18.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 101.0, 12.0, 2.0, 33.0, 101.0, 101.0, 15.0, 101.0, 7.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 25.0, 101.0, 23.0, 11.0, 35.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 18.0, 101.0, 9.0, 101.0, 7.0, 101.0, 101.0, 101.0, 5.0, 101.0, 101.0, 8.0, 101.0, 43.0, 6.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 54.0, 101.0, 9.0, 43.0, 101.0, 10.0, 6.0, 22.0, 48.0, 101.0, 101.0, 59.0, 101.0, 101.0, 101.0, 31.0, 11.0, 1.0, 48.0, 101.0, 44.0, 39.0, 101.0, 101.0, 1.0, 3.0, 101.0, 101.0, 101.0, 51.0, 4.0, 58.0, 101.0, 11.0, 28.0, 46.0, 70.0, 12.0, 14.0, 8.0, 101.0, 23.0, 101.0, 101.0, 15.0, 25.0, 10.0, 101.0, 63.0, 43.0, 21.0, 25.0, 59.0, 9.0, 101.0, 65.0, 101.0, 101.0, 6.0, 101.0, 37.0, 30.0, 101.0, 19.0, 26.0, 44.0, 74.0, 5.0, 101.0, 2.0, 101.0, 101.0, 47.0, 101.0, 101.0, 101.0, 101.0, 23.0, 101.0, 10.0, 40.0, 101.0, 101.0, 101.0, 101.0, 73.0, 34.0, 75.0, 101.0, 101.0, 39.0, 101.0, 71.0, 101.0, 14.0, 21.0, 42.0, 4.0, 101.0, 101.0, 6.0, 70.0, 101.0, 8.0, 51.0, 81.0, 6.0, 1.0, 14.0, 101.0, 101.0, 101.0, 101.0, 24.0, 101.0, 7.0, 101.0, 10.0, 101.0, 33.0, 6.0, 101.0, 101.0, 41.0, 67.0, 15.0, 92.0, 101.0, 101.0, 30.0, 22.0, 59.0, 2.0, 101.0, 76.0, 101.0, 30.0, 90.0, 21.0, 27.0, 6.0, 94.0, 34.0, 101.0, 101.0, 101.0, 101.0, 101.0, 24.0, 24.0, 101.0, 71.0, 47.0, 59.0, 40.0, 30.0, 101.0, 87.0, 11.0, 10.0, 85.0, 101.0, 101.0, 59.0, 101.0, 41.0, 16.0, 86.0, 101.0, 65.0, 56.0, 101.0, 43.0, 2.0, 10.0, 101.0, 66.0, 16.0, 101.0, 101.0, 101.0, 101.0, 42.0, 67.0, 9.0, 101.0, 101.0, 40.0, 101.0, 70.0, 59.0, 101.0, 3.0, 95.0, 16.0, 1.0, 8.0, 25.0, 101.0, 101.0, 101.0, 15.0, 101.0, 64.0, 13.0, 101.0, 2.0, 7.0, 101.0, 101.0, 101.0, 101.0, 47.0, 21.0, 58.0, 52.0, 9.0, 43.0, 19.0, 99.0, 101.0, 101.0, 101.0, 101.0, 93.0, 101.0, 46.0, 101.0, 2.0, 101.0, 86.0, 101.0, 101.0, 6.0, 56.0, 101.0, 52.0, 8.0, 24.0, 77.0, 5.0, 101.0, 94.0, 5.0, 101.0, 61.0, 101.0, 48.0, 15.0, 3.0, 9.0, 101.0, 101.0, 12.0, 15.0, 101.0, 18.0, 101.0, 11.0, 22.0, 19.0, 6.0, 39.0, 35.0, 2.0, 101.0, 1.0, 101.0, 101.0, 101.0, 56.0, 62.0, 3.0, 75.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 10.0, 32.0, 101.0, 17.0, 24.0, 101.0, 69.0, 101.0, 39.0, 44.0, 101.0, 90.0, 43.0, 13.0, 101.0, 30.0, 2.0, 1.0, 90.0, 101.0, 87.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 90.0, 101.0, 3.0, 38.0, 54.0, 101.0, 101.0, 60.0, 8.0, 101.0, 1.0, 101.0, 101.0, 101.0, 101.0, 101.0, 11.0, 4.0, 101.0, 101.0, 98.0, 101.0, 41.0, 101.0, 4.0, 101.0, 27.0, 101.0, 18.0, 101.0, 4.0, 101.0, 70.0, 101.0, 101.0, 2.0, 101.0, 9.0, 25.0, 53.0, 31.0, 1.0, 16.0, 101.0, 12.0, 66.0, 6.0, 1.0, 101.0, 88.0, 19.0, 42.0, 101.0, 53.0, 101.0, 101.0, 49.0, 34.0, 101.0, 27.0, 101.0, 58.0, 94.0, 101.0, 101.0, 101.0, 95.0, 5.0, 90.0, 14.0, 101.0, 101.0, 2.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 49.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 62.0, 101.0, 69.0, 6.0, 101.0, 101.0, 3.0, 88.0, 86.0, 101.0, 101.0, 38.0, 19.0, 101.0, 48.0, 11.0, 101.0, 13.0, 15.0, 101.0, 31.0, 58.0, 101.0, 10.0, 101.0, 85.0, 101.0, 101.0, 1.0, 78.0, 39.0, 10.0, 80.0, 101.0, 101.0, 101.0, 2.0, 1.0, 101.0, 35.0, 101.0, 101.0, 69.0, 101.0, 101.0, 4.0, 101.0, 19.0, 101.0, 101.0, 81.0, 57.0, 101.0, 11.0, 47.0, 101.0, 61.0, 101.0, 101.0, 101.0, 101.0, 4.0, 14.0, 101.0, 7.0, 24.0, 4.0, 88.0, 66.0, 101.0, 101.0, 48.0, 101.0, 6.0, 52.0, 10.0, 101.0, 101.0, 101.0, 101.0, 21.0, 101.0, 4.0, 101.0, 3.0, 2.0, 101.0, 12.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 84.0, 69.0, 77.0, 101.0, 15.0, 33.0, 80.0, 97.0, 101.0, 101.0, 16.0, 101.0, 31.0, 101.0, 19.0, 101.0, 85.0, 6.0, 28.0, 14.0, 101.0, 101.0, 1.0, 101.0, 7.0, 101.0, 101.0, 100.0, 24.0, 23.0, 101.0, 90.0, 101.0, 27.0, 101.0, 101.0, 51.0, 101.0, 4.0, 101.0, 101.0, 52.0, 6.0, 62.0, 4.0, 12.0, 28.0, 83.0, 101.0, 13.0, 101.0, 1.0, 12.0, 15.0, 101.0, 101.0, 39.0, 101.0, 101.0, 24.0, 101.0, 7.0, 101.0, 101.0, 101.0, 95.0, 38.0, 101.0, 101.0, 11.0, 101.0, 101.0, 101.0, 101.0, 4.0, 101.0, 101.0, 42.0, 101.0, 54.0, 24.0, 2.0, 41.0, 11.0, 1.0, 24.0, 101.0, 24.0, 19.0, 14.0, 48.0, 2.0, 101.0, 9.0, 65.0, 90.0, 2.0, 34.0, 101.0, 5.0, 89.0, 101.0, 101.0, 101.0, 80.0, 4.0, 101.0, 7.0, 101.0, 24.0, 7.0, 4.0, 63.0, 27.0, 86.0, 101.0, 101.0, 74.0, 101.0, 101.0, 1.0, 7.0, 101.0, 7.0, 101.0, 95.0, 101.0, 95.0, 101.0, 46.0, 101.0, 21.0, 44.0, 101.0, 101.0, 38.0, 40.0, 65.0, 76.0, 101.0, 5.0, 7.0, 5.0, 101.0, 10.0, 25.0, 12.0, 17.0, 95.0, 101.0, 82.0, 50.0, 66.0, 101.0, 33.0, 101.0, 9.0, 81.0, 8.0, 9.0, 101.0, 101.0, 65.0, 101.0, 26.0, 2.0, 101.0, 101.0, 3.0, 2.0, 101.0, 75.0, 30.0, 88.0, 4.0, 101.0, 101.0, 95.0, 53.0, 11.0, 3.0, 101.0, 101.0, 101.0, 101.0, 101.0, 2.0, 83.0, 4.0, 14.0, 30.0, 19.0, 101.0, 3.0, 31.0, 3.0, 83.0, 101.0, 53.0, 101.0, 101.0, 101.0, 101.0, 21.0, 83.0, 81.0, 97.0, 101.0, 1.0, 12.0, 90.0, 7.0, 13.0, 101.0, 66.0, 20.0, 5.0, 2.0, 6.0, 101.0, 12.0, 2.0, 101.0, 101.0, 2.0, 50.0, 1.0, 2.0, 101.0, 101.0, 1.0, 28.0, 25.0, 3.0, 12.0, 1.0, 101.0, 101.0, 43.0, 101.0, 101.0, 101.0, 9.0, 6.0, 101.0, 11.0, 101.0, 14.0, 22.0, 96.0, 4.0, 65.0, 101.0, 101.0, 101.0, 77.0, 101.0, 101.0, 4.0, 25.0, 19.0, 65.0, 101.0, 81.0, 101.0, 100.0, 88.0, 15.0, 3.0, 101.0, 11.0, 13.0, 21.0, 101.0, 101.0, 12.0, 101.0, 101.0, 50.0, 20.0, 35.0, 19.0, 101.0, 101.0, 23.0, 12.0, 17.0, 101.0, 46.0, 3.0, 6.0, 7.0, 47.0, 25.0, 10.0, 7.0, 46.0, 65.0, 6.0, 101.0, 101.0, 4.0, 11.0, 4.0, 101.0, 27.0, 15.0, 9.0, 101.0, 93.0, 7.0, 13.0, 69.0, 66.0, 101.0, 101.0, 13.0, 12.0, 13.0, 101.0, 80.0, 101.0, 87.0, 15.0, 21.0, 9.0, 74.0, 16.0, 101.0, 3.0, 58.0, 48.0, 31.0, 101.0, 101.0, 35.0, 14.0, 8.0, 101.0, 101.0, 1.0, 101.0, 15.0, 101.0, 101.0, 13.0, 4.0, 101.0, 101.0, 101.0, 11.0, 61.0, 101.0, 101.0, 41.0, 101.0, 101.0, 101.0, 22.0, 12.0, 2.0, 27.0, 5.0, 25.0, 2.0, 101.0, 101.0, 5.0, 101.0, 74.0, 8.0, 101.0, 50.0, 101.0, 101.0, 10.0, 7.0, 42.0, 1.0, 39.0, 101.0, 30.0, 2.0, 101.0, 60.0, 25.0, 88.0, 22.0, 1.0, 101.0, 4.0, 9.0, 101.0, 21.0, 101.0, 2.0, 6.0, 8.0, 101.0, 28.0, 1.0, 101.0, 1.0, 6.0, 101.0, 30.0, 13.0, 13.0, 101.0, 30.0, 101.0, 101.0, 101.0]
In [16]:
boModelExperiment = alpenglow.experiments.BatchAndOnlineExperiment(
top_k=100,
seed=254938879,
dimension=10,
period_length=1000,
batch_learning_rate=0.07,
batch_negative_rate=20,
online_learning_rate=0.15,
online_negative_rate=120,
number_of_iterations=3,
clear_model=True,
)
boRankings = boModelExperiment.run("python/test_alpenglow/test_data_4", experimentType="online_id", verbose=True)
list(boRankings["rank"].fillna(101).values)
reading data...
data reading finished
running experiment...
Out[16]:
[101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
8.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
2.0,
101.0,
101.0,
2.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
22.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
2.0,
101.0,
101.0,
101.0,
23.0,
14.0,
33.0,
101.0,
101.0,
35.0,
101.0,
41.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
15.0,
101.0,
4.0,
24.0,
5.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
29.0,
101.0,
4.0,
101.0,
37.0,
101.0,
101.0,
101.0,
6.0,
101.0,
101.0,
56.0,
101.0,
47.0,
51.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
57.0,
101.0,
10.0,
7.0,
101.0,
25.0,
32.0,
9.0,
36.0,
101.0,
101.0,
16.0,
101.0,
101.0,
101.0,
30.0,
2.0,
11.0,
50.0,
101.0,
19.0,
1.0,
101.0,
101.0,
18.0,
14.0,
101.0,
101.0,
101.0,
28.0,
52.0,
63.0,
101.0,
40.0,
34.0,
56.0,
48.0,
4.0,
69.0,
7.0,
101.0,
33.0,
101.0,
101.0,
67.0,
70.0,
64.0,
101.0,
74.0,
26.0,
20.0,
8.0,
56.0,
73.0,
101.0,
74.0,
101.0,
101.0,
56.0,
101.0,
44.0,
36.0,
101.0,
4.0,
21.0,
26.0,
4.0,
12.0,
101.0,
15.0,
101.0,
101.0,
49.0,
101.0,
101.0,
101.0,
101.0,
77.0,
101.0,
2.0,
16.0,
101.0,
101.0,
101.0,
101.0,
1.0,
16.0,
75.0,
101.0,
101.0,
62.0,
101.0,
23.0,
101.0,
56.0,
67.0,
31.0,
27.0,
101.0,
101.0,
53.0,
80.0,
101.0,
8.0,
33.0,
68.0,
15.0,
97.0,
5.0,
101.0,
101.0,
101.0,
101.0,
22.0,
101.0,
11.0,
101.0,
3.0,
101.0,
62.0,
8.0,
101.0,
101.0,
3.0,
17.0,
44.0,
82.0,
101.0,
101.0,
26.0,
63.0,
23.0,
1.0,
101.0,
6.0,
101.0,
23.0,
33.0,
68.0,
20.0,
24.0,
101.0,
30.0,
101.0,
101.0,
101.0,
101.0,
101.0,
28.0,
14.0,
101.0,
65.0,
8.0,
4.0,
5.0,
95.0,
101.0,
49.0,
38.0,
47.0,
10.0,
101.0,
101.0,
42.0,
101.0,
16.0,
9.0,
6.0,
101.0,
1.0,
19.0,
36.0,
5.0,
14.0,
9.0,
101.0,
32.0,
90.0,
101.0,
101.0,
101.0,
101.0,
27.0,
58.0,
1.0,
101.0,
101.0,
72.0,
101.0,
92.0,
68.0,
101.0,
87.0,
47.0,
47.0,
3.0,
12.0,
37.0,
101.0,
101.0,
101.0,
65.0,
101.0,
71.0,
1.0,
101.0,
77.0,
16.0,
101.0,
101.0,
101.0,
101.0,
1.0,
101.0,
101.0,
38.0,
10.0,
50.0,
40.0,
24.0,
101.0,
101.0,
101.0,
101.0,
30.0,
101.0,
8.0,
101.0,
93.0,
101.0,
11.0,
101.0,
101.0,
5.0,
95.0,
101.0,
96.0,
57.0,
24.0,
101.0,
18.0,
101.0,
92.0,
3.0,
101.0,
28.0,
101.0,
101.0,
8.0,
101.0,
13.0,
18.0,
101.0,
13.0,
21.0,
101.0,
4.0,
101.0,
10.0,
58.0,
79.0,
34.0,
54.0,
96.0,
9.0,
101.0,
1.0,
101.0,
101.0,
101.0,
23.0,
5.0,
57.0,
101.0,
101.0,
101.0,
101.0,
39.0,
37.0,
101.0,
2.0,
16.0,
101.0,
4.0,
35.0,
101.0,
7.0,
101.0,
41.0,
99.0,
101.0,
101.0,
7.0,
17.0,
101.0,
84.0,
59.0,
46.0,
55.0,
101.0,
101.0,
101.0,
101.0,
12.0,
27.0,
101.0,
101.0,
101.0,
100.0,
101.0,
101.0,
101.0,
19.0,
101.0,
101.0,
47.0,
1.0,
101.0,
25.0,
101.0,
101.0,
101.0,
101.0,
101.0,
32.0,
41.0,
16.0,
29.0,
4.0,
101.0,
79.0,
84.0,
36.0,
101.0,
101.0,
101.0,
6.0,
101.0,
45.0,
88.0,
9.0,
101.0,
101.0,
1.0,
101.0,
4.0,
32.0,
58.0,
67.0,
4.0,
56.0,
82.0,
18.0,
101.0,
1.0,
101.0,
31.0,
21.0,
69.0,
101.0,
79.0,
83.0,
64.0,
101.0,
58.0,
101.0,
101.0,
66.0,
3.0,
31.0,
15.0,
20.0,
98.0,
80.0,
49.0,
6.0,
101.0,
3.0,
5.0,
101.0,
1.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
93.0,
101.0,
101.0,
101.0,
101.0,
101.0,
101.0,
44.0,
93.0,
101.0,
61.0,
101.0,
56.0,
7.0,
46.0,
33.0,
101.0,
101.0,
44.0,
101.0,
101.0,
6.0,
46.0,
45.0,
41.0,
16.0,
29.0,
101.0,
78.0,
101.0,
2.0,
89.0,
36.0,
91.0,
101.0,
1.0,
101.0,
101.0,
4.0,
38.0,
70.0,
101.0,
29.0,
16.0,
101.0,
53.0,
91.0,
101.0,
101.0,
1.0,
101.0,
74.0,
39.0,
101.0,
9.0,
101.0,
101.0,
7.0,
19.0,
101.0,
29.0,
16.0,
67.0,
101.0,
101.0,
101.0,
59.0,
101.0,
1.0,
13.0,
101.0,
101.0,
15.0,
64.0,
101.0,
14.0,
22.0,
101.0,
17.0,
101.0,
101.0,
21.0,
101.0,
101.0,
101.0,
101.0,
101.0,
1.0,
101.0,
90.0,
101.0,
4.0,
1.0,
16.0,
23.0,
101.0,
101.0,
101.0,
49.0,
56.0,
101.0,
101.0,
5.0,
21.0,
101.0,
101.0,
17.0,
5.0,
68.0,
101.0,
101.0,
54.0,
18.0,
101.0,
9.0,
101.0,
16.0,
8.0,
19.0,
41.0,
62.0,
8.0,
27.0,
101.0,
4.0,
101.0,
45.0,
50.0,
61.0,
7.0,
16.0,
14.0,
101.0,
101.0,
101.0,
10.0,
101.0,
101.0,
101.0,
101.0,
11.0,
10.0,
101.0,
44.0,
101.0,
18.0,
2.0,
85.0,
101.0,
17.0,
101.0,
16.0,
101.0,
29.0,
21.0,
101.0,
101.0,
101.0,
20.0,
101.0,
101.0,
32.0,
101.0,
12.0,
23.0,
101.0,
101.0,
101.0,
31.0,
49.0,
43.0,
101.0,
101.0,
23.0,
75.0,
101.0,
2.0,
101.0,
48.0,
20.0,
8.0,
87.0,
5.0,
1.0,
30.0,
25.0,
2.0,
2.0,
101.0,
101.0,
26.0,
4.0,
101.0,
56.0,
28.0,
36.0,
101.0,
34.0,
5.0,
17.0,
101.0,
19.0,
24.0,
101.0,
16.0,
101.0,
101.0,
10.0,
80.0,
101.0,
101.0,
39.0,
47.0,
101.0,
9.0,
101.0,
101.0,
28.0,
101.0,
2.0,
101.0,
101.0,
24.0,
30.0,
101.0,
5.0,
101.0,
16.0,
101.0,
41.0,
5.0,
55.0,
4.0,
101.0,
38.0,
101.0,
101.0,
101.0,
11.0,
101.0,
101.0,
101.0,
25.0,
2.0,
7.0,
101.0,
7.0,
30.0,
16.0,
8.0,
42.0,
101.0,
5.0,
32.0,
38.0,
101.0,
101.0,
27.0,
90.0,
101.0,
82.0,
13.0,
101.0,
101.0,
62.0,
65.0,
51.0,
6.0,
7.0,
101.0,
28.0,
1.0,
101.0,
14.0,
10.0,
5.0,
1.0,
101.0,
101.0,
29.0,
12.0,
9.0,
1.0,
101.0,
85.0,
17.0,
101.0,
101.0,
6.0,
93.0,
11.0,
13.0,
45.0,
13.0,
101.0,
13.0,
13.0,
7.0,
32.0,
101.0,
40.0,
91.0,
101.0,
46.0,
101.0,
16.0,
3.0,
101.0,
93.0,
18.0,
1.0,
44.0,
9.0,
11.0,
101.0,
101.0,
38.0,
19.0,
48.0,
1.0,
15.0,
12.0,
11.0,
6.0,
101.0,
12.0,
5.0,
101.0,
1.0,
55.0,
24.0,
101.0,
1.0,
37.0,
101.0,
5.0,
20.0,
1.0,
101.0,
101.0,
95.0,
101.0,
101.0,
6.0,
16.0,
4.0,
101.0,
13.0,
8.0,
27.0,
11.0,
101.0,
1.0,
94.0,
27.0,
101.0,
51.0,
101.0,
101.0,
101.0,
2.0,
8.0,
21.0,
20.0,
101.0,
78.0,
31.0,
25.0,
22.0,
6.0,
5.0,
92.0,
19.0,
25.0,
35.0,
101.0,
101.0,
25.0,
101.0,
101.0,
20.0,
14.0,
93.0,
15.0,
26.0,
101.0,
2.0,
36.0,
58.0,
101.0,
22.0,
20.0,
6.0,
35.0,
38.0,
12.0,
13.0,
7.0,
51.0,
6.0,
4.0,
48.0,
24.0,
2.0,
13.0,
3.0,
101.0,
23.0,
10.0,
9.0,
101.0,
21.0,
19.0,
8.0,
22.0,
101.0,
58.0,
101.0,
22.0,
21.0,
23.0,
101.0,
97.0,
101.0,
101.0,
22.0,
22.0,
17.0,
20.0,
58.0,
101.0,
17.0,
101.0,
62.0,
76.0,
101.0,
101.0,
20.0,
25.0,
1.0,
101.0,
65.0,
5.0,
101.0,
94.0,
101.0,
10.0,
5.0,
34.0,
37.0,
93.0,
101.0,
26.0,
96.0,
101.0,
101.0,
19.0,
101.0,
4.0,
101.0,
11.0,
21.0,
5.0,
10.0,
4.0,
42.0,
1.0,
58.0,
101.0,
4.0,
95.0,
13.0,
14.0,
101.0,
8.0,
94.0,
101.0,
17.0,
4.0,
46.0,
1.0,
70.0,
101.0,
15.0,
8.0,
17.0,
66.0,
56.0,
101.0,
10.0,
1.0,
101.0,
4.0,
8.0,
25.0,
21.0,
101.0,
5.0,
2.0,
32.0,
92.0,
14.0,
1.0,
101.0,
1.0,
13.0,
55.0,
101.0,
4.0,
28.0,
29.0,
101.0,
101.0,
101.0,
101.0]
In [19]:
factorModelExperiment = alpenglow.experiments.FactorModelExperiment(
top_k=100,
seed=254938879,
dimension=10,
learning_rate=0.1,
negative_rate=10
)
facRankings = factorModelExperiment.run("python/test_alpenglow/test_data_4", experimentType="online_id", verbose=True)
print(facRankings["rank"].fillna(101).tolist())
reading data...
data reading finished
running experiment...
[101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 8.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 2.0, 101.0, 101.0, 1.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 23.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 2.0, 101.0, 101.0, 101.0, 24.0, 14.0, 33.0, 101.0, 101.0, 38.0, 101.0, 41.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 17.0, 101.0, 4.0, 23.0, 5.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 28.0, 101.0, 4.0, 101.0, 41.0, 101.0, 101.0, 101.0, 14.0, 101.0, 101.0, 57.0, 101.0, 46.0, 52.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 53.0, 101.0, 10.0, 7.0, 101.0, 25.0, 33.0, 9.0, 40.0, 101.0, 101.0, 13.0, 101.0, 101.0, 101.0, 27.0, 2.0, 14.0, 51.0, 101.0, 22.0, 1.0, 101.0, 101.0, 24.0, 21.0, 101.0, 101.0, 101.0, 27.0, 55.0, 62.0, 101.0, 42.0, 37.0, 58.0, 47.0, 3.0, 71.0, 7.0, 101.0, 36.0, 101.0, 101.0, 62.0, 71.0, 64.0, 101.0, 75.0, 36.0, 20.0, 11.0, 68.0, 73.0, 101.0, 72.0, 101.0, 101.0, 56.0, 101.0, 47.0, 33.0, 101.0, 3.0, 22.0, 22.0, 4.0, 23.0, 101.0, 20.0, 101.0, 101.0, 54.0, 101.0, 101.0, 101.0, 101.0, 77.0, 101.0, 3.0, 21.0, 101.0, 101.0, 101.0, 101.0, 1.0, 17.0, 78.0, 101.0, 101.0, 61.0, 101.0, 19.0, 101.0, 44.0, 69.0, 37.0, 40.0, 101.0, 101.0, 51.0, 83.0, 101.0, 47.0, 91.0, 19.0, 5.0, 1.0, 9.0, 101.0, 101.0, 101.0, 101.0, 42.0, 101.0, 11.0, 101.0, 12.0, 101.0, 98.0, 87.0, 101.0, 101.0, 39.0, 31.0, 57.0, 57.0, 101.0, 101.0, 62.0, 66.0, 16.0, 101.0, 101.0, 81.0, 101.0, 77.0, 57.0, 25.0, 26.0, 53.0, 29.0, 1.0, 101.0, 101.0, 101.0, 101.0, 101.0, 38.0, 10.0, 101.0, 30.0, 97.0, 101.0, 43.0, 57.0, 101.0, 99.0, 41.0, 1.0, 2.0, 101.0, 101.0, 16.0, 101.0, 73.0, 97.0, 89.0, 101.0, 82.0, 86.0, 4.0, 75.0, 29.0, 8.0, 101.0, 10.0, 4.0, 101.0, 101.0, 101.0, 101.0, 80.0, 60.0, 9.0, 101.0, 101.0, 72.0, 101.0, 78.0, 45.0, 101.0, 78.0, 21.0, 70.0, 22.0, 20.0, 85.0, 101.0, 101.0, 101.0, 6.0, 101.0, 61.0, 1.0, 101.0, 47.0, 66.0, 101.0, 101.0, 101.0, 101.0, 101.0, 33.0, 101.0, 12.0, 2.0, 19.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 85.0, 101.0, 101.0, 101.0, 98.0, 101.0, 101.0, 101.0, 78.0, 15.0, 93.0, 101.0, 88.0, 99.0, 89.0, 101.0, 101.0, 101.0, 2.0, 10.0, 101.0, 91.0, 101.0, 57.0, 83.0, 60.0, 15.0, 20.0, 101.0, 9.0, 101.0, 101.0, 25.0, 101.0, 4.0, 6.0, 20.0, 90.0, 76.0, 99.0, 20.0, 101.0, 9.0, 69.0, 101.0, 101.0, 1.0, 3.0, 10.0, 100.0, 101.0, 101.0, 101.0, 51.0, 14.0, 101.0, 8.0, 101.0, 101.0, 50.0, 89.0, 101.0, 73.0, 21.0, 54.0, 97.0, 79.0, 59.0, 101.0, 12.0, 101.0, 15.0, 101.0, 101.0, 76.0, 8.0, 59.0, 101.0, 101.0, 43.0, 101.0, 101.0, 2.0, 101.0, 23.0, 101.0, 42.0, 21.0, 59.0, 101.0, 101.0, 86.0, 86.0, 101.0, 57.0, 101.0, 101.0, 101.0, 101.0, 101.0, 73.0, 34.0, 101.0, 48.0, 7.0, 101.0, 79.0, 28.0, 47.0, 101.0, 101.0, 101.0, 4.0, 101.0, 33.0, 22.0, 60.0, 101.0, 101.0, 9.0, 101.0, 12.0, 101.0, 53.0, 24.0, 3.0, 101.0, 25.0, 44.0, 78.0, 43.0, 66.0, 101.0, 93.0, 99.0, 101.0, 101.0, 74.0, 11.0, 101.0, 24.0, 90.0, 101.0, 40.0, 22.0, 101.0, 68.0, 21.0, 101.0, 101.0, 93.0, 84.0, 33.0, 68.0, 38.0, 101.0, 15.0, 101.0, 68.0, 101.0, 10.0, 101.0, 101.0, 61.0, 101.0, 101.0, 101.0, 32.0, 101.0, 55.0, 20.0, 29.0, 62.0, 23.0, 101.0, 19.0, 97.0, 52.0, 59.0, 101.0, 101.0, 101.0, 65.0, 101.0, 101.0, 101.0, 101.0, 101.0, 14.0, 101.0, 91.0, 40.0, 101.0, 94.0, 101.0, 101.0, 101.0, 22.0, 99.0, 5.0, 51.0, 101.0, 14.0, 3.0, 101.0, 101.0, 17.0, 101.0, 89.0, 69.0, 101.0, 101.0, 52.0, 101.0, 13.0, 101.0, 101.0, 37.0, 101.0, 101.0, 2.0, 97.0, 101.0, 101.0, 59.0, 27.0, 17.0, 101.0, 101.0, 101.0, 58.0, 70.0, 18.0, 101.0, 72.0, 37.0, 90.0, 79.0, 7.0, 66.0, 101.0, 101.0, 99.0, 101.0, 101.0, 50.0, 101.0, 101.0, 100.0, 101.0, 14.0, 101.0, 101.0, 101.0, 66.0, 94.0, 101.0, 23.0, 101.0, 91.0, 101.0, 100.0, 11.0, 101.0, 101.0, 99.0, 101.0, 101.0, 101.0, 101.0, 2.0, 92.0, 98.0, 101.0, 71.0, 10.0, 101.0, 101.0, 101.0, 9.0, 66.0, 101.0, 101.0, 101.0, 101.0, 5.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 21.0, 101.0, 101.0, 101.0, 101.0, 9.0, 101.0, 101.0, 101.0, 101.0, 101.0, 11.0, 101.0, 32.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 46.0, 101.0, 71.0, 46.0, 76.0, 101.0, 101.0, 94.0, 101.0, 101.0, 101.0, 101.0, 4.0, 101.0, 101.0, 101.0, 15.0, 92.0, 31.0, 61.0, 47.0, 101.0, 50.0, 101.0, 101.0, 43.0, 101.0, 71.0, 101.0, 101.0, 74.0, 101.0, 18.0, 50.0, 101.0, 101.0, 10.0, 101.0, 63.0, 101.0, 16.0, 101.0, 43.0, 44.0, 16.0, 13.0, 83.0, 54.0, 53.0, 101.0, 77.0, 19.0, 101.0, 101.0, 101.0, 58.0, 69.0, 101.0, 101.0, 101.0, 84.0, 101.0, 101.0, 101.0, 101.0, 101.0, 89.0, 101.0, 13.0, 101.0, 101.0, 23.0, 14.0, 101.0, 1.0, 4.0, 77.0, 101.0, 17.0, 9.0, 2.0, 44.0, 101.0, 101.0, 101.0, 101.0, 84.0, 28.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 88.0, 91.0, 94.0, 101.0, 101.0, 101.0, 101.0, 101.0, 12.0, 101.0, 101.0, 8.0, 34.0, 101.0, 101.0, 101.0, 76.0, 101.0, 91.0, 101.0, 77.0, 101.0, 7.0, 101.0, 101.0, 101.0, 101.0, 58.0, 35.0, 101.0, 43.0, 101.0, 101.0, 101.0, 101.0, 101.0, 13.0, 101.0, 26.0, 101.0, 101.0, 101.0, 97.0, 100.0, 47.0, 101.0, 101.0, 34.0, 101.0, 101.0, 101.0, 20.0, 41.0, 101.0, 87.0, 98.0, 12.0, 101.0, 101.0, 21.0, 101.0, 101.0, 101.0, 3.0, 101.0, 101.0, 101.0, 88.0, 83.0, 101.0, 59.0, 71.0, 101.0, 11.0, 74.0, 101.0, 101.0, 101.0, 16.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 101.0, 64.0, 92.0, 101.0, 6.0, 4.0, 4.0, 101.0, 101.0, 71.0, 101.0, 101.0, 101.0, 10.0, 61.0, 101.0, 83.0, 17.0, 101.0, 101.0, 101.0, 101.0, 101.0, 53.0, 101.0, 9.0, 67.0, 101.0, 101.0, 7.0, 67.0, 101.0, 101.0, 101.0, 101.0, 18.0, 101.0, 47.0, 101.0, 13.0, 15.0, 101.0, 20.0, 19.0, 101.0, 66.0, 54.0, 101.0, 101.0, 56.0, 101.0, 3.0, 101.0, 101.0, 101.0, 101.0, 101.0, 36.0, 101.0, 101.0, 4.0, 88.0, 90.0, 101.0, 21.0, 101.0, 101.0, 87.0, 2.0, 17.0, 88.0, 101.0, 97.0, 78.0, 101.0, 101.0, 101.0, 98.0, 44.0, 101.0, 3.0, 35.0, 17.0, 2.0, 101.0, 27.0, 101.0, 94.0, 90.0, 101.0, 101.0, 101.0, 101.0, 101.0, 86.0, 18.0, 101.0, 88.0, 101.0, 101.0, 33.0, 101.0, 101.0, 59.0, 101.0, 101.0, 35.0, 101.0, 30.0, 101.0, 86.0, 84.0, 101.0, 101.0, 101.0, 101.0, 39.0, 71.0, 101.0, 97.0, 101.0, 101.0, 101.0, 101.0, 101.0, 32.0, 101.0, 101.0, 101.0, 96.0, 101.0, 101.0, 30.0, 101.0, 101.0, 3.0, 59.0, 33.0, 46.0, 1.0, 101.0, 2.0, 101.0, 18.0, 68.0, 101.0, 89.0, 43.0, 95.0, 15.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 62.0, 101.0, 15.0, 101.0, 101.0, 62.0, 75.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 14.0, 11.0, 101.0, 6.0, 101.0, 101.0, 59.0, 101.0, 90.0, 17.0, 101.0, 52.0, 101.0, 101.0]
In [22]:
data = pd.read_csv(
"python/test_alpenglow/test_data_4",
sep=' ',
header=None,
names=['time', 'user', 'item', 'id', 'score', 'eval']
)
sbExperiment = alpenglow.experiments.SimulatedBatchExperiment(
top_k=100,
negative_rate=3,
seed=254938879,
period_length=1000
)
rankings = sbExperiment.run(data, verbose=True)
print(rankings['rank'].fillna(101).tolist())
reading data...
data reading finished
running experiment...
[101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 49.0, 91.0, 19.0, 4.0, 1.0, 12.0, 101.0, 101.0, 101.0, 101.0, 33.0, 101.0, 12.0, 101.0, 11.0, 101.0, 98.0, 86.0, 101.0, 101.0, 44.0, 23.0, 43.0, 62.0, 101.0, 101.0, 62.0, 60.0, 10.0, 101.0, 101.0, 76.0, 101.0, 83.0, 61.0, 17.0, 28.0, 38.0, 23.0, 1.0, 101.0, 101.0, 101.0, 101.0, 101.0, 42.0, 8.0, 101.0, 101.0, 99.0, 101.0, 39.0, 75.0, 101.0, 95.0, 12.0, 1.0, 2.0, 101.0, 101.0, 11.0, 101.0, 84.0, 80.0, 88.0, 101.0, 89.0, 88.0, 3.0, 46.0, 7.0, 9.0, 101.0, 101.0, 4.0, 101.0, 101.0, 101.0, 101.0, 88.0, 43.0, 10.0, 101.0, 101.0, 46.0, 101.0, 87.0, 31.0, 101.0, 90.0, 16.0, 50.0, 15.0, 23.0, 82.0, 101.0, 101.0, 101.0, 5.0, 101.0, 101.0, 1.0, 101.0, 79.0, 87.0, 101.0, 101.0, 101.0, 101.0, 101.0, 27.0, 101.0, 101.0, 101.0, 13.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 89.0, 16.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 2.0, 11.0, 101.0, 101.0, 101.0, 101.0, 101.0, 43.0, 15.0, 19.0, 101.0, 12.0, 101.0, 101.0, 46.0, 101.0, 101.0, 101.0, 9.0, 101.0, 93.0, 101.0, 13.0, 101.0, 21.0, 101.0, 101.0, 101.0, 1.0, 3.0, 6.0, 101.0, 101.0, 101.0, 101.0, 33.0, 15.0, 101.0, 7.0, 101.0, 101.0, 21.0, 91.0, 101.0, 101.0, 16.0, 101.0, 101.0, 37.0, 101.0, 101.0, 6.0, 101.0, 9.0, 101.0, 101.0, 34.0, 10.0, 20.0, 101.0, 101.0, 62.0, 43.0, 101.0, 5.0, 101.0, 13.0, 101.0, 24.0, 23.0, 13.0, 101.0, 101.0, 22.0, 101.0, 101.0, 34.0, 101.0, 101.0, 101.0, 101.0, 101.0, 4.0, 38.0, 101.0, 68.0, 48.0, 101.0, 40.0, 32.0, 52.0, 101.0, 101.0, 101.0, 1.0, 101.0, 5.0, 8.0, 48.0, 101.0, 101.0, 101.0, 101.0, 101.0, 99.0, 41.0, 36.0, 1.0, 58.0, 31.0, 101.0, 54.0, 1.0, 87.0, 50.0, 96.0, 19.0, 67.0, 101.0, 28.0, 4.0, 101.0, 28.0, 47.0, 101.0, 49.0, 90.0, 74.0, 70.0, 55.0, 101.0, 91.0, 43.0, 6.0, 34.0, 1.0, 2.0, 101.0, 5.0, 101.0, 11.0, 101.0, 26.0, 101.0, 101.0, 12.0, 101.0, 101.0, 101.0, 4.0, 101.0, 47.0, 4.0, 26.0, 73.0, 100.0, 101.0, 75.0, 101.0, 78.0, 23.0, 101.0, 101.0, 101.0, 76.0, 101.0, 69.0, 87.0, 101.0, 51.0, 2.0, 8.0, 37.0, 47.0, 101.0, 3.0, 101.0, 10.0, 47.0, 17.0, 1.0, 17.0, 34.0, 11.0, 93.0, 13.0, 101.0, 101.0, 18.0, 13.0, 101.0, 29.0, 101.0, 101.0, 47.0, 101.0, 22.0, 101.0, 101.0, 1.0, 101.0, 101.0, 3.0, 3.0, 101.0, 101.0, 61.0, 10.0, 23.0, 101.0, 101.0, 54.0, 68.0, 79.0, 8.0, 101.0, 9.0, 101.0, 12.0, 69.0, 1.0, 20.0, 101.0, 101.0, 82.0, 47.0, 101.0, 101.0, 54.0, 101.0, 75.0, 101.0, 1.0, 101.0, 55.0, 101.0, 101.0, 2.0, 101.0, 13.0, 101.0, 101.0, 101.0, 101.0, 8.0, 101.0, 101.0, 53.0, 77.0, 101.0, 101.0, 101.0, 2.0, 43.0, 101.0, 101.0, 35.0, 101.0, 101.0, 30.0, 101.0, 14.0, 6.0, 22.0, 19.0, 13.0, 2.0, 10.0, 101.0, 1.0, 101.0, 14.0, 51.0, 23.0, 28.0, 16.0, 5.0, 101.0, 101.0, 101.0, 10.0, 101.0, 101.0, 46.0, 12.0, 18.0, 12.0, 101.0, 27.0, 101.0, 29.0, 1.0, 9.0, 101.0, 39.0, 94.0, 40.0, 101.0, 3.0, 17.0, 6.0, 101.0, 101.0, 4.0, 101.0, 101.0, 18.0, 101.0, 11.0, 21.0, 101.0, 101.0, 93.0, 19.0, 36.0, 23.0, 101.0, 101.0, 12.0, 39.0, 101.0, 2.0, 101.0, 33.0, 36.0, 21.0, 19.0, 25.0, 2.0, 16.0, 7.0, 5.0, 14.0, 101.0, 16.0, 13.0, 12.0, 101.0, 5.0, 39.0, 5.0, 48.0, 12.0, 2.0, 14.0, 101.0, 29.0, 26.0, 101.0, 16.0, 101.0, 58.0, 3.0, 81.0, 13.0, 101.0, 62.0, 2.0, 2.0, 21.0, 63.0, 101.0, 40.0, 101.0, 12.0, 101.0, 101.0, 1.0, 5.0, 101.0, 5.0, 93.0, 10.0, 101.0, 16.0, 30.0, 34.0, 7.0, 101.0, 9.0, 101.0, 101.0, 29.0, 19.0, 101.0, 101.0, 101.0, 2.0, 2.0, 3.0, 101.0, 17.0, 14.0, 13.0, 5.0, 14.0, 20.0, 14.0, 25.0, 27.0, 101.0, 65.0, 30.0, 14.0, 57.0, 5.0, 2.0, 101.0, 101.0, 53.0, 20.0, 15.0, 1.0, 34.0, 101.0, 2.0, 1.0, 101.0, 43.0, 5.0, 21.0, 2.0, 101.0, 101.0, 34.0, 4.0, 20.0, 1.0, 101.0, 15.0, 48.0, 101.0, 101.0, 2.0, 51.0, 16.0, 15.0, 14.0, 6.0, 101.0, 2.0, 13.0, 2.0, 16.0, 101.0, 101.0, 69.0, 37.0, 47.0, 101.0, 7.0, 10.0, 101.0, 101.0, 18.0, 2.0, 101.0, 14.0, 6.0, 101.0, 101.0, 37.0, 14.0, 3.0, 2.0, 12.0, 31.0, 8.0, 4.0, 101.0, 8.0, 3.0, 101.0, 1.0, 2.0, 21.0, 101.0, 1.0, 47.0, 62.0, 3.0, 25.0, 1.0, 101.0, 101.0, 101.0, 101.0, 101.0, 12.0, 22.0, 3.0, 101.0, 6.0, 19.0, 18.0, 13.0, 84.0, 6.0, 70.0, 28.0, 101.0, 37.0, 101.0, 101.0, 101.0, 7.0, 8.0, 7.0, 15.0, 101.0, 101.0, 18.0, 15.0, 26.0, 10.0, 1.0, 79.0, 9.0, 21.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 11.0, 16.0, 37.0, 18.0, 29.0, 101.0, 4.0, 19.0, 31.0, 101.0, 25.0, 4.0, 1.0, 13.0, 28.0, 11.0, 8.0, 4.0, 36.0, 8.0, 101.0, 101.0, 40.0, 8.0, 16.0, 2.0, 101.0, 13.0, 16.0, 5.0, 101.0, 20.0, 6.0, 4.0, 27.0, 101.0, 33.0, 101.0, 16.0, 16.0, 23.0, 101.0, 34.0, 101.0, 101.0, 13.0, 6.0, 28.0, 16.0, 32.0, 101.0, 10.0, 101.0, 101.0, 101.0, 101.0, 101.0, 22.0, 31.0, 13.0, 101.0, 38.0, 1.0, 101.0, 10.0, 101.0, 17.0, 2.0, 7.0, 21.0, 69.0, 101.0, 101.0, 28.0, 101.0, 101.0, 11.0, 101.0, 20.0, 101.0, 8.0, 12.0, 1.0, 19.0, 3.0, 44.0, 1.0, 101.0, 71.0, 3.0, 18.0, 12.0, 2.0, 101.0, 16.0, 60.0, 101.0, 11.0, 8.0, 24.0, 1.0, 32.0, 101.0, 17.0, 4.0, 25.0, 75.0, 20.0, 47.0, 14.0, 2.0, 60.0, 1.0, 7.0, 33.0, 20.0, 101.0, 1.0, 10.0, 14.0, 99.0, 1.0, 1.0, 101.0, 1.0, 3.0, 56.0, 101.0, 8.0, 32.0, 22.0, 52.0, 77.0, 101.0, 101.0]
In [5]:
experiment = alpenglow.experiments.SvdppModelExperiment(
top_k=100,
seed=254938879,
dimension=10,
learning_rate=0.1,
negative_rate=10
)
rankings = experiment.run("python/test_alpenglow/test_data_4", experimentType="online_id", verbose=True)
print(alpenglow.evaluation.DcgScore(rankings).mean())
print(rankings['rank'].fillna(101).tolist())
reading data...
data reading finished
running experiment...
0.11076980880439599
[101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 10.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 4.0, 101.0, 101.0, 2.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 10.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 1.0, 101.0, 101.0, 101.0, 34.0, 8.0, 6.0, 101.0, 101.0, 1.0, 101.0, 13.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 43.0, 101.0, 5.0, 30.0, 46.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 1.0, 101.0, 4.0, 101.0, 37.0, 101.0, 101.0, 101.0, 19.0, 101.0, 101.0, 21.0, 101.0, 47.0, 9.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 54.0, 101.0, 2.0, 15.0, 101.0, 58.0, 32.0, 28.0, 58.0, 101.0, 101.0, 17.0, 101.0, 101.0, 101.0, 4.0, 67.0, 32.0, 30.0, 101.0, 25.0, 7.0, 101.0, 101.0, 40.0, 54.0, 101.0, 101.0, 101.0, 57.0, 37.0, 55.0, 101.0, 44.0, 55.0, 15.0, 35.0, 8.0, 6.0, 8.0, 101.0, 9.0, 101.0, 101.0, 70.0, 36.0, 11.0, 101.0, 11.0, 27.0, 45.0, 24.0, 64.0, 44.0, 101.0, 21.0, 101.0, 101.0, 5.0, 101.0, 57.0, 13.0, 101.0, 44.0, 9.0, 50.0, 17.0, 45.0, 101.0, 59.0, 101.0, 101.0, 56.0, 101.0, 101.0, 101.0, 101.0, 26.0, 101.0, 11.0, 51.0, 101.0, 101.0, 101.0, 101.0, 84.0, 37.0, 77.0, 101.0, 101.0, 11.0, 101.0, 5.0, 101.0, 42.0, 55.0, 59.0, 81.0, 101.0, 101.0, 2.0, 21.0, 101.0, 71.0, 60.0, 60.0, 2.0, 42.0, 2.0, 101.0, 101.0, 101.0, 101.0, 22.0, 101.0, 9.0, 101.0, 12.0, 101.0, 65.0, 19.0, 101.0, 101.0, 61.0, 15.0, 25.0, 93.0, 101.0, 101.0, 29.0, 33.0, 13.0, 9.0, 101.0, 30.0, 101.0, 73.0, 48.0, 66.0, 76.0, 96.0, 6.0, 27.0, 101.0, 101.0, 101.0, 101.0, 101.0, 67.0, 16.0, 101.0, 83.0, 33.0, 55.0, 68.0, 11.0, 101.0, 68.0, 89.0, 20.0, 54.0, 101.0, 101.0, 46.0, 101.0, 37.0, 51.0, 101.0, 101.0, 19.0, 100.0, 31.0, 26.0, 90.0, 12.0, 101.0, 92.0, 84.0, 101.0, 101.0, 101.0, 101.0, 5.0, 101.0, 4.0, 101.0, 101.0, 96.0, 101.0, 74.0, 50.0, 101.0, 69.0, 53.0, 31.0, 32.0, 15.0, 29.0, 101.0, 101.0, 101.0, 41.0, 101.0, 21.0, 10.0, 101.0, 101.0, 26.0, 101.0, 101.0, 101.0, 101.0, 67.0, 62.0, 3.0, 86.0, 14.0, 52.0, 96.0, 27.0, 101.0, 101.0, 101.0, 101.0, 77.0, 101.0, 39.0, 101.0, 50.0, 101.0, 101.0, 101.0, 38.0, 89.0, 64.0, 101.0, 74.0, 76.0, 25.0, 101.0, 29.0, 101.0, 3.0, 1.0, 101.0, 30.0, 101.0, 35.0, 20.0, 27.0, 15.0, 101.0, 101.0, 12.0, 23.0, 101.0, 101.0, 101.0, 11.0, 9.0, 2.0, 101.0, 101.0, 18.0, 35.0, 101.0, 2.0, 77.0, 101.0, 101.0, 101.0, 47.0, 101.0, 55.0, 101.0, 101.0, 101.0, 98.0, 76.0, 101.0, 101.0, 18.0, 101.0, 45.0, 60.0, 101.0, 91.0, 89.0, 101.0, 85.0, 52.0, 70.0, 16.0, 93.0, 101.0, 101.0, 64.0, 101.0, 101.0, 76.0, 53.0, 101.0, 101.0, 29.0, 60.0, 101.0, 77.0, 101.0, 8.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 74.0, 101.0, 64.0, 101.0, 101.0, 101.0, 101.0, 101.0, 87.0, 22.0, 62.0, 31.0, 101.0, 101.0, 101.0, 36.0, 25.0, 101.0, 14.0, 101.0, 18.0, 101.0, 46.0, 101.0, 84.0, 101.0, 101.0, 20.0, 101.0, 10.0, 101.0, 2.0, 3.0, 93.0, 37.0, 8.0, 101.0, 27.0, 4.0, 25.0, 101.0, 101.0, 101.0, 101.0, 57.0, 30.0, 82.0, 101.0, 71.0, 16.0, 101.0, 101.0, 101.0, 12.0, 92.0, 19.0, 101.0, 22.0, 101.0, 80.0, 56.0, 17.0, 28.0, 101.0, 2.0, 101.0, 63.0, 101.0, 86.0, 101.0, 66.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 45.0, 9.0, 51.0, 101.0, 101.0, 33.0, 54.0, 93.0, 101.0, 101.0, 101.0, 2.0, 76.0, 101.0, 28.0, 26.0, 101.0, 101.0, 9.0, 42.0, 101.0, 36.0, 101.0, 15.0, 61.0, 101.0, 101.0, 101.0, 101.0, 78.0, 13.0, 48.0, 88.0, 101.0, 101.0, 45.0, 17.0, 101.0, 39.0, 5.0, 101.0, 101.0, 20.0, 101.0, 101.0, 101.0, 101.0, 34.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 5.0, 31.0, 96.0, 101.0, 101.0, 101.0, 98.0, 101.0, 17.0, 101.0, 101.0, 101.0, 69.0, 101.0, 8.0, 101.0, 101.0, 52.0, 88.0, 101.0, 79.0, 41.0, 83.0, 101.0, 47.0, 101.0, 101.0, 101.0, 101.0, 101.0, 66.0, 1.0, 82.0, 96.0, 101.0, 29.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 42.0, 30.0, 53.0, 101.0, 19.0, 8.0, 101.0, 30.0, 101.0, 19.0, 101.0, 101.0, 32.0, 46.0, 57.0, 101.0, 101.0, 101.0, 101.0, 29.0, 73.0, 101.0, 92.0, 84.0, 101.0, 101.0, 22.0, 101.0, 101.0, 101.0, 101.0, 101.0, 89.0, 101.0, 101.0, 101.0, 34.0, 67.0, 101.0, 24.0, 101.0, 89.0, 23.0, 101.0, 45.0, 101.0, 71.0, 101.0, 101.0, 101.0, 101.0, 65.0, 101.0, 101.0, 101.0, 101.0, 36.0, 53.0, 101.0, 101.0, 101.0, 28.0, 101.0, 65.0, 101.0, 101.0, 34.0, 101.0, 101.0, 68.0, 101.0, 85.0, 101.0, 101.0, 101.0, 9.0, 60.0, 42.0, 101.0, 97.0, 87.0, 101.0, 28.0, 82.0, 7.0, 32.0, 90.0, 54.0, 101.0, 36.0, 91.0, 41.0, 33.0, 101.0, 101.0, 41.0, 101.0, 53.0, 101.0, 101.0, 101.0, 12.0, 85.0, 101.0, 101.0, 101.0, 89.0, 30.0, 101.0, 2.0, 26.0, 53.0, 99.0, 101.0, 101.0, 67.0, 51.0, 101.0, 50.0, 26.0, 101.0, 101.0, 68.0, 101.0, 11.0, 101.0, 68.0, 11.0, 101.0, 101.0, 42.0, 101.0, 13.0, 101.0, 101.0, 20.0, 27.0, 58.0, 101.0, 101.0, 101.0, 101.0, 79.0, 81.0, 92.0, 101.0, 101.0, 101.0, 101.0, 101.0, 60.0, 101.0, 101.0, 76.0, 26.0, 33.0, 101.0, 47.0, 101.0, 85.0, 10.0, 32.0, 101.0, 101.0, 56.0, 101.0, 101.0, 28.0, 101.0, 99.0, 95.0, 101.0, 101.0, 101.0, 101.0, 30.0, 101.0, 101.0, 101.0, 101.0, 101.0, 80.0, 21.0, 101.0, 101.0, 101.0, 51.0, 101.0, 101.0, 101.0, 34.0, 59.0, 101.0, 101.0, 13.0, 36.0, 101.0, 101.0, 38.0, 95.0, 89.0, 101.0, 101.0, 101.0, 4.0, 101.0, 101.0, 36.0, 46.0, 101.0, 12.0, 101.0, 1.0, 26.0, 100.0, 89.0, 4.0, 60.0, 101.0, 89.0, 56.0, 67.0, 27.0, 89.0, 101.0, 44.0, 80.0, 57.0, 88.0, 4.0, 2.0, 101.0, 101.0, 101.0, 101.0, 101.0, 78.0, 10.0, 26.0, 101.0, 16.0, 55.0, 90.0, 101.0, 101.0, 6.0, 101.0, 40.0, 101.0, 101.0, 101.0, 101.0, 101.0, 67.0, 48.0, 31.0, 101.0, 101.0, 78.0, 61.0, 9.0, 101.0, 101.0, 101.0, 101.0, 101.0, 23.0, 101.0, 101.0, 88.0, 93.0, 101.0, 101.0, 101.0, 101.0, 101.0, 11.0, 4.0, 101.0, 67.0, 85.0, 101.0, 101.0, 101.0, 6.0, 25.0, 66.0, 101.0, 101.0, 101.0, 14.0, 101.0, 101.0, 2.0, 101.0, 8.0, 24.0, 19.0, 101.0, 101.0, 90.0, 58.0, 83.0, 101.0, 13.0, 42.0, 61.0, 61.0, 89.0, 101.0, 101.0, 97.0, 73.0, 89.0, 101.0, 38.0, 101.0, 69.0, 74.0, 101.0, 33.0, 84.0, 45.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 68.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 65.0, 101.0, 101.0, 38.0, 6.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 101.0, 65.0, 83.0, 12.0, 33.0, 21.0, 8.0, 101.0, 8.0, 39.0, 8.0, 101.0, 26.0, 101.0, 2.0, 101.0, 101.0, 101.0, 101.0, 89.0, 101.0, 57.0, 101.0, 24.0, 101.0, 101.0, 72.0, 101.0, 101.0, 101.0, 4.0, 101.0, 10.0, 101.0, 101.0, 25.0, 101.0, 101.0, 43.0, 21.0, 101.0, 2.0, 34.0, 101.0, 97.0, 4.0, 62.0, 101.0, 7.0, 70.0, 101.0, 101.0, 31.0, 101.0, 101.0]
In [7]:
data = pd.read_csv(
"python/test_alpenglow/test_data_4",
sep=' ',
header=None,
names=['time', 'user', 'item', 'id', 'score', 'eval']
)
model = ag.OfflineModel()
model.fit(data)
def predict(model, user, item):
rd = rs.RecDat()
rd.user = user
rd.item = item
return model.prediction(rd)
errors = [(1 - predict(model.model, u, i))**2 for (u, i) in data[['user', 'item']].values]
rmse = np.sqrt(pd.Series(errors)).mean()
In [8]:
rmse
Out[8]:
0.31307693145764515
In [1]:
%matplotlib inline
import alpenglow as ag
import alpenglow.Getter as rs
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import alpenglow.experiments
import alpenglow.evaluation
In [2]:
data = pd.read_csv(
"python/test_alpenglow/test_data_4",
sep=' ',
header=None,
names=['time', 'user', 'item', 'id', 'score', 'eval']
)
exp = ag.OfflineModel()
exp.fit(data)
In [3]:
preds = exp.recommend()
In [5]:
exp.model.write("model_save")
In [6]:
exp2 = ag.OfflineModel()
In [ ]:
In [10]:
print(list(preds['item']))
[94, 30, 166, 225, 300, 299, 442, 196, 455, 337, 372, 462, 250, 256, 427, 204, 38, 247, 429, 62, 36, 338, 496, 215, 177, 293, 255, 128, 40, 156, 165, 86, 375, 102, 483, 371, 444, 211, 383, 450, 266, 292, 108, 25, 120, 468, 251, 97, 497, 282, 414, 4, 168, 69, 491, 298, 197, 277, 452, 181, 479, 81, 325, 16, 421, 263, 330, 54, 161, 434, 295, 271, 99, 464, 351, 400, 395, 5, 458, 348, 245, 22, 216, 118, 105, 236, 221, 377, 440, 191, 425, 17, 436, 205, 127, 278, 265, 77, 80, 284, 197, 300, 16, 427, 86, 116, 165, 440, 29, 6, 491, 234, 204, 215, 403, 318, 356, 436, 139, 181, 99, 452, 296, 425, 58, 295, 468, 95, 108, 266, 281, 483, 271, 78, 351, 299, 112, 429, 419, 250, 12, 434, 478, 284, 192, 93, 127, 362, 254, 488, 205, 105, 330, 178, 142, 15, 445, 206, 302, 409, 497, 260, 390, 273, 481, 111, 450, 152, 72, 63, 294, 146, 19, 45, 232, 237, 65, 48, 276, 426, 7, 252, 380, 185, 268, 136, 228, 406, 144, 446, 381, 122, 459, 270, 35, 27, 349, 441, 49, 87, 166, 225, 30, 38, 196, 299, 177, 293, 442, 250, 247, 256, 483, 292, 337, 36, 25, 156, 444, 211, 450, 215, 108, 266, 414, 491, 204, 330, 375, 181, 351, 282, 251, 348, 62, 102, 86, 128, 271, 4, 165, 97, 40, 69, 96, 298, 146, 174, 16, 277, 99, 197, 120, 421, 168, 325, 454, 245, 425, 284, 161, 221, 236, 216, 383, 205, 54, 127, 22, 464, 233, 400, 81, 80, 118, 112, 78, 278, 191, 403, 479, 5, 436, 478, 318, 377, 356, 17, 234, 458, 6, 419, 265, 58, 95, 77, 289, 122, 139, 296, 30, 225, 166, 94, 299, 300, 372, 337, 98, 462, 196, 215, 36, 496, 250, 40, 338, 62, 455, 256, 429, 444, 204, 120, 255, 38, 247, 293, 211, 383, 292, 434, 165, 427, 128, 156, 25, 483, 263, 97, 177, 491, 81, 251, 86, 102, 181, 452, 414, 497, 400, 168, 375, 99, 4, 271, 395, 295, 450, 371, 277, 325, 108, 479, 266, 188, 351, 197, 421, 298, 464, 246, 195, 69, 162, 440, 494, 498, 53, 206, 330, 418, 410, 447, 425, 23, 281, 205, 127, 54, 192, 161, 5, 93, 348, 314, 12, 78, 105, 112, 94, 225, 30, 166, 300, 442, 299, 98, 337, 250, 62, 372, 496, 40, 215, 462, 204, 293, 255, 429, 427, 38, 36, 455, 247, 165, 128, 338, 25, 444, 156, 292, 86, 256, 266, 450, 177, 108, 371, 375, 251, 483, 97, 497, 211, 120, 383, 434, 491, 102, 468, 263, 81, 181, 400, 395, 99, 4, 452, 414, 271, 421, 325, 464, 277, 22, 245, 216, 298, 295, 351, 168, 118, 127, 191, 425, 197, 195, 479, 221, 236, 16, 330, 54, 206, 69, 278, 188, 282, 80, 161, 436, 478, 146, 440, 5, 162, 246, 377, 78, 204, 225, 166, 30, 196, 337, 247, 98, 62, 375, 250, 462, 102, 299, 497, 256, 40, 372, 429, 468, 156, 427, 266, 108, 450, 496, 395, 38, 455, 452, 251, 371, 177, 483, 282, 263, 255, 168, 215, 298, 245, 118, 16, 197, 325, 338, 216, 81, 22, 97, 69, 464, 54, 188, 191, 236, 161, 479, 278, 36, 80, 221, 25, 458, 211, 400, 5, 195, 277, 246, 162, 53, 292, 498, 410, 418, 414, 23, 494, 447, 116, 29, 284, 377, 434, 17, 77, 4, 440, 403, 289, 265, 120, 318, 488, 58, 6, 296, 397, 234, 94, 225, 30, 166, 442, 299, 98, 337, 204, 372, 250, 62, 247, 128, 40, 496, 455, 256, 215, 86, 429, 36, 383, 427, 38, 102, 338, 293, 375, 255, 156, 497, 177, 251, 483, 452, 371, 211, 266, 450, 108, 292, 263, 395, 25, 468, 444, 81, 120, 97, 400, 434, 168, 414, 282, 69, 298, 197, 421, 188, 277, 325, 479, 4, 54, 464, 16, 491, 161, 195, 246, 245, 162, 118, 5, 22, 498, 53, 216, 418, 181, 410, 236, 494, 458, 271, 221, 23, 447, 191, 278, 99, 80, 295, 436, 330, 377, 440, 116, 17, 225, 166, 94, 442, 300, 98, 337, 372, 215, 196, 462, 250, 36, 40, 496, 62, 338, 455, 429, 204, 256, 255, 444, 120, 38, 427, 247, 292, 165, 293, 483, 383, 434, 211, 97, 128, 414, 25, 156, 251, 452, 86, 81, 497, 177, 263, 491, 181, 102, 400, 298, 371, 450, 395, 325, 99, 271, 375, 266, 168, 295, 108, 4, 421, 188, 464, 330, 351, 197, 498, 246, 205, 162, 348, 479, 494, 53, 440, 195, 410, 418, 277, 281, 447, 23, 206, 425, 69, 192, 314, 127, 93, 468, 12, 105, 78, 245, 22, 112, 353, 166, 442, 300, 215, 337, 196, 250, 462, 372, 496, 36, 429, 165, 247, 455, 256, 338, 383, 128, 452, 86, 255, 497, 251, 434, 483, 292, 395, 427, 414, 38, 263, 444, 102, 120, 188, 293, 400, 97, 298, 25, 211, 246, 410, 162, 53, 494, 418, 371, 447, 23, 156, 181, 195, 450, 325, 491, 421, 375, 266, 108, 271, 464, 348, 99, 278, 295, 236, 330, 351, 221, 468, 168, 197, 205, 80, 245, 22, 118, 105, 216, 206, 281, 191, 101, 440, 488, 69, 479, 78, 93, 314, 192, 112, 96, 174, 12, 454, 353, 127, 166, 30, 94, 225, 462, 455, 337, 442, 98, 102, 177, 300, 36, 299, 247, 168, 211, 69, 282, 196, 204, 128, 215, 375, 479, 197, 86, 120, 429, 161, 156, 38, 5, 165, 54, 452, 277, 458, 444, 427, 483, 4, 263, 250, 16, 62, 17, 77, 81, 377, 265, 289, 496, 330, 497, 397, 440, 40, 132, 29, 414, 116, 293, 113, 205, 251, 371, 295, 357, 400, 6, 403, 454, 348, 234, 468, 233, 281, 318, 436, 356, 12, 271, 488, 58, 192, 188, 93, 95, 491, 434, 296, 314, 255, 298, 139, 146, 195, 362, 353, 166, 225, 94, 442, 98, 462, 337, 256, 36, 196, 215, 338, 250, 204, 429, 496, 247, 40, 427, 62, 38, 177, 383, 211, 102, 444, 255, 120, 483, 128, 156, 165, 293, 414, 86, 292, 375, 168, 452, 371, 69, 282, 251, 298, 97, 81, 181, 197, 497, 25, 4, 479, 263, 491, 434, 277, 450, 348, 330, 295, 266, 400, 351, 271, 108, 161, 54, 5, 395, 105, 188, 99, 325, 205, 468, 458, 440, 421, 16, 498, 162, 246, 96, 418, 494, 53, 78, 357, 174, 410, 454, 112, 464, 281, 23, 17, 447, 377, 139, 265, 30, 225, 94, 299, 337, 372, 215, 98, 62, 40, 250, 496, 204, 36, 165, 247, 128, 383, 429, 338, 86, 256, 263, 455, 434, 293, 444, 255, 497, 452, 81, 292, 102, 251, 120, 38, 211, 188, 25, 427, 156, 483, 375, 246, 498, 177, 162, 181, 53, 410, 97, 494, 418, 23, 447, 414, 195, 491, 168, 108, 266, 99, 271, 450, 371, 298, 277, 421, 479, 325, 4, 197, 351, 464, 468, 69, 278, 236, 54, 221, 206, 161, 295, 5, 80, 22, 78, 118, 458, 105, 245, 112, 216, 348, 191, 488, 440, 127, 425, 281, 166, 94, 300, 40, 98, 250, 496, 215, 372, 36, 462, 204, 338, 255, 429, 292, 444, 120, 293, 434, 165, 38, 97, 25, 455, 427, 128, 247, 156, 395, 256, 414, 497, 181, 483, 251, 86, 263, 450, 383, 211, 491, 81, 452, 266, 298, 108, 400, 99, 325, 188, 464, 246, 421, 498, 162, 375, 494, 271, 53, 351, 410, 447, 418, 371, 23, 4, 278, 221, 236, 102, 195, 78, 112, 80, 295, 177, 127, 22, 206, 168, 425, 245, 216, 419, 118, 281, 191, 440, 468, 192, 277, 93, 314, 105, 348, 12, 205, 353, 478, 414, 53, 348, 181, 447, 246, 292, 494, 78, 410, 174, 139, 351, 96, 278, 101, 236, 162, 23, 498, 369, 188, 357, 105, 395, 221, 80, 419, 418, 298, 112, 94, 30, 225, 166, 299, 98, 442, 196, 337, 250, 204, 372, 62, 462, 455, 496, 247, 40, 165, 429, 427, 215, 128, 256, 38, 36, 86, 293, 255, 338, 156, 177, 102, 375, 383, 483, 450, 371, 266, 497, 108, 292, 25, 251, 444, 211, 468, 97, 452, 120, 414, 81, 395, 298, 263, 434, 421, 491, 400, 325, 282, 168, 4, 197, 464, 277, 69, 181, 245, 22, 99, 216, 118, 16, 271, 479, 191, 236, 221, 295, 188, 54, 278, 330, 161, 80, 351, 195, 5, 436, 127, 162, 458, 246, 498, 440, 425, 348, 53, 205, 225, 166, 94, 299, 442, 300, 372, 98, 337, 462, 196, 215, 36, 455, 250, 338, 496, 256, 40, 62, 204, 429, 247, 444, 255, 38, 427, 383, 120, 211, 165, 128, 293, 483, 177, 102, 156, 292, 86, 434, 414, 452, 251, 97, 81, 25, 497, 263, 375, 168, 491, 371, 400, 181, 4, 450, 298, 69, 197, 271, 479, 295, 395, 325, 266, 99, 277, 108, 330, 282, 421, 188, 351, 464, 205, 440, 348, 54, 161, 468, 246, 498, 5, 195, 162, 281, 494, 53, 418, 410, 458, 447, 314, 192, 206, 23, 425, 105, 93, 12, 94, 165, 86, 102, 455, 225, 30, 462, 375, 196, 337, 177, 372, 427, 468, 69, 429, 156, 497, 371, 452, 38, 16, 197, 62, 266, 442, 168, 161, 450, 483, 54, 108, 250, 5, 458, 479, 251, 298, 299, 395, 293, 277, 211, 29, 81, 188, 116, 236, 284, 377, 263, 421, 221, 80, 17, 338, 77, 118, 245, 278, 289, 265, 436, 216, 191, 36, 357, 414, 22, 418, 498, 53, 4, 410, 403, 397, 162, 6, 23, 246, 318, 494, 325, 234, 447, 330, 356, 348, 454, 113, 464, 58, 139, 195, 101, 132, 233, 296, 488, 94, 225, 30, 166, 300, 299, 442, 337, 250, 62, 372, 455, 165, 247, 462, 427, 128, 429, 40, 496, 86, 38, 256, 293, 215, 255, 36, 156, 375, 102, 450, 371, 266, 177, 338, 108, 483, 383, 497, 468, 251, 25, 292, 97, 452, 211, 298, 395, 444, 414, 81, 282, 421, 120, 325, 263, 464, 197, 400, 245, 22, 434, 216, 16, 69, 118, 168, 4, 491, 236, 221, 277, 191, 278, 80, 188, 181, 479, 54, 99, 161, 271, 330, 295, 436, 5, 351, 195, 284, 498, 162, 458, 246, 348, 127, 53, 410, 418, 447, 494, 166, 442, 196, 337, 215, 40, 372, 496, 429, 462, 427, 256, 247, 165, 255, 38, 86, 483, 338, 128, 414, 292, 293, 371, 251, 497, 156, 97, 383, 266, 102, 25, 108, 177, 395, 81, 444, 120, 375, 468, 211, 434, 325, 421, 181, 188, 400, 464, 348, 278, 221, 236, 498, 330, 491, 263, 80, 245, 351, 162, 246, 22, 197, 53, 118, 410, 216, 494, 418, 295, 447, 99, 282, 271, 205, 105, 191, 23, 112, 78, 195, 454, 16, 69, 96, 168, 4, 101, 440, 419, 281, 174, 233, 127, 314, 369, 192, 425, 488, 436, 300, 442, 372, 250, 256, 196, 429, 462, 36, 38, 204, 338, 215, 496, 40, 255, 62, 156, 483, 414, 247, 292, 293, 177, 371, 450, 97, 120, 444, 165, 266, 128, 375, 211, 86, 25, 108, 102, 181, 251, 468, 325, 348, 383, 351, 497, 168, 282, 491, 4, 330, 421, 236, 221, 295, 464, 197, 105, 278, 80, 395, 452, 69, 112, 78, 99, 271, 205, 96, 434, 419, 245, 479, 440, 174, 81, 277, 139, 216, 369, 22, 118, 16, 454, 101, 191, 281, 314, 127, 425, 233, 357, 192, 436, 403, 400, 498, 162, 188, 12, 284, 16, 436, 455, 102, 127, 215, 99, 177, 112, 78, 434, 452, 318, 403, 58, 195, 188, 419, 425, 162, 254, 491, 296, 478, 400, 498, 447, 246, 122, 351, 95, 362, 356, 53, 410, 440, 314, 81, 494, 15, 4, 234, 418, 197, 6, 499, 181, 369, 105, 23, 1, 256, 129, 228, 270, 481, 290, 407, 361, 52, 273, 282, 336, 35, 90, 281, 485, 227, 305, 493, 232, 139, 7, 230, 50, 268, 404, 48, 171, 473, 231, 460, 79, 19, 408, 131, 206, 72, 459, 150, 186, 136, 183, 474, 381, 164, 210, 43, 426, 225, 166, 299, 300, 442, 196, 98, 250, 337, 496, 40, 215, 62, 372, 204, 462, 429, 36, 247, 427, 128, 86, 293, 38, 455, 251, 338, 483, 292, 497, 256, 25, 383, 444, 371, 414, 434, 97, 452, 395, 400, 211, 156, 102, 263, 450, 108, 266, 120, 375, 177, 491, 325, 468, 298, 421, 181, 188, 271, 464, 195, 295, 99, 245, 498, 22, 330, 246, 216, 118, 162, 494, 410, 53, 191, 418, 447, 278, 23, 236, 221, 351, 348, 80, 168, 197, 206, 205, 105, 440, 146, 4, 314, 436, 127, 281, 488, 425, 479, 69, 429, 98, 256, 483, 488, 421, 211, 206, 278, 116, 118, 101, 191, 414, 22, 245, 271, 29, 325, 298, 197, 254, 464, 338, 216, 93, 236, 80, 292, 221, 69, 479, 375, 353, 5, 25, 281, 205, 12, 54, 255, 161, 192, 436, 468, 314, 168, 19, 231, 458, 1, 114, 120, 79, 461, 227, 302, 493, 83, 378, 35, 323, 294, 104, 27, 276, 388, 125, 232, 347, 485, 228, 361, 49, 390, 0, 404, 481, 144, 268, 57, 63, 222, 290, 131, 136, 408, 405, 406, 155, 142, 441, 460, 444, 270, 237, 283, 152, 7, 134, 30, 225, 299, 442, 455, 337, 372, 38, 300, 36, 156, 250, 429, 483, 496, 444, 462, 215, 293, 196, 292, 371, 177, 450, 375, 25, 168, 266, 298, 62, 108, 295, 4, 464, 491, 421, 440, 204, 468, 205, 247, 479, 197, 271, 99, 181, 281, 69, 192, 245, 12, 93, 277, 216, 251, 348, 351, 436, 454, 403, 118, 22, 425, 318, 353, 191, 233, 127, 86, 128, 6, 165, 356, 234, 58, 95, 105, 362, 102, 146, 296, 478, 434, 236, 54, 221, 497, 17, 161, 16, 80, 278, 206, 132, 458, 377, 397, 5, 499, 29, 30, 94, 166, 300, 204, 337, 442, 462, 196, 247, 86, 98, 256, 102, 250, 40, 215, 452, 429, 455, 497, 36, 496, 375, 263, 81, 395, 251, 338, 177, 188, 483, 156, 282, 168, 427, 69, 211, 38, 468, 400, 197, 498, 479, 410, 246, 53, 418, 293, 195, 162, 494, 23, 266, 434, 371, 54, 161, 447, 298, 450, 108, 5, 16, 458, 421, 255, 414, 120, 277, 325, 97, 464, 116, 118, 29, 245, 236, 278, 191, 22, 216, 436, 377, 221, 77, 444, 80, 440, 17, 488, 292, 25, 265, 289, 4, 397, 205, 403, 281, 98, 300, 211, 338, 204, 337, 452, 81, 38, 197, 168, 295, 105, 479, 196, 161, 250, 444, 400, 16, 5, 146, 128, 96, 271, 54, 174, 458, 165, 496, 375, 29, 255, 116, 298, 351, 497, 440, 491, 277, 263, 289, 6, 17, 265, 403, 181, 488, 314, 77, 377, 362, 356, 188, 318, 101, 234, 120, 95, 397, 58, 139, 113, 15, 281, 122, 4, 12, 357, 93, 132, 369, 192, 436, 296, 284, 498, 353, 418, 468, 494, 53, 156, 308, 134, 410, 380, 200, 23, 157, 65, 273, 70, 162, 445, 441, 144, 406, 39, 246, 94, 166, 30, 225, 462, 442, 98, 372, 337, 299, 196, 204, 256, 455, 247, 165, 128, 102, 250, 86, 36, 62, 215, 429, 338, 177, 427, 496, 40, 375, 38, 452, 497, 211, 156, 483, 282, 293, 251, 69, 168, 371, 255, 81, 263, 197, 468, 444, 479, 266, 120, 450, 161, 108, 54, 400, 277, 5, 16, 395, 414, 458, 25, 4, 298, 188, 97, 434, 292, 421, 330, 325, 195, 377, 17, 116, 29, 77, 464, 265, 295, 440, 498, 246, 289, 162, 418, 271, 53, 436, 491, 205, 410, 494, 245, 118, 23, 397, 447, 348, 225, 94, 98, 300, 462, 196, 338, 36, 215, 256, 250, 496, 40, 62, 444, 38, 120, 429, 427, 177, 255, 211, 204, 247, 156, 292, 383, 102, 375, 168, 483, 25, 181, 165, 97, 434, 491, 414, 263, 277, 86, 479, 450, 69, 99, 251, 351, 266, 371, 452, 197, 108, 497, 81, 271, 298, 295, 282, 400, 54, 161, 5, 395, 325, 348, 78, 458, 112, 105, 440, 330, 425, 357, 188, 421, 17, 419, 464, 377, 246, 127, 77, 162, 265, 468, 205, 132, 96, 494, 281, 498, 397, 53, 418, 289, 206, 447, 410, 174, 23, 225, 166, 94, 442, 300, 98, 372, 337, 215, 462, 36, 196, 250, 40, 496, 338, 455, 256, 62, 429, 204, 255, 444, 120, 38, 247, 427, 383, 483, 211, 292, 165, 293, 414, 434, 97, 128, 156, 177, 452, 251, 25, 86, 102, 81, 497, 263, 491, 181, 298, 168, 400, 371, 375, 325, 450, 295, 271, 99, 4, 395, 330, 266, 197, 188, 421, 479, 108, 351, 205, 464, 69, 348, 440, 277, 498, 246, 281, 162, 494, 53, 418, 410, 192, 195, 314, 447, 23, 93, 206, 425, 282, 12, 105, 127, 78, 454, 353, 112, 468, 94, 30, 225, 166, 299, 98, 442, 196, 337, 372, 250, 204, 462, 455, 62, 247, 496, 429, 215, 40, 165, 427, 256, 36, 128, 38, 86, 255, 338, 293, 156, 177, 383, 102, 483, 375, 371, 497, 450, 292, 251, 266, 25, 444, 211, 108, 468, 97, 452, 120, 414, 81, 395, 263, 298, 434, 282, 400, 168, 491, 421, 325, 197, 69, 4, 464, 277, 181, 271, 479, 16, 245, 99, 22, 330, 295, 118, 216, 54, 188, 161, 191, 236, 221, 351, 278, 5, 80, 195, 348, 458, 436, 440, 162, 246, 205, 498, 105, 127, 53, 30, 225, 166, 299, 94, 196, 98, 337, 250, 215, 40, 372, 62, 36, 462, 255, 429, 338, 204, 293, 292, 444, 38, 427, 455, 25, 165, 434, 247, 120, 97, 128, 251, 256, 483, 491, 156, 211, 181, 497, 86, 414, 81, 263, 383, 400, 395, 450, 108, 266, 371, 99, 452, 271, 177, 325, 351, 298, 421, 375, 464, 295, 188, 102, 4, 246, 162, 195, 498, 494, 53, 127, 447, 410, 206, 425, 418, 22, 468, 23, 245, 216, 278, 221, 277, 118, 330, 78, 168, 236, 105, 112, 191, 348, 80, 281, 440, 205, 192, 419, 166, 225, 30, 300, 98, 256, 247, 455, 337, 165, 196, 462, 128, 86, 372, 299, 442, 102, 427, 383, 375, 429, 177, 250, 62, 38, 156, 371, 483, 468, 497, 36, 452, 266, 69, 338, 450, 40, 251, 108, 293, 215, 168, 496, 197, 211, 16, 255, 298, 161, 479, 54, 81, 414, 5, 395, 458, 421, 263, 277, 325, 245, 97, 118, 464, 330, 216, 29, 4, 22, 191, 400, 116, 436, 25, 236, 188, 377, 284, 17, 221, 77, 278, 80, 440, 289, 265, 403, 454, 120, 318, 6, 195, 205, 292, 356, 233, 348, 234, 397, 299, 30, 166, 94, 442, 300, 196, 250, 496, 337, 98, 215, 204, 372, 36, 429, 462, 255, 165, 338, 292, 293, 434, 25, 427, 444, 38, 97, 247, 128, 251, 497, 120, 86, 483, 395, 81, 455, 450, 156, 452, 414, 263, 400, 266, 108, 383, 256, 491, 325, 181, 371, 211, 298, 464, 421, 99, 188, 271, 195, 375, 498, 22, 246, 162, 245, 216, 410, 494, 53, 118, 447, 468, 102, 418, 295, 278, 191, 23, 221, 206, 236, 351, 127, 80, 425, 177, 4, 281, 314, 440, 192, 93, 205, 330, 78, 112, 12, 353, 488, 30, 300, 299, 442, 196, 337, 372, 455, 462, 38, 429, 496, 255, 256, 36, 62, 215, 293, 338, 204, 247, 40, 177, 292, 156, 444, 371, 128, 483, 165, 25, 211, 450, 375, 414, 86, 266, 108, 102, 120, 97, 181, 251, 491, 298, 383, 468, 351, 4, 497, 168, 282, 348, 271, 295, 105, 395, 99, 325, 277, 330, 434, 197, 69, 421, 81, 236, 221, 464, 278, 400, 80, 96, 78, 479, 112, 452, 16, 263, 174, 245, 419, 22, 216, 54, 161, 425, 127, 118, 440, 191, 139, 205, 5, 146, 357, 436, 162, 188, 458, 94, 166, 225, 300, 98, 299, 337, 442, 427, 247, 250, 256, 372, 462, 165, 128, 38, 62, 429, 86, 177, 156, 375, 293, 102, 40, 496, 255, 371, 450, 36, 338, 483, 215, 108, 468, 383, 497, 282, 251, 298, 292, 25, 211, 97, 414, 452, 69, 197, 16, 444, 168, 421, 395, 4, 325, 120, 277, 464, 245, 81, 236, 479, 54, 161, 216, 118, 22, 221, 278, 80, 191, 5, 263, 330, 458, 491, 284, 400, 348, 436, 295, 181, 351, 99, 377, 105, 29, 271, 17, 403, 188, 440, 434, 205, 454, 116, 318, 265, 77, 166, 299, 462, 98, 300, 36, 256, 215, 455, 196, 496, 250, 40, 444, 120, 383, 211, 62, 177, 247, 38, 102, 204, 168, 427, 255, 414, 483, 292, 156, 128, 293, 434, 263, 181, 165, 452, 375, 479, 69, 81, 4, 491, 86, 97, 197, 277, 251, 400, 25, 295, 282, 271, 497, 351, 348, 188, 161, 5, 54, 330, 298, 99, 440, 246, 395, 162, 494, 458, 418, 53, 105, 498, 410, 23, 371, 357, 205, 447, 325, 96, 281, 174, 139, 78, 17, 77, 112, 265, 377, 192, 93, 289, 132, 314, 12, 101, 397, 206, 419, 215, 444, 196, 177, 496, 168, 250, 40, 383, 429, 427, 414, 483, 102, 62, 4, 255, 479, 375, 97, 69, 247, 292, 204, 197, 293, 277, 181, 282, 491, 434, 295, 440, 128, 161, 5, 54, 458, 452, 263, 205, 330, 351, 99, 348, 25, 325, 271, 281, 357, 192, 17, 12, 78, 314, 93, 139, 112, 77, 265, 377, 105, 132, 289, 86, 397, 419, 450, 165, 425, 371, 81, 454, 403, 353, 113, 6, 369, 464, 96, 101, 233, 497, 251, 234, 174, 266, 356, 16, 318, 29, 127, 400, 206, 436, 116, 108, 95, 58, 478, 337, 255, 483, 166, 225, 298, 497, 236, 221, 245, 80, 216, 22, 118, 25, 278, 30, 69, 191, 197, 421, 251, 54, 161, 464, 277, 292, 395, 4, 458, 325, 5, 383, 436, 97, 377, 403, 29, 168, 318, 414, 479, 234, 372, 356, 116, 58, 6, 17, 105, 296, 77, 95, 265, 289, 462, 139, 357, 362, 348, 112, 330, 397, 211, 419, 351, 78, 127, 454, 96, 113, 254, 442, 478, 233, 132, 146, 174, 122, 290, 268, 252, 228, 1, 369, 144, 183, 15, 390, 90, 445, 388, 499, 230, 484, 425, 72, 273, 237, 70, 338, 40, 337, 99, 62, 256, 434, 4, 425, 120, 205, 454, 127, 206, 233, 97, 108, 78, 112, 478, 450, 362, 156, 419, 263, 277, 266, 102, 383, 69, 282, 122, 314, 284, 468, 497, 15, 369, 132, 403, 488, 268, 356, 101, 139, 308, 204, 237, 35, 65, 445, 144, 484, 48, 361, 157, 353, 318, 437, 265, 323, 347, 404, 200, 302, 95, 0, 70, 231, 446, 294, 113, 407, 16, 7, 473, 129, 43, 45, 485, 136, 298, 134, 409, 499, 59, 39, 344, 104, 145, 331, 276, 406, 290, 283, 252, 125, 130, 1, 405, 94, 30, 225, 166, 299, 196, 442, 337, 204, 250, 372, 455, 462, 62, 427, 247, 429, 165, 496, 256, 38, 40, 128, 215, 36, 293, 255, 86, 338, 156, 177, 375, 102, 371, 450, 483, 266, 383, 108, 292, 25, 497, 251, 444, 468, 211, 97, 414, 120, 452, 298, 395, 282, 81, 263, 491, 421, 4, 168, 325, 434, 197, 69, 400, 181, 277, 464, 16, 245, 22, 216, 236, 99, 118, 479, 221, 271, 278, 54, 351, 191, 80, 295, 330, 161, 188, 5, 348, 105, 458, 436, 127, 162, 246, 440, 195, 498, 284, 425, 377, 166, 225, 299, 372, 98, 462, 196, 256, 36, 215, 455, 250, 40, 62, 496, 204, 247, 429, 383, 128, 120, 165, 38, 444, 156, 211, 102, 293, 427, 177, 255, 375, 86, 292, 168, 483, 414, 263, 97, 434, 497, 452, 395, 25, 4, 479, 251, 181, 277, 81, 298, 69, 197, 450, 266, 108, 188, 491, 400, 282, 54, 371, 325, 161, 246, 162, 5, 494, 53, 418, 498, 99, 421, 410, 458, 23, 351, 447, 271, 468, 440, 464, 295, 357, 236, 78, 221, 112, 348, 278, 17, 80, 377, 195, 77, 105, 139, 281, 419, 265, 30, 94, 166, 299, 300, 442, 98, 196, 337, 250, 372, 40, 496, 215, 462, 204, 36, 429, 165, 455, 255, 247, 427, 338, 38, 128, 293, 256, 86, 292, 444, 483, 156, 25, 383, 251, 497, 97, 120, 450, 434, 371, 102, 211, 177, 266, 108, 375, 81, 452, 414, 395, 263, 400, 491, 298, 468, 325, 181, 421, 464, 99, 271, 188, 4, 168, 295, 22, 245, 195, 216, 118, 197, 498, 351, 246, 277, 162, 191, 330, 236, 53, 494, 278, 410, 221, 418, 447, 479, 23, 69, 127, 80, 425, 206, 440, 282, 205, 348, 16, 225, 166, 94, 299, 442, 300, 372, 98, 337, 462, 196, 215, 36, 455, 250, 256, 338, 496, 40, 62, 204, 429, 247, 383, 444, 38, 120, 255, 427, 165, 211, 128, 177, 293, 483, 102, 156, 86, 292, 452, 434, 414, 97, 375, 251, 263, 81, 497, 168, 25, 491, 400, 181, 371, 4, 298, 69, 479, 450, 197, 395, 266, 277, 271, 325, 295, 99, 108, 282, 188, 330, 421, 440, 464, 351, 205, 161, 54, 246, 498, 5, 348, 162, 494, 53, 468, 418, 195, 410, 281, 447, 23, 458, 192, 206, 425, 314, 93, 12, 105, 36, 38, 97, 351, 400, 455, 427, 4, 295, 81, 414, 425, 251, 127, 156, 78, 112, 483, 105, 395, 419, 478, 277, 177, 246, 96, 162, 174, 146, 195, 108, 325, 447, 494, 348, 464, 188, 498, 53, 281, 410, 450, 330, 23, 192, 418, 93, 266, 353, 314, 497, 440, 12, 383, 421, 205, 132, 371, 247, 168, 452, 256, 397, 488, 22, 113, 265, 357, 362, 481, 122, 19, 63, 17, 77, 323, 268, 232, 136, 237, 408, 221, 302, 499, 446, 409, 48, 87, 0, 473, 347, 361, 7, 479, 276, 142, 426, 65, 405, 260, 372, 337, 462, 250, 98, 300, 255, 196, 211, 491, 181, 429, 99, 25, 263, 271, 295, 400, 455, 483, 81, 325, 293, 281, 206, 192, 4, 38, 440, 93, 12, 351, 425, 452, 156, 383, 464, 127, 251, 246, 195, 494, 479, 78, 162, 330, 421, 188, 498, 112, 53, 410, 478, 418, 447, 23, 298, 395, 419, 277, 497, 122, 488, 15, 348, 146, 132, 427, 454, 105, 233, 369, 174, 481, 499, 7, 408, 460, 96, 380, 473, 441, 301, 150, 52, 19, 273, 63, 171, 232, 361, 48, 349, 1, 406, 185, 260, 65, 134, 393, 30, 225, 94, 442, 299, 372, 462, 98, 300, 337, 455, 196, 256, 36, 215, 338, 250, 496, 40, 62, 204, 247, 429, 383, 444, 177, 211, 38, 102, 128, 120, 427, 165, 255, 293, 156, 483, 86, 168, 375, 452, 263, 292, 434, 81, 414, 69, 251, 497, 479, 4, 97, 25, 197, 282, 277, 491, 400, 181, 371, 161, 54, 5, 271, 295, 298, 450, 395, 458, 330, 99, 266, 188, 108, 325, 440, 351, 348, 205, 421, 17, 246, 77, 377, 162, 468, 498, 16, 265, 494, 53, 418, 195, 410, 281, 289, 464, 23, 132, 397, 98, 128, 247, 338, 282, 383, 69, 468, 429, 293, 299, 479, 371, 62, 161, 54, 277, 16, 458, 5, 36, 120, 497, 255, 298, 97, 377, 17, 444, 77, 414, 325, 421, 265, 289, 40, 29, 397, 464, 452, 284, 116, 357, 132, 496, 236, 251, 245, 113, 25, 118, 221, 216, 80, 292, 22, 191, 215, 263, 278, 330, 395, 454, 205, 281, 295, 233, 362, 192, 12, 348, 122, 15, 254, 314, 488, 93, 78, 112, 425, 419, 105, 369, 127, 101, 491, 273, 99, 499, 478, 441, 252, 178, 408, 72, 380, 445, 481, 268, 260, 442, 372, 196, 62, 383, 165, 338, 86, 427, 128, 81, 251, 255, 414, 177, 211, 371, 298, 444, 292, 400, 263, 188, 120, 434, 293, 395, 330, 348, 156, 498, 282, 25, 375, 97, 69, 197, 246, 53, 410, 162, 418, 494, 181, 23, 168, 447, 295, 205, 450, 271, 491, 325, 195, 421, 105, 468, 351, 266, 454, 479, 108, 233, 96, 464, 16, 174, 99, 440, 101, 488, 278, 281, 236, 146, 314, 221, 161, 192, 93, 29, 12, 5, 277, 245, 4, 54, 116, 118, 80, 206, 353, 369, 139, 436, 22, 191, 78, 216, 403, 166, 30, 225, 94, 372, 442, 299, 337, 98, 455, 300, 256, 36, 338, 215, 196, 383, 247, 177, 211, 250, 496, 429, 444, 102, 204, 40, 62, 120, 38, 128, 168, 427, 69, 483, 263, 165, 293, 452, 255, 156, 86, 375, 81, 479, 282, 277, 4, 197, 434, 251, 491, 400, 161, 5, 54, 414, 292, 497, 181, 458, 271, 330, 295, 25, 371, 97, 99, 17, 77, 377, 348, 265, 440, 205, 289, 188, 397, 132, 16, 351, 113, 195, 105, 116, 146, 29, 281, 246, 454, 162, 494, 418, 357, 53, 498, 206, 395, 410, 23, 225, 94, 372, 337, 36, 98, 338, 455, 496, 40, 250, 62, 383, 429, 204, 444, 120, 247, 211, 434, 452, 102, 255, 263, 38, 292, 81, 177, 165, 128, 483, 414, 181, 293, 427, 168, 251, 400, 86, 188, 497, 491, 156, 97, 25, 395, 246, 498, 162, 479, 271, 69, 494, 53, 418, 410, 4, 23, 197, 447, 298, 351, 99, 295, 348, 375, 277, 330, 195, 205, 105, 440, 5, 161, 282, 54, 371, 325, 281, 78, 96, 206, 174, 112, 101, 357, 192, 458, 93, 421, 12, 314, 419, 425, 139, 488, 17, 353, 265, 464, 30, 98, 300, 299, 455, 196, 462, 337, 256, 250, 247, 204, 38, 36, 177, 215, 338, 165, 62, 496, 102, 86, 255, 293, 40, 483, 156, 383, 375, 211, 292, 414, 444, 251, 282, 450, 266, 108, 25, 497, 468, 168, 69, 298, 120, 452, 81, 197, 97, 181, 348, 4, 330, 491, 395, 479, 277, 351, 16, 105, 400, 263, 295, 161, 54, 271, 5, 325, 421, 236, 221, 96, 458, 188, 278, 80, 174, 434, 464, 99, 162, 205, 245, 440, 246, 357, 498, 494, 139, 418, 53, 377, 436, 410, 17, 118, 146, 78, 447, 454, 30, 166, 225, 94, 442, 372, 98, 337, 300, 215, 36, 462, 496, 196, 40, 455, 250, 256, 444, 120, 62, 429, 255, 38, 211, 427, 293, 204, 434, 292, 97, 156, 483, 383, 177, 247, 491, 25, 414, 168, 181, 4, 263, 99, 452, 81, 271, 128, 102, 295, 251, 165, 400, 375, 325, 479, 277, 497, 450, 197, 330, 440, 86, 371, 205, 69, 298, 351, 281, 425, 464, 266, 421, 108, 192, 206, 127, 314, 93, 12, 353, 348, 54, 161, 5, 478, 195, 454, 17, 132, 395, 78, 265, 146, 233, 77, 458, 488, 112, 397, 299, 442, 372, 300, 98, 337, 462, 196, 215, 455, 256, 36, 338, 250, 496, 40, 204, 62, 429, 247, 383, 38, 427, 165, 128, 444, 211, 120, 102, 177, 255, 483, 86, 156, 414, 293, 292, 452, 375, 168, 251, 497, 81, 263, 434, 97, 25, 298, 371, 181, 69, 479, 197, 400, 395, 282, 4, 491, 188, 277, 450, 348, 295, 325, 330, 271, 266, 246, 498, 108, 351, 162, 494, 53, 418, 161, 410, 54, 99, 5, 421, 23, 447, 440, 205, 105, 468, 458, 464, 281, 195, 96, 357, 16, 78, 236, 174, 112, 17, 192, 196, 156, 211, 442, 377, 77, 17, 289, 263, 427, 38, 265, 4, 483, 357, 397, 429, 113, 132, 371, 36, 266, 6, 188, 436, 403, 234, 284, 440, 318, 81, 108, 62, 298, 356, 395, 251, 58, 450, 139, 418, 296, 53, 23, 95, 410, 454, 488, 494, 246, 162, 498, 233, 101, 421, 195, 447, 330, 254, 205, 236, 120, 362, 293, 118, 80, 15, 281, 348, 12, 191, 221, 369, 245, 273, 122, 178, 445, 294, 72, 142, 400, 186, 1, 144, 252, 48, 390, 409, 406, 380, 441, 134, 231, 35, 228, 260, 270, 152, 185, 299, 372, 247, 337, 102, 128, 36, 62, 497, 40, 250, 496, 251, 98, 400, 455, 395, 498, 410, 53, 418, 246, 23, 494, 162, 195, 447, 69, 338, 483, 282, 434, 168, 197, 177, 375, 479, 161, 5, 54, 414, 458, 116, 29, 16, 298, 330, 348, 205, 454, 421, 371, 468, 233, 77, 120, 440, 277, 289, 377, 17, 265, 93, 281, 436, 254, 12, 271, 357, 314, 192, 353, 325, 397, 206, 278, 6, 146, 174, 113, 118, 295, 444, 132, 105, 139, 403, 96, 318, 58, 236, 1, 231, 95, 356, 191, 369, 19, 114, 294, 300, 455, 62, 211, 196, 434, 255, 292, 383, 38, 4, 263, 491, 181, 99, 314, 25, 293, 277, 205, 197, 271, 452, 427, 177, 298, 353, 421, 204, 206, 69, 425, 81, 400, 102, 127, 5, 497, 132, 54, 330, 17, 458, 161, 397, 77, 78, 351, 128, 122, 403, 265, 436, 6, 15, 112, 251, 289, 246, 478, 318, 377, 488, 494, 113, 356, 95, 195, 165, 162, 234, 139, 419, 58, 454, 247, 296, 53, 233, 395, 188, 418, 357, 369, 498, 450, 410, 23, 447, 499, 481, 29, 254, 408, 380, 7, 273, 441, 301, 473, 94, 225, 30, 166, 300, 299, 442, 98, 337, 250, 62, 496, 372, 40, 204, 215, 462, 293, 255, 429, 36, 38, 427, 455, 165, 247, 128, 338, 25, 156, 444, 86, 292, 256, 450, 266, 108, 177, 97, 497, 251, 375, 371, 483, 120, 383, 434, 211, 491, 102, 263, 468, 81, 400, 395, 452, 99, 181, 4, 421, 325, 271, 464, 414, 277, 22, 216, 245, 118, 298, 168, 295, 127, 191, 425, 197, 351, 195, 479, 206, 16, 54, 188, 221, 236, 69, 330, 278, 436, 161, 282, 478, 80, 440, 5, 377, 162, 246, 146, 281, 166, 225, 94, 299, 442, 300, 372, 98, 337, 462, 196, 215, 36, 455, 338, 250, 256, 496, 40, 62, 204, 429, 247, 444, 38, 120, 383, 255, 427, 211, 177, 128, 165, 293, 156, 483, 102, 292, 86, 434, 414, 97, 375, 452, 168, 25, 251, 263, 81, 497, 491, 4, 181, 371, 400, 69, 479, 450, 197, 277, 298, 271, 266, 295, 99, 108, 325, 282, 395, 330, 421, 351, 188, 54, 161, 440, 5, 464, 205, 348, 468, 458, 281, 246, 498, 162, 195, 494, 53, 425, 418, 410, 192, 206, 17, 314, 105, 447, 93, 23, 30, 166, 442, 300, 98, 196, 337, 250, 215, 372, 496, 40, 36, 62, 462, 429, 455, 204, 427, 338, 38, 292, 256, 293, 247, 444, 165, 483, 414, 25, 97, 120, 128, 251, 156, 371, 86, 211, 434, 450, 177, 497, 181, 491, 266, 298, 81, 383, 108, 395, 452, 400, 325, 102, 375, 271, 351, 295, 99, 263, 421, 464, 330, 468, 348, 4, 188, 105, 278, 221, 236, 245, 168, 498, 22, 246, 162, 80, 216, 205, 494, 118, 53, 410, 447, 418, 197, 96, 78, 127, 191, 112, 425, 440, 174, 23, 206, 195, 281, 314, 94, 30, 166, 225, 300, 299, 442, 196, 337, 372, 455, 250, 462, 204, 427, 256, 38, 62, 247, 429, 36, 496, 338, 215, 293, 40, 255, 128, 165, 177, 156, 86, 375, 102, 483, 371, 444, 450, 383, 266, 292, 211, 108, 25, 120, 97, 251, 468, 497, 414, 282, 4, 168, 298, 491, 69, 452, 197, 277, 181, 81, 325, 421, 263, 434, 479, 395, 16, 464, 99, 271, 400, 295, 330, 54, 161, 351, 245, 5, 22, 216, 348, 236, 118, 458, 221, 191, 105, 278, 80, 440, 425, 436, 127, 377, 17, 205, 77, 265, 284, 30, 225, 94, 300, 442, 98, 196, 337, 250, 372, 496, 215, 462, 40, 62, 204, 36, 429, 455, 427, 38, 338, 256, 293, 165, 292, 128, 483, 444, 86, 25, 156, 251, 371, 177, 414, 97, 211, 120, 383, 497, 450, 266, 108, 102, 434, 81, 375, 491, 452, 181, 298, 395, 400, 263, 468, 325, 271, 421, 99, 295, 464, 351, 330, 4, 348, 188, 168, 245, 22, 197, 216, 236, 221, 278, 118, 105, 498, 277, 246, 162, 191, 80, 195, 494, 205, 69, 53, 127, 282, 410, 447, 418, 425, 479, 440, 23, 206, 96, 78, 30, 225, 300, 299, 442, 337, 372, 196, 462, 455, 256, 250, 204, 247, 36, 62, 215, 429, 427, 338, 496, 38, 40, 128, 165, 177, 293, 255, 86, 102, 383, 156, 375, 483, 211, 444, 292, 371, 120, 414, 497, 251, 450, 25, 266, 108, 168, 97, 282, 452, 468, 298, 69, 81, 4, 263, 197, 395, 181, 277, 479, 491, 434, 400, 325, 54, 161, 421, 351, 348, 330, 16, 295, 5, 271, 188, 464, 458, 99, 105, 236, 221, 278, 80, 162, 246, 498, 440, 245, 494, 53, 418, 410, 377, 205, 17, 447, 118, 22, 96, 30, 225, 94, 299, 442, 300, 98, 372, 337, 462, 196, 455, 215, 36, 250, 256, 338, 496, 40, 62, 204, 429, 247, 38, 427, 444, 383, 255, 128, 177, 211, 165, 293, 120, 102, 156, 483, 86, 292, 375, 25, 251, 168, 434, 452, 414, 263, 97, 497, 81, 371, 491, 4, 181, 400, 69, 450, 479, 277, 197, 266, 108, 282, 271, 295, 395, 99, 298, 325, 330, 54, 161, 351, 5, 421, 468, 188, 440, 464, 458, 348, 205, 246, 162, 498, 195, 16, 494, 53, 105, 17, 281, 418, 425, 377, 410, 77, 265, 447, 23, 94, 98, 442, 337, 372, 462, 256, 250, 215, 36, 62, 247, 429, 40, 496, 165, 427, 338, 128, 86, 38, 383, 102, 483, 255, 177, 156, 375, 452, 293, 414, 298, 497, 371, 211, 450, 251, 120, 292, 266, 97, 444, 282, 108, 81, 468, 395, 168, 25, 69, 263, 325, 434, 421, 188, 479, 400, 348, 4, 464, 330, 181, 16, 498, 236, 277, 221, 278, 162, 246, 418, 53, 205, 410, 161, 491, 494, 295, 80, 54, 447, 245, 23, 351, 5, 440, 118, 105, 99, 22, 271, 216, 454, 191, 458, 281, 195, 101, 78, 112, 429, 211, 271, 462, 371, 295, 414, 483, 206, 464, 325, 375, 105, 22, 421, 263, 96, 221, 400, 216, 132, 146, 174, 251, 236, 245, 80, 281, 168, 191, 397, 468, 298, 278, 192, 440, 118, 265, 377, 17, 256, 357, 113, 348, 77, 247, 353, 128, 395, 330, 403, 93, 362, 436, 314, 12, 356, 479, 234, 318, 289, 95, 139, 296, 6, 284, 481, 87, 268, 122, 323, 409, 408, 63, 142, 499, 19, 446, 237, 441, 473, 48, 45, 0, 232, 136, 390, 228, 150, 65, 111, 276, 260, 58, 331, 405, 90, 344, 178, 461]
In [5]:
preds2 = exp.recommend(users=[1,2], exclude_known=False)
In [6]:
preds2
Out[6]:
user
item
rank
0
1
94
1
1
1
30
2
2
1
166
3
3
1
225
4
4
1
98
5
5
1
300
6
6
1
299
7
7
1
442
8
8
1
196
9
9
1
455
10
10
1
337
11
11
1
372
12
12
1
462
13
13
1
250
14
14
1
256
15
15
1
427
16
16
1
204
17
17
1
38
18
18
1
247
19
19
1
429
20
20
1
62
21
21
1
36
22
22
1
338
23
23
1
496
24
24
1
215
25
25
1
177
26
26
1
293
27
27
1
255
28
28
1
128
29
29
1
40
30
...
...
...
...
170
2
36
71
171
2
156
72
172
2
488
73
173
2
485
74
174
2
102
75
175
2
177
76
176
2
62
77
177
2
362
78
178
2
16
79
179
2
319
80
180
2
444
81
181
2
38
82
182
2
122
83
183
2
336
84
184
2
125
85
185
2
79
86
186
2
113
87
187
2
434
88
188
2
318
89
189
2
296
90
190
2
251
91
191
2
409
92
192
2
380
93
193
2
270
94
194
2
420
95
195
2
493
96
196
2
1
97
197
2
97
98
198
2
99
99
199
2
30
100
200 rows × 3 columns
In [7]:
len(exp.recommend(exclude_known=True)['item'])
Out[7]:
6431
In [8]:
(exp.recommend(exclude_known=True)['item'] == exp.recommend(exclude_known=False)['item']).value_counts()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-c269627c5c46> in <module>()
----> 1 (exp.recommend(exclude_known=True)['item'] == exp.recommend(exclude_known=False)['item']).value_counts()
/home/kd/anaconda3/envs/py3-proba2/lib/python3.5/site-packages/pandas/core/ops.py in wrapper(self, other, axis)
816 if not self._indexed_same(other):
817 msg = 'Can only compare identically-labeled Series objects'
--> 818 raise ValueError(msg)
819 return self._constructor(na_op(self.values, other.values),
820 index=self.index, name=name)
ValueError: Can only compare identically-labeled Series objects
In [9]:
preds.join(data.set_index(['user','item']), on=['user','item'], how='inner').groupby('user')['eval'].count().mean()
Out[9]:
nan
In [10]:
data
Out[10]:
time
user
item
id
score
eval
0
100
23
30
0
1
1
1
105
23
337
1
1
1
2
110
23
372
2
1
1
3
115
23
120
3
1
1
4
120
23
168
4
1
1
5
125
34
204
5
1
1
6
130
23
468
6
1
1
7
135
23
256
7
1
1
8
140
23
225
8
1
1
9
145
23
462
9
1
1
10
150
23
455
10
1
1
11
155
23
166
11
1
1
12
160
23
128
12
1
1
13
165
23
4
13
1
1
14
170
74
166
14
1
1
15
175
70
442
15
1
1
16
180
34
383
16
1
1
17
185
34
225
17
1
1
18
190
4
98
18
1
1
19
195
23
452
19
1
1
20
200
23
293
20
1
1
21
205
23
260
21
1
1
22
210
23
6
22
1
1
23
215
23
161
23
1
1
24
220
23
234
24
1
1
25
225
23
94
25
1
1
26
230
23
375
26
1
1
27
235
32
371
27
1
1
28
240
23
204
28
1
1
29
245
23
473
29
1
1
...
...
...
...
...
...
...
970
4950
99
108
970
1
1
971
4955
32
325
971
1
1
972
4960
55
120
972
1
1
973
4965
84
263
973
1
1
974
4970
71
496
974
1
1
975
4975
91
94
975
1
1
976
4980
39
205
976
1
1
977
4985
82
30
977
1
1
978
4990
99
177
978
1
1
979
4995
99
277
979
1
1
980
5000
38
62
980
1
1
981
5005
84
101
981
1
1
982
5010
51
166
982
1
1
983
5015
28
98
983
1
1
984
5020
17
204
984
1
1
985
5025
83
16
985
1
1
986
5030
23
22
986
1
1
987
5035
80
94
987
1
1
988
5040
8
196
988
1
1
989
5045
70
299
989
1
1
990
5050
52
30
990
1
1
991
5055
55
421
991
1
1
992
5060
34
395
992
1
1
993
5065
53
337
993
1
1
994
5070
38
128
994
1
1
995
5075
86
168
995
1
1
996
5080
40
383
996
1
1
997
5085
83
29
997
1
1
998
5090
73
234
998
1
1
999
5095
23
390
999
1
1
1000 rows × 6 columns
In [2]:
r=rs.FactorModelReader()
In [3]:
uif = r.read("model_save", 10)
In [6]:
users = []
user_factors = []
for f in uif.user_factors:
users.append(f.entity)
user_factors.append(f.factors)
items = []
item_factors = []
for f in uif.item_factors:
items.append(f.entity)
item_factors.append(f.factors)
In [13]:
user_df = pd.DataFrame.from_records(user_factors, columns=range(1,10+1))
user_df['user']=users
user_df.set_index('user',inplace=True)
item_df = pd.DataFrame.from_records(item_factors, columns=range(1,10+1))
item_df['item']=items
item_df.set_index('item',inplace=True)
In [15]:
item_df
Out[15]:
1
2
3
4
5
6
7
8
9
10
item
0
0.093610
0.092002
0.041882
0.109370
-0.103590
0.065632
-0.113365
0.089075
0.110280
0.071719
1
0.093194
0.096220
0.050682
0.096436
-0.101917
0.079697
-0.117589
0.086036
0.103890
0.073094
4
0.096395
-0.069351
0.051472
0.011227
-0.426102
-0.041697
0.027440
-0.113184
0.110873
0.242209
5
0.001814
0.182096
0.018791
0.111336
-0.190668
-0.003389
-0.008853
-0.109414
0.011959
0.353851
6
0.049667
0.072248
0.011327
0.111306
-0.134521
0.069018
-0.125834
0.001380
0.095448
0.143113
7
0.083668
0.101772
0.054034
0.096514
-0.100438
0.072806
-0.116940
0.077727
0.120039
0.069309
12
0.000646
0.066634
0.024443
0.037554
-0.121900
0.127679
-0.108263
0.108044
0.171281
0.107984
15
0.069869
0.080188
0.055549
0.074867
-0.094905
0.099009
-0.145672
0.051607
0.140944
0.083084
16
0.091338
0.076094
0.000022
0.233812
-0.113537
0.097707
-0.157931
-0.121617
-0.078356
0.227226
17
0.047451
0.140318
0.054805
0.084570
-0.204108
0.003819
-0.044212
-0.042416
0.071185
0.228679
19
0.087238
0.098669
0.049238
0.104640
-0.106915
0.067564
-0.109175
0.087966
0.111473
0.070341
22
0.033286
-0.000654
0.173198
0.199046
-0.163440
0.176472
-0.183354
0.031309
-0.011467
-0.088938
23
-0.070479
0.121597
0.007689
0.084306
0.055208
0.111745
0.186667
0.108758
-0.048888
-0.010410
25
0.275476
-0.230280
0.246899
0.171006
-0.302693
0.157869
0.102837
-0.059534
0.177327
-0.182102
27
0.089195
0.102056
0.051737
0.110445
-0.104089
0.057624
-0.112806
0.089226
0.109461
0.069108
29
0.034879
0.123365
0.014978
0.149393
-0.070228
0.094729
-0.110485
0.000390
0.052495
0.185034
30
-0.082610
-0.355950
0.079619
-0.125272
-0.301729
1.010372
0.659684
-0.248795
0.117434
0.470840
33
0.089734
0.091777
0.044150
0.106371
-0.102425
0.067708
-0.116865
0.089550
0.111210
0.074599
35
0.091726
0.099656
0.056138
0.104689
-0.096596
0.068928
-0.113558
0.079682
0.113759
0.071124
36
0.183615
-0.129582
-0.009280
-0.128634
-0.183836
0.469065
0.462965
-0.005706
0.368925
0.287368
38
0.276116
-0.368336
0.157953
0.153992
-0.371499
0.224039
0.017487
-0.384900
0.016909
0.092929
39
0.090349
0.103528
0.048020
0.094973
-0.098528
0.072933
-0.121648
0.078060
0.115203
0.067754
40
-0.112042
-0.174139
0.243724
0.045856
-0.349329
0.625671
0.296915
0.207385
0.151393
-0.188710
43
0.087703
0.093278
0.039341
0.112302
-0.100293
0.066290
-0.117577
0.084413
0.116441
0.068222
45
0.095434
0.105367
0.045715
0.097392
-0.109944
0.067066
-0.114442
0.080122
0.110405
0.065712
48
0.091624
0.089534
0.051559
0.100573
-0.099633
0.070256
-0.115347
0.085518
0.110642
0.077814
49
0.090011
0.100196
0.042176
0.098653
-0.108228
0.069636
-0.116852
0.089595
0.106815
0.070286
50
0.087062
0.094266
0.045454
0.110902
-0.102529
0.062854
-0.118697
0.088485
0.110456
0.069471
52
0.083253
0.092732
0.048615
0.102687
-0.096652
0.072535
-0.121874
0.086208
0.118302
0.069451
53
-0.074586
0.118195
-0.001786
0.083203
0.048812
0.129365
0.185033
0.105815
-0.051727
-0.015784
...
...
...
...
...
...
...
...
...
...
...
447
-0.052825
0.104558
0.001668
0.081088
0.031917
0.112720
0.180607
0.101982
-0.052730
-0.035403
450
0.090784
-0.265026
0.170762
0.231928
-0.360185
0.238125
-0.249570
-0.143541
-0.181566
-0.092046
452
-0.007944
0.246385
-0.017636
0.178871
0.077266
0.429073
0.134355
0.171917
-0.080726
0.236309
454
0.148199
0.066344
-0.000891
0.087365
-0.006468
0.152854
-0.131126
0.022376
0.135121
0.128504
455
0.387163
-0.300269
-0.063589
-0.038878
-0.166205
0.346559
0.114734
-0.580486
-0.028107
0.664999
458
-0.022409
0.180514
0.036770
0.121493
-0.194443
-0.012321
-0.038436
-0.107678
0.011381
0.347355
459
0.086537
0.096211
0.044022
0.102844
-0.106206
0.067682
-0.118965
0.086229
0.110985
0.070918
460
0.086176
0.094948
0.052502
0.095250
-0.100135
0.073225
-0.119682
0.090938
0.111673
0.073279
461
0.093453
0.094726
0.046016
0.103331
-0.103537
0.068196
-0.113851
0.093328
0.106020
0.074212
462
-0.009144
0.054628
-0.045455
0.133371
-0.022795
0.503285
0.589281
-0.242404
0.184664
0.660514
464
-0.049258
-0.047589
0.152541
0.128306
-0.202275
0.219671
-0.173160
0.040970
0.062192
-0.049357
468
0.050379
-0.046618
0.200173
0.328947
-0.141044
0.210893
-0.257204
-0.228634
-0.214693
0.032068
469
0.093028
0.090585
0.047421
0.103511
-0.098598
0.068574
-0.119860
0.092650
0.108269
0.075087
473
0.092326
0.092410
0.042547
0.098111
-0.104181
0.074588
-0.117710
0.086491
0.110729
0.072799
474
0.092048
0.102665
0.041481
0.093755
-0.109630
0.072784
-0.118755
0.085089
0.106730
0.066362
478
0.161115
-0.007041
0.056669
0.055352
-0.216935
0.026725
-0.082211
0.089330
0.118223
0.031433
479
-0.101068
0.135038
0.003041
0.065909
-0.237783
0.054288
-0.015715
-0.110666
0.077308
0.382122
481
0.081967
0.095540
0.047519
0.100817
-0.109685
0.070518
-0.114137
0.082708
0.116141
0.068827
483
0.128267
-0.120323
0.038312
0.144115
-0.002947
0.430070
-0.078708
-0.206197
0.144764
0.090938
484
0.096415
0.098917
0.033990
0.104391
-0.103143
0.069810
-0.116475
0.081806
0.110683
0.065098
485
0.093108
0.096958
0.048292
0.102181
-0.100979
0.070902
-0.116491
0.086250
0.109722
0.069234
486
0.093019
0.098077
0.045700
0.096967
-0.100765
0.072004
-0.120247
0.089644
0.107845
0.071343
488
0.071297
0.108856
0.035581
0.119352
-0.068418
0.126829
-0.065622
0.108527
0.092797
0.111446
491
0.344091
-0.144204
0.101617
0.063674
-0.259098
0.036117
0.181888
0.007086
0.328418
-0.022169
493
0.087989
0.098752
0.046831
0.099545
-0.102417
0.072610
-0.118356
0.089564
0.109259
0.068012
494
-0.073800
0.116293
-0.006515
0.075952
0.045490
0.127459
0.186307
0.096179
-0.034882
-0.023701
496
0.118371
-0.236318
0.261182
0.095095
-0.258123
0.527516
0.411485
0.099284
0.267055
-0.181755
497
-0.066977
0.128963
0.178262
0.289765
-0.047914
0.398260
0.032021
0.012872
-0.121691
0.032443
498
-0.052260
0.141821
0.001091
0.056393
0.055154
0.160654
0.187161
0.107494
-0.068163
-0.036949
499
0.083557
0.090731
0.040724
0.099736
-0.106194
0.078692
-0.121653
0.079857
0.116108
0.065122
260 rows × 10 columns
In [3]:
(u,i) = ag.readFactorModel('model_save', 10)
In [1]:
%matplotlib inline
import alpenglow as ag
import alpenglow.Getter as rs
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import alpenglow.experiments
import alpenglow.evaluation
In [2]:
factorModelExperiment = alpenglow.experiments.FactorModelExperiment(
top_k=100,
seed=254938879,
dimension=10,
learning_rate=0.1,
negative_rate=10
)
facRankings = factorModelExperiment.run(
"python/test_alpenglow/test_data_4",
experimentType="online_id",
verbose=True,
calculate_toplists=True
)
reading data...
data reading finished
logging predictions
running experiment...
In [3]:
data = pd.read_csv(
"python/test_alpenglow/test_data_4",
sep=' ',
header=None,
names=['time', 'user', 'item', 'id', 'score', 'eval']
)
In [4]:
preds = factorModelExperiment.get_predictions()
In [5]:
preds_joined = preds.join(data.reset_index().set_index(['index','item'])['score'], on=['record_id','item'], how="left")
In [12]:
preds_hits = (
preds_joined
.fillna(0)
.sort_values('score', ascending=False)
.drop_duplicates(subset=['record_id'])
.sort_values('record_id')
)
In [15]:
preds_hits.loc[preds_hits['score']==0, 'rank']=101
In [16]:
preds_hits
Out[16]:
record_id
time
user
item
rank
prediction
score
0
1
105
23
30
101
0.000151
0.0
2
2
110
23
337
101
0.000110
0.0
5
3
115
23
337
101
0.000111
0.0
9
4
120
23
120
101
-0.000059
0.0
14
5
125
34
30
101
0.000000
0.0
20
6
130
23
120
101
-0.000054
0.0
21
7
135
23
168
101
0.000328
0.0
34
8
140
23
204
101
0.000004
0.0
44
9
145
23
120
101
-0.000056
0.0
45
10
150
23
168
101
0.000331
0.0
65
11
155
23
120
101
-0.000042
0.0
66
12
160
23
168
101
0.000345
0.0
79
13
165
23
455
101
0.000254
0.0
101
14
170
74
166
11
0.000000
1.0
110
15
175
70
468
101
0.000000
0.0
133
16
180
34
372
101
-0.000149
0.0
142
17
185
34
225
9
-0.000005
1.0
156
18
190
4
256
101
0.000000
0.0
181
19
195
23
120
101
-0.000047
0.0
200
20
200
23
383
101
-0.000074
0.0
201
21
205
23
168
101
0.000370
0.0
226
22
210
23
256
101
0.000167
0.0
246
23
215
23
256
101
0.000182
0.0
268
24
220
23
30
101
0.000176
0.0
290
25
225
23
30
101
0.000174
0.0
329
26
230
23
94
101
-0.000269
0.0
335
27
235
32
468
101
0.000000
0.0
373
28
240
23
204
19
-0.000010
1.0
406
29
245
23
94
101
-0.000256
0.0
425
30
250
23
120
101
-0.000005
0.0
...
...
...
...
...
...
...
...
88809
970
4950
99
271
101
0.000448
0.0
88968
971
4955
32
140
101
0.000232
0.0
89069
972
4960
55
120
76
0.000149
1.0
89148
973
4965
84
351
101
0.000179
0.0
89216
974
4970
71
496
23
0.000364
1.0
89371
975
4975
91
90
101
0.000112
0.0
89481
976
4980
39
118
101
0.000160
0.0
89557
977
4985
82
30
64
0.000081
1.0
89686
978
4990
99
43
101
0.000177
0.0
89706
979
4995
99
337
101
0.000489
0.0
89865
980
5000
38
43
101
0.000096
0.0
89899
981
5005
84
94
101
0.000357
0.0
89996
982
5010
51
27
101
0.000239
0.0
90178
983
5015
28
263
101
0.000064
0.0
90223
984
5020
17
323
101
0.000089
0.0
90356
985
5025
83
488
101
0.000199
0.0
90402
986
5030
23
445
101
0.000542
0.0
90505
987
5035
80
94
12
0.000217
1.0
90624
988
5040
8
196
31
0.000000
1.0
90710
989
5045
70
299
17
0.000460
1.0
90806
990
5050
52
418
101
0.000190
0.0
90941
991
5055
55
236
101
0.000204
0.0
91076
992
5060
34
395
83
0.000139
1.0
91121
993
5065
53
353
101
0.000197
0.0
91286
994
5070
38
128
93
0.000076
1.0
91324
995
5075
86
168
31
0.000248
1.0
91411
996
5080
40
357
101
0.000105
0.0
91564
997
5085
83
29
71
0.000187
1.0
91661
998
5090
73
152
101
0.000164
0.0
91695
999
5095
23
344
101
0.000707
0.0
999 rows × 7 columns
In [ ]:
Content source: proto-n/Alpenglow
Similar notebooks: