public List <Recommendation_Meta_Item> getListRecommendation_R1_TraditionalUsers(Predict_DAO_MCol a, int nbR1) { //Predict_DAO_MC a = new Predict_DAO_MC(); List <Recommendation_Meta_Item> list = new List <Recommendation_Meta_Item>(); List <Recommendation_Meta_Item> RC = new List <Recommendation_Meta_Item>(); List <string> lstCluster = new List <string>(); List <string> User_OfCluster = new List <string>(); //Settings r = GetRecommendationSeting(a); lstCluster = a.GetListClusterID(); //Check number of recommendations if (nbR1 <= 0) { nbR1 = 1; } //int i = 0; foreach (string cluster in lstCluster) { User_OfCluster = a.GetListUser_OfCluster(cluster); foreach (string u in User_OfCluster) { RC = a.GetRecommendC6_ForTraditionalUser(u, nbR1);//2 list.AddRange(RC); } } return(list); }
//public List<Recommendation_Meta_Item> GetListRecommendC6_ForTraditionalUser() //{ // Predict_DAO_MC a = new Predict_DAO_MC(); // List<Recommendation_Meta_Item> list = new List<Recommendation_Meta_Item>(); // List<Recommendation_Meta_Item> RC = new List<Recommendation_Meta_Item>(); // try // { // a.beginTransaction(); // List<User> list_users_tra = a.getTraditionalUser_UnBlocked(); // foreach (User u in list_users_tra) // { // RC = a.GetRecommendC6_ForTraditionalUser(u, 1); // list.AddRange(RC); // } // a.commitTransaction(); // return list; // } // catch (Exception ex) // { // a.rollbackTransaction(); // throw ex; // } //} //---------------------------------------------------------------------------------------------- //This function calls GetRecommendC6_ForTraditionalUser from Predict_DAO_MC to give R1 //Created by MC. NGUYEN //Corrected by MC. NGUYEN, 22.10.2014 //Changed: 24.10.2014: the formule to calculate SCORE for each Meta Produit (based on Count(*)). //---------------------------------------------------------------------------------------------- public List <Recommendation_Meta_Item> getListRecommendation_R1_TraditionalUsers(Predict_DAO_MCol a) { List <Recommendation_Meta_Item> list1 = new List <Recommendation_Meta_Item>(); List <Recommendation_Meta_Item> list2 = new List <Recommendation_Meta_Item>(); List <string> list3 = new List <string>(); List <string> list4 = new List <string>(); foreach (string cluster in a.GetListClusterID()) { foreach (string u in a.GetListUser_OfCluster(cluster)) { List <Recommendation_Meta_Item> forTraditionalUser = a.GetRecommendC6_ForTraditionalUser(u, 2); list1.AddRange((IEnumerable <Recommendation_Meta_Item>)forTraditionalUser); } } return(list1); }
//have formular here public List <Recommendation_Meta_Item> GetRecommendationR3(Predict_DAO_MCol a) { List <Recommendation_Meta_Item> list1 = new List <Recommendation_Meta_Item>(); Recommendation_Meta_Item recommendationMetaItem1 = new Recommendation_Meta_Item(); List <CONF> list2 = new List <CONF>(); List <DIST> list3 = new List <DIST>(); List <string> list4 = new List <string>(); List <string> list5 = new List <string>(); List <string> list6 = new List <string>(); List <U_I_Q> list7 = new List <U_I_Q>(); foreach (string cluster in a.GetListClusterID()) { List <CONF> confOfCluster = a.GetCONF_OfCluster(cluster); List <DIST> distOfCluster = a.GetDIST_OfCluster(cluster); List <string> listUserOfCluster = a.GetListUser_OfCluster(cluster); List <U_I_Q> traditionalUsersMore = a.GetQuantityTraditionalUsers_More(cluster); foreach (string user in listUserOfCluster) { List <string> notPurchasedOfUser = a.GetListMetaItemNotPurchased_OfUser(user, cluster); List <string> listMetaItemOfUser = a.GetListMetaItem_OfUser(user); string str = ""; double num1 = 0.0; for (int index1 = 0; index1 < notPurchasedOfUser.Count; ++index1) { double num2 = 0.0; double num3 = 0.0; double num4 = 1.0; for (int index2 = 0; index2 < listMetaItemOfUser.Count; ++index2) { for (int index3 = 0; index3 < confOfCluster.Count; ++index3) { if (confOfCluster[index3].MetaItemSource.Equals(listMetaItemOfUser[index2]) && confOfCluster[index3].MetaItemDestination.Equals(notPurchasedOfUser[index1])) { num3 = confOfCluster[index3].Confident; break; } } for (int index3 = 0; index3 < distOfCluster.Count; ++index3) { if (distOfCluster[index3].MetaItemDestination.Equals(listMetaItemOfUser[index2]) && distOfCluster[index3].MetaItemDestination.Equals(notPurchasedOfUser[index1])) { num4 = distOfCluster[index3].Distance; break; } } if (num4 != 0.0) { num2 += num3 / num4; } } if (num1 < num2 / (double)listMetaItemOfUser.Count) { num1 = num2; str = notPurchasedOfUser[index1]; } } if (num1 != 0.0) { Recommendation_Meta_Item recommendationMetaItem2 = new Recommendation_Meta_Item(); recommendationMetaItem2.UserID = user; recommendationMetaItem2.MetaItemID = str; recommendationMetaItem2.RecommendType = ConstantValues.RC_TYPE_LRS03; recommendationMetaItem2.Quantity = 0.0; for (int index = 0; index < traditionalUsersMore.Count; ++index) { if (traditionalUsersMore[index].MetaItemID.Equals(str)) { recommendationMetaItem2.Quantity = traditionalUsersMore[index].QTY; break; } } recommendationMetaItem2.Score = num1; list1.Add(recommendationMetaItem2); } } } return(list1); }