Beispiel #1
0
        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);
        }
Beispiel #2
0
        //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);
        }
Beispiel #3
0
        public List <Recommendation_Meta_Item> GetRecommendationR4(Predict_DAO_MCol a, double param)
        {
            List <Recommendation_Meta_Item> list1 = new List <Recommendation_Meta_Item>();
            List <string> list2 = new List <string>();
            List <string> list3 = new List <string>();
            List <string> list4 = new List <string>();
            Dictionary <string, double> dictionary1 = new Dictionary <string, double>();
            Dictionary <string, double> dictionary2 = new Dictionary <string, double>();
            Dictionary <string, double> dictionary3 = new Dictionary <string, double>();
            Dictionary <string, double> dictionary4 = new Dictionary <string, double>();
            Dictionary <string, string> dictionary5 = new Dictionary <string, string>();
            List <string> listClusterId             = a.GetListClusterID();
            Dictionary <string, string> listNewItem = a.GetListNewItem();

            foreach (string cluster in listClusterId)
            {
                try
                {
                    Dictionary <string, double> listRateU = a.GetListRateU(cluster);
                    Dictionary <string, double> listRateF = a.GetListRateF(cluster);
                    foreach (KeyValuePair <string, double> keyValuePair1 in listRateU)
                    {
                        Dictionary <string, double> listRateUf = a.GetListRateUF(keyValuePair1.Key);
                        double        num1        = 0.0;
                        string        FamillyCode = "Not found";
                        List <string> list5       = new List <string>();
                        List <double> list6       = new List <double>();
                        foreach (KeyValuePair <string, double> keyValuePair2 in listRateF)
                        {
                            double num2;
                            if (listRateUf.ContainsKey(keyValuePair2.Key))
                            {
                                double num3 = keyValuePair2.Value;
                                double num4 = keyValuePair1.Value;
                                double num5 = keyValuePair2.Value;
                                num2 = param * num5 * (1.0 / num4 - 1.0 / num3);
                            }
                            else
                            {
                                num2 = 0.0;
                            }
                            if (num2 > num1)
                            {
                                num1        = num2;
                                FamillyCode = keyValuePair2.Key;
                            }
                        }
                        if (num1 != 0.0)
                        {
                            double num2 = (double)a.getQTYR4(keyValuePair1.Key, FamillyCode, 1);
                            foreach (KeyValuePair <string, string> keyValuePair2 in listNewItem)
                            {
                                if (keyValuePair2.Value.Equals(FamillyCode))
                                {
                                    list1.Add(new Recommendation_Meta_Item()
                                    {
                                        UserID        = keyValuePair1.Key,
                                        RecommendType = ConstantValues.RC_TYPE_LRS04,
                                        MetaItemID    = keyValuePair2.Key,
                                        Quantity      = num2,
                                        Score         = num1
                                    });
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return(list1);
        }
Beispiel #4
0
        //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);
        }