Exemplo n.º 1
0
 public RecommendationEngine()
 {
     categories  = CheckinOperations.getCategorie();
     places      = CheckinOperations.getPlaces();
     pCategories = CheckinOperations.getPlaceCategories();
     aEng        = new AnalyzeEngine();
 }
 public AnalyzeEngine(bool tf)
 {
     categoryPoints = new ConcurrentDictionary <string, double>();
     this.Categorie = CheckinOperations.getCategorie();
     pCategories    = CheckinOperations.getPlaceCategories();
     likeCategories = CheckinOperations.listLikeCategories();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Thresholds
        /// </summary>
        /// <param name="Popularity"></param>
        /// <param name="CategoryQuality"></param>
        public Engine(double Popularity, double CategoryQuality)
        {
            PopularityThreshold      = Popularity;
            CategoryQualityThreshold = CategoryQuality;

            places          = CheckinOperations.getPlaces().ToList();
            placeCategories = CheckinOperations.getPlaceCategories();
            CATEGORIES      = CheckinOperations.getCategorie();
            UserCheckins    = CheckinOperations.listCheckIns();
            checkinUser     = CheckinOperations.listCheckInsReturnedUser();
        }
Exemplo n.º 4
0
        private Dictionary <string, int> getDefaultData()
        {
            Dictionary <string, int> data = new Dictionary <string, int>();

            var categories = CheckinOperations.getCategorie();

            foreach (var cat in categories)
            {
                data.Add(cat.NAME, 0);
            }
            return(data);
        }
Exemplo n.º 5
0
        public string GenerateData(string arff)
        {
            string data = "@data\n";

            var             userList = CheckinOperations.getUsers();
            List <ArffData> datas    = new List <ArffData>();

            foreach (var user in userList)
            {
                ArffData d = new ArffData();
                d.Name      = user.USERNAME;
                d.Categorie = getDefaultData();
                var checkins = CheckinOperations.getCheckIns(user.USERID);
                foreach (var checkin in checkins)
                {
                    var categories = CheckinOperations.getPlaceCategories(checkin.PLACEID.Value);
                    foreach (var catPlace in categories)
                    {
                        var cat = CheckinOperations.getCategory(catPlace.CATEGORIEID.Value);
                        d.Categorie[cat.NAME] += 1;
                    }
                }
                d.CheckinCount = checkins.Count;
                datas.Add(d);
            }
            foreach (var d in datas)
            {
                string row = string.Empty;

                row += d.Name + ",";
                foreach (var cat in d.Categorie)
                {
                    if (cat.Value == 0)
                    {
                        row += cat.Value.ToString().Replace(",", ".") + ",";
                    }
                    else
                    {
                        float result = ((float)cat.Value) / (float)d.CheckinCount;
                        row += result.ToString().Replace(",", ".") + ",";
                    }
                }

                row   = row.Substring(0, row.Length - 1);
                data += row + "\n";
            }
            arff = arff.Replace("@DATA", data + "\n\n");
            return(arff);
        }
        public void _Load()
        {
            categoryPoints = new ConcurrentDictionary <string, double>();
            this.Categorie = CheckinOperations.getCategorie();

            Engine eng = new Engine(popularityThreshold, CategoryQualityThreshold);

            List <string> list_lines = new List <string>();

            Parallel.ForEach(Categorie, (cat) =>
            {
                var catPoint = eng.getCategoryPoint(cat.CATEGORIEID);
                categoryPoints.AddOrUpdate(cat.NAME, catPoint, (key, oldvalue) => oldvalue + catPoint);
            });
            pCategories    = CheckinOperations.getPlaceCategories();
            likeCategories = CheckinOperations.listLikeCategories();
            //var catPoint = eng.getCategoryPoint(896);
            //categoryPoints.AddOrUpdate("Amphitheater", catPoint, (key, oldvalue) => oldvalue + catPoint);
        }
Exemplo n.º 7
0
        public string GenerateAttibutes(string arff)
        {
            var    categories = CheckinOperations.getCategorie();
            string attributes = string.Empty;

            attributes += "@ATTRIBUTE Name string\n";
            foreach (var cat in categories)
            {
                string name = cat.NAME;
                foreach (var item in replaceChar)
                {
                    name = name.Replace(item, "");
                }
                attributes += "@ATTRIBUTE " + name.Replace(" ", "_") + " numeric\n";
            }

            arff = arff.Replace("@ATTRIBUTE", attributes + "\n\n");

            return(arff);
        }
Exemplo n.º 8
0
        private List <FenomenResult> getSimilarUsers(Dictionary <string, double> CategoryProfile)
        {
            //Fenomen Profilleri oluşturuluyor..
            var FenomenProfiles = CheckinOperations.listCategoryProfile();
            List <Dictionary <string, double> > fProfiles = new List <Dictionary <string, double> >();

            string[] splitChars1 = { "#" };
            string[] splitChars2 = { ":" };
            foreach (var profile in FenomenProfiles)
            {
                Dictionary <string, double> profil = new Dictionary <string, double>();
                var features = profile.FEATURES.Split(splitChars1, StringSplitOptions.RemoveEmptyEntries);
                foreach (var f in features)
                {
                    string[] feat  = f.Split(splitChars2, StringSplitOptions.RemoveEmptyEntries);
                    string   name  = feat[0];
                    string   value = feat[1];
                    profil.Add(name, Convert.ToDouble(value));
                }
                fProfiles.Add(profil);
            }
            var result     = new List <FenomenResult>();
            var userVector = aEng.VectorToList(CategoryProfile);

            for (int i = 0; i < fProfiles.Count; i++)
            {
                var fenomenVector = aEng.VectorToList(fProfiles[i]);
                var r             = CosineSimilarity.GetCosineSimilarity(userVector, fenomenVector);
                result.Add(new FenomenResult()
                {
                    fenomenProfile   = fProfiles[i],
                    SimilarityResult = r
                });
            }

            result.Sort((emp1, emp2) => emp1.SimilarityResult.CompareTo(emp2.SimilarityResult));

            return(result);
        }