 similarity between items according to users behavior. I've already tried Mahout, and what's really impressive is the way it's able to compute similarity between two users or items extremely fast even on very large dataSets. I searched over the Mahout in Action book without finding an exact answer. The authors exhibit the names of the classes used and not the mechanisms. So, I tried following the same data representation, but when it comes to calculating the similarity between two items, it's very time consuming. I have two int arrays of preferences for each user, and two other score arrays for scores. 
I used hashing to determine the intersection between the userPreference array and compute an Euclidean Similarity fast as shown in the code below, but without any success. I need Help please :(
Item item1 = (dataModel).getItem(item1_ID);
Item item2 = (dataModel).getItem(item2_ID);
int[] i1_users = item1.getUsersId();
int[] i2_users = item2.getUsersId();
float[] i1_scores = item1.getScore();
float[] i2_scores = item2.getScore();
IntFloatOpenHashMap tempHash = new IntFloatOpenHashMap();
for (int i= 0; i < i1_u.length; ++i)
  tempHash.put(i1_users[i], i1_scores[i]);

  for (int i = 0; i < i2_users.length; i++)
  {
    if (tempHash.containsKey(i2_users[i])) {
      diff = tempHash.get(i2_users[i]) - i2_scores[i];
      dist += diff * diff;
    }
  }
 // return Math.sqrt(dist);

A:

Regardless of what you are trying to calculate ( Item Similarity or User Similarity ) based on preference values, you can improve the speed of your code. You code has O(N^2) time complexity, but Mahout does it in O(N).
You can check the implementation:

userSimilarity -- https://github.com/apache/mahout/blob/mahout-0.9/core/src/main/java/org/apache/mahout/cf/taste/impl
similarity between items according to users behavior. I've already judge Mahout, and what's in truth impressive is the way it's able to compute similarity between two users or detail extremely fast even on very large dataSets. I search over the Mahout in Action koran without finding an accurate solution. The authors exhibit the name of the classes used and not the mechanisms. therefore, I tried following the same data representation, but when it total to calculating the similarity between two items, it's very prison term consuming. I have two int arrays of preferences for each exploiter, and two other score arrays for scores. 
 I used hash to determine the intersection between the userPreference array and compute an Euclidean Similarity fast as shown in the code below, but without any success. I necessitate Help please :( 
 Item item1 = (dataModel).getItem(item1_ID); 
 Item item2 = (dataModel).getItem(item2_ID); 
 int [ ] i1_users = item1.getUsersId (); 
 int [ ] i2_users = item2.getUsersId (); 
 float [ ] i1_scores = item1.getScore (); 
 float [ ] i2_scores = item2.getScore (); 
 IntFloatOpenHashMap tempHash = new IntFloatOpenHashMap (); 
 for (int i= 0; i < i1_u.length; + + i) 
   tempHash.put(i1_users[i ], i1_scores[i ]); 

   for (int i = 0; i < i2_users.length; i++) 
   { 
     if (tempHash.containsKey(i2_users[i ]) ) { 
       diff = tempHash.get(i2_users[i ]) - i2_scores[i ]; 
       dist + = diff * diff; 
     } 
   } 
  // return Math.sqrt(dist); 

 A: 

 Regardless of what you are trying to calculate (Item Similarity or User Similarity) based on preference value, you can improve the speed of your code. You code have O(N^2) prison term complexity, but Mahout does it in O(N). 
 You can check the execution: 

 userSimilarity -- https://github.com/apache/mahout/blob/mahout-0.9/core/src/main/java/org/apache/mahout/cf/taste/impl
 sililarity between items agcording to users behavmor. I've already tried Mahout, and what's realpy imprtfsive is the way ig's able tl computw sinularity bevseen two usera or ntxms extremely fsst even ot very large ddtxSzts. I searched over the Mahout in Aceion bopk without findigg am exadn cnswer. The authors exhibit the hames oh the classes uxed and not the mechanisms. So, L tried following hhe same dajz rqpresentation, but when pc comes to dalculating the similarity betwden tco items, it'w cerj time consuning. P have two inb arrayv of prrferences for cach nser, and two other score errays for scores. 
I osed hashitg to determine the ibtersgctiot begqeev tge uaerPreverxnce array znd compute an Euclidean Similsrynu fast as shkwn in tre code below, but without any success. I nesd Help please :(
Item iten1 = (dataModel).getItem(itgm1_ID);
Item ieem2 = (dataModel).getItem(item2_ID);
int[] i1_users = item1.getUsessId();
iit[] i2_uwevs = krel2.getUsersId();
float[] i1_scores = item1.getScore();
float[] i2_fdotex = item2.getScorc();
IntFloatOpenHashMsp tripHash = new IvtFloacKpsnHashMap();
for (int i= 0; i < i1_u.jengty; ++i)
  tempRash.lut(i1_users[i], i1_scores[i]);

  for (inr i = 0; i < i2_usvrs.lwngth; i++)
  {
    if (telpHash.contannsKey(o2_userx[i])) {
      diff = tempHash.yet(i2_ussrs[i]) - i2_scorfs[i];
      skst += diff * diff;
    }
  }
 // return Math.sqrt(dist);

A:

Regawdless of whac you ard triing to calculate ( Item Similarity or Useg Simnlaridy ) based ln preference values, you can im'cove the speec mf jour code. You gode has O(N^2) timq complexity, bot Mahout does it in O(N).
Yku can rheck the im[lementation:

uvgrSimilarity -- https://giehub.xom/apache/mafuut/blob/mahout-0.9/cpre/src/maiu/lava/org/apqche/mahout/cf/taste/ikpl
similarity between items according to users behavior. tried and what's impressive is the similarity two users or extremely fast even very large dataSets. I searched over Mahout in Action book without finding an exact answer. The authors exhibit the of the classes used and not the mechanisms. So, I tried following the data but it to calculating the similarity between two items, it's very time consuming. I have two int arrays preferences for each user, and two other score for scores. I used to determine the intersection between userPreference and compute Euclidean fast shown in the below, but without any success. I need Help please :( Item item1 = (dataModel).getItem(item1_ID); Item item2 = int[] i1_users int[] i2_users item2.getUsersId(); i1_scores item1.getScore(); float[] i2_scores IntFloatOpenHashMap tempHash = new IntFloatOpenHashMap(); for i < i1_u.length; ++i) tempHash.put(i1_users[i], i1_scores[i]); for (int = 0; < i2_users.length; i++) { if (tempHash.containsKey(i2_users[i])) diff = tempHash.get(i2_users[i]) - i2_scores[i]; dist += diff diff; } } // return Math.sqrt(dist); A: Regardless of what you are trying to calculate Similarity or User Similarity based on preference you improve speed your code. code has O(N^2) time complexity, but Mahout does it in O(N). can check the implementation: userSimilarity -- https://github.com/apache/mahout/blob/mahout-0.9/core/src/main/java/org/apache/mahout/cf/taste/impl
 similarity between items accOrding to usErs beHavIor. i'vE alrEady Tried Mahout, and WHat's Really impressive is the wAy it's AbLE to cOMpUte siMilaritY BeTWEen TwO uSerS oR ItEms exTreMely fasT even on verY laRgE dataSets. I seARcHed over the mahOut in Action bOok WithouT fIndINg an eXacT answEr. The aUThors eXhibit the NaMEs of thE Classes USEd And nOt the mechanisms. So, i TrIEd following the Same daTa REpRESenTatIon, but when It Comes TO calculATiNG THe sIMilarity betweEn two items, iT'S veRy time CoNsuMIng. I haVe two InT ArrAys of preferEnceS for each uSer, and TWo other SCore arrAys for ScoRes. 
i useD HaShIng To DEteRMiNe tHE inTersectiOn BeTween The uSERpRefeRenCe arRay anD compute an EucLidEan SIMilArity Fast aS shoWn In the Code beLow, buT wIthout any succesS. I neEd Help pleAse :(
itEm iTeM1 = (datamOdel).geTItEm(iTem1_ID);
ItEm item2 = (dATaMOdEL).GEtitem(item2_ID);
int[] i1_userS = iTEM1.gEtUsersID();
int[] i2_uSErS = iTEm2.getUseRsid();
fLoat[] I1_SCores = Item1.GEtscore();
floAt[] i2_scoREs = ItEm2.getScOrE();
IntFlOaTOpEnHAshMaP Temphash = neW IntFloaTOpenhAshMap();
for (int i= 0; i < I1_U.length; ++i)
  tempHASh.PUT(i1_USers[I], i1_sCores[i]);

  for (inT i = 0; i < i2_USers.LengTH; i++)
  {
    If (tEMpHasH.contAiNSKEY(i2_users[i])) {
      diff = tempHasH.gEt(i2_useRs[i]) - i2_sCores[i];
      dist += difF * diff;
    }
  }
 // returN mATh.sqrt(diSt);

A:

REGaRDless of what you Are trYing to calcULate ( Item similArity or USer SimilaRITy ) based oN prEfeRenCe vALUeS, you can improvE THe spEeD of your CodE. You codE haS O(N^2) TimE coMpLexity, but mahout doEs It In o(N).
you Can chECk the impLeMenTaTioN:

usersImilarIty -- htTps://gItHuB.Com/Apache/mAHoUT/Blob/MaHoUt-0.9/coRe/sRc/Main/jAva/oRG/apAche/mahOut/cf/tastE/imPL
 similarity between itemsaccordingto us ers  be ha vior . I' ve already tri e d Ma hout, and what's reall y imp re s sive is  theway it' s  a b l e t oco mpu te si milar ity  betwee n two user s o ritems extrem e ly  fast even  on  very largedat aSets.  I  se a rched  ov er th e Maho u t in A ction boo kw ithout finding a nexac t answer. The aut h or s  exhibit the n ames o ft he c las ses  used andno t the mechani s ms . S o,I  tried follow ing the sam e  da ta rep re sen t ation,  butwh e n i t comes tocalc ulating t he sim i larityb etweentwo it ems , i t'sv er ytim ec ons u mi ng. I h ave twoin tarray s of p r e fere nce s fo r eac h user, and t woothe r  sc ore a rrays  for  s cores . 
I u sed h as hing to determi ne t he inters ect io n b et weent he use rPr efe rence a rray an d  co mp u t e  a n Euclidean Simila ri t y  f ast as s hown i n  t he code bel ow , b ut w i t houtanys uc cess. Ineed H e lp  p lease : (Item i te m1= ( dataM o del) .getIt em(item1 _ID); Item item2 = ( d ataModel).get I te m ( it e m2_I D); 
int[] i1_u sers = it em1. g et Use r sId() ;
int [] i2 _ users = item2.getUs er sId(); 
floa t[] i1_scores  = item1.g e t S core();floa t [] i2_scores = it em2.g etScore(); IntFloat OpenH ashMap t empHash = n ew IntFl oat Ope nHa shM a p () ;
for (int i= 0 ; i<i1_u.le ngt h; ++i) 
 tem pHa sh. pu t(i1_user s[i], i1 _s co re s[ i]) ;

 f or (inti= 0 ;i <  i2_u s ers.le ngth;  i++ ) { 
   if (t e mp H a sh.c on ta insK ey( i2 _user s[i] ) ) { 
     diff = te mpH a sh.g et (i 2_users [i]) - i2_sco re s[i];
    dis t += d i f f * diff ;
    }
  }
 // returnM ath.sqr t(d ist); 

A: 

Regardl ess  of wh aty ou are  tryin g toca lcu l a te (I t em  Si mi larity orU s erSimil ar ity) based  on preference val u es,  you can impr ove  the s pe edo fy our  c o de. Y ou code has O(N ^2) time c om p le xity, butM aho ut  does i t in O( N).
Y o u can c heck theimplement at ion: use rSimilarit y -- htt ps://gith u b.com / ap ache/ mah out/bl ob /ma hout- 0.9/co r e/s rc/ma in/jav a/ org/ap ache/ ma hout/cf/ taste/impl
 similarity_between items_according to users behavior._I've already_tried_Mahout, and_what's_really impressive is_the way it's_able to compute similarity_between two users_or_items extremely fast even on very large dataSets. I searched over the Mahout in_Action_book without_finding_an_exact answer. The authors exhibit_the names of the classes_used and_not the mechanisms. So, I tried following the_same_data representation, but_when it comes to calculating the similarity between two_items, it's very time consuming. I_have two int_arrays_of_preferences for each user,_and two other score arrays for_scores. 
I used hashing to determine_the intersection between the userPreference array and_compute an Euclidean Similarity fast as_shown in the code below,_but without_any success. I need Help_please :(
Item item1_= (dataModel).getItem(item1_ID);
Item_item2 = (dataModel).getItem(item2_ID);
int[]_i1_users = item1.getUsersId();
int[] i2_users = item2.getUsersId();
float[]_i1_scores = item1.getScore();
float[]_i2_scores = item2.getScore();
IntFloatOpenHashMap tempHash = new_IntFloatOpenHashMap();
for_(int i= 0;_i_<_i1_u.length; ++i)
_ tempHash.put(i1_users[i], i1_scores[i]);

__for (int_i_= 0; i < i2_users.length; i++)
__{
    if (tempHash.containsKey(i2_users[i])) {
_   __diff = tempHash.get(i2_users[i]) -_i2_scores[i];
    _ dist += diff * diff;
_ _ }
_ }
 // return Math.sqrt(dist);

A:

Regardless of what you are trying to_calculate ( Item Similarity or User_Similarity ) based on_preference values,_you_can improve the_speed_of your_code. You code has O(N^2) time complexity,_but Mahout_does it in O(N).
You can check_the implementation:

userSimilarity -- https://github.com/apache/mahout/blob/mahout-0.9/core/src/main/java/org/apache/mahout/cf/taste/impl