Ejemplo n.º 1
0
        private void analysisDataset()
        {
            Print("_______________________");
            Print("Analyzing Dataset . . .");
            Print();



            int  sessionCount   = 0;
            long totalSpentTime = 0;
            long totalPageHits  = 0;
            Dictionary <string, Pair <long> > pages = new Dictionary <string, Pair <long> >();

            Dictionary <string, int> countrycode = new Dictionary <string, int>();
            Dictionary <string, int> browser     = new Dictionary <string, int>();
            Dictionary <string, int> OS          = new Dictionary <string, int>();


            Dictionary <string, int> gender = new Dictionary <string, int>
            {
                { true.ToString(), 0 },
                { false.ToString(), 0 },
                { "unkowen", 0 }
            };

            Session tmpS;

            foreach (User u in extractedUsers)
            {
                if (u.Gender == null)
                {
                    gender["unkowen"]++;
                }
                else
                {
                    gender[u.Gender.ToString()]++;
                }
                if (u.Sessions != null && u.Sessions.Count > 0)
                {
                    tmpS = u.Sessions[0];

                    searchInDic(countrycode, tmpS.CountryCode);
                    searchInDic(browser, tmpS.Browser);
                    searchInDic(OS, tmpS.OperatingSystem);

                    sessionCount   += u.Sessions.Count;
                    totalSpentTime += (long)u.Sessions.Sum(x => x.Duration.TotalSeconds);
                    foreach (var s in u.Sessions)
                    {
                        //sessionCount++;
                        //totalSpentTime += (long) s.Duration.TotalSeconds;

                        foreach (var r in s.Requests)
                        {
                            totalPageHits++;
                            if (pages.ContainsKey(r.RequstedPage) == false)
                            {
                                pages.Add(r.RequstedPage, new Pair <long>(0, 0));
                            }

                            pages[r.RequstedPage].Weight++;
                            pages[r.RequstedPage].Value += r.SpentTime;
                        }
                    }
                }
            }

            Series genderChart = new Series()
            {
                ChartType = SeriesChartType.Pie, IsValueShownAsLabel = true
            };
            Series countryChart = new Series()
            {
                ChartType = SeriesChartType.Pie, IsValueShownAsLabel = true
            };
            Series browsersChart = new Series()
            {
                ChartType = SeriesChartType.Pie, IsValueShownAsLabel = true
            };
            Series osChart = new Series()
            {
                ChartType = SeriesChartType.Pie, IsValueShownAsLabel = true
            };

            Series pagesChart = new Series()
            {
                ChartType = SeriesChartType.Column, Color = System.Drawing.Color.SeaGreen, Name = "Page Hits"
            };
            Series pagesChart2 = new Series()
            {
                ChartType = SeriesChartType.Column, Color = System.Drawing.Color.Tomato, Name = "Spent Time"
            };

            Print("Countries:");
            foreach (var c in countrycode)
            {
                countryChart.Points.AddXY(c.Key, (int)(c.Value * 100.0 / extractedUsers.Count));
                Print("\t" + c.Key + " = " + c.Value + " users (" + (int)(c.Value * 100.0 / extractedUsers.Count) + " %)");
            }

            Print();
            Print("Browsers:");
            foreach (var c in browser)
            {
                browsersChart.Points.AddXY(c.Key, (int)(c.Value * 100.0 / extractedUsers.Count));
                Print("\t" + c.Key + " = " + c.Value + " users (" + (int)(c.Value * 100.0 / extractedUsers.Count) + " %)");
            }

            Print();
            Print("OperatingSystems:");
            foreach (var c in OS)
            {
                osChart.Points.AddXY(c.Key, (int)(c.Value * 100.0 / extractedUsers.Count));
                Print("\t" + c.Key + " = " + c.Value + " users (" + (int)(c.Value * 100.0 / extractedUsers.Count) + " %)");
            }

            Print();
            Print("Gender:");
            foreach (var c in gender)
            {
                genderChart.Points.AddXY(getGender(c.Key), (int)(c.Value * 100.0 / extractedUsers.Count));
                Print("\t" + getGender(c.Key) + " = " + c.Value + " users (" + (int)(c.Value * 100.0 / extractedUsers.Count) + " %)");
            }

            Print();
            Print("Pages:");
            var orderPages = pages.OrderByDescending(x => ranking(totalSpentTime, totalPageHits, x));

            foreach (var c in orderPages)
            {
                Print(c.Key + "\t\t\t- hits = " + c.Value.Weight.ToString("N0") + " (" + (int)(c.Value.Weight * 100.0 / totalPageHits) +
                      " %) ,\tspentTime = " + c.Value.Value.ToString("N0") + " (" + (int)(c.Value.Value * 100.0 / totalSpentTime) + " %)" +
                      "\tRank = " + ranking(totalSpentTime, totalPageHits, c) + " points");

                pagesChart.Points.AddXY(fixName(c.Key), (int)(c.Value.Weight * 100.0 / totalPageHits));
                pagesChart2.Points.AddXY(fixName(c.Key), (int)(c.Value.Value * 100.0 / totalSpentTime));
            }

            Print("---------------------");

            Print();
            Print("Total Spent time\t= " + totalSpentTime.ToString("N0") + " sec");
            Print("Total Pages Hits\t= " + totalPageHits.ToString("N0") + " hits");
            Print("Total Session count\t= " + sessionCount.ToString("N0") + " session");

            Print("Unique Visitors\t= " + extractedUsers.Count.ToString("N0") + " visitors");

            Print("Avarage Spent time = " + (totalSpentTime / extractedUsers.Count).ToString("N0") + "  sec/visitor");
            Print("Avarage Pages Hits = " + (totalPageHits / extractedUsers.Count).ToString("N0") + "  hits/visitor");

            Print("Avarage Session count\t= " + (sessionCount * 1.0 / extractedUsers.Count));


            Print("---------------------");
            chartForm = new ChartForm().SetChart(countryChart, browsersChart, osChart, genderChart, pagesChart, pagesChart2);



            Print();
            Print("orginal Topology:");
            Graph graphOrginal = new Graph();

            foreach (var p in buildOrginalTopology(graphOrginal))
            {
                Print(p);
            }


            Print();
            Graph         suggestedOrginal         = new Graph();
            List <string> suggestedWebsiteTopology = new List <string>(new string[] { "NEW HOME" });

            suggestedWebsiteTopology.AddRange(buildSuggestedTopology(suggestedOrginal, "NEW HOME", orderPages.Select(x => x.Key), 3, "", int.Parse(txtboxLevelOfProposedNewTopology.Text)));
            Print("Suggested Topology:");
            foreach (var p in suggestedWebsiteTopology)
            {
                Print(p);
            }

            graphForm = new GraphForm().AddGraphs(suggestedOrginal, graphOrginal);

            //MinMax m = new MinMax(); int count = 0, totalcount = (extractedUsers.Count * (extractedUsers.Count + 1) / 2); double tmp = 0, ava = 0; for (int i = 0; i < extractedUsers.Count; i++) { for (int j = extractedUsers.Count - 1; j > i; j--) { m.SetMinMaxValues(tmp = extractedUsers[i].Distance(extractedUsers[j])); ava += tmp; count++; } Processbarhandler((int)((count * 1.0) / totalcount * 100), " wait "); } Print("min   = " + m.MinWeight); Print("max   = " + m.MaxWeight); Print("sum   = " + ava); Print("avarg = " + (ava / totalcount));
        }
Ejemplo n.º 2
0
        public ChartForm CloneMe()
        {
            var t = new ChartForm().SetChart(c, b, o, g, p, p2);

            return(t);
        }