public int CompareTo(object obj)
        {
            var featInteraction = obj as FeatureInteraction;

            return(FIScoreComparer.Compare(this, featInteraction));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("********************************");
            Console.WriteLine("* XGBOOST Feature Interactions *");
            Console.WriteLine("********************************");
            Console.ResetColor();

            ParseArgs(args);
            FIScoreComparer.SetComparer(GlobalSettings.SortBy);

            Console.WriteLine("");

            Console.WriteLine("Settings:");
            Console.WriteLine("=========");
            Console.WriteLine(String.Format("XgbModelFile: {0}", GlobalSettings.XgbModelFile));
            Console.WriteLine(String.Format("OutputXlsxFile: {0}", GlobalSettings.OutputXlsxFile));
            Console.WriteLine(String.Format("MaxInteractionDepth: {0}", GlobalSettings.MaxInteractionDepth));
            Console.WriteLine(String.Format("MaxDeepening: {0}", GlobalSettings.MaxDeepening));
            Console.WriteLine(String.Format("MaxTrees: {0}", GlobalSettings.MaxTrees));
            Console.WriteLine(String.Format("TopK: {0}", GlobalSettings.TopK));
            Console.WriteLine(String.Format("SortBy: {0}", FIScoreComparer.SortBy));
            Console.WriteLine();

            if (args.Length == 0)
            {
                Thread t1 = new Thread(() =>
                {
                    for (int c = 3; c >= 0; c--)
                    {
                        Console.Write("\rStarting in {0:00} seconds with the settings above. Press any key to abort ...", c);
                        if (c == 0)
                        {
                            break;
                        }
                        for (int i = 0; i < 20; i++)
                        {
                            if (Console.KeyAvailable)
                            {
                                Console.ReadKey(true);
                                Console.WriteLine();
                                Environment.Exit(0);
                            }
                            Thread.Sleep(50);
                        }
                    }

                    return;
                });

                t1.Start();
                t1.Join();
                Console.WriteLine("\n");
            }

            var      start    = DateTime.Now;
            XgbModel xgbModel = XgbModelParser.GetXgbModelFromFile(GlobalSettings.XgbModelFile, GlobalSettings.MaxTrees);

            if (xgbModel == null)
            {
                Environment.Exit(-1);
            }

            var featureInteractions = xgbModel.GetFeatureInteractions(GlobalSettings.MaxInteractionDepth, GlobalSettings.MaxDeepening);

            var end = DateTime.Now;

            GlobalStats.ElapsedTime = (end - start);
            GlobalStats.ParsedTrees = xgbModel.NumTrees;
            GlobalStats.CollectedFeatureInteractions = featureInteractions.Count;

            featureInteractions.WriteToXlsx(GlobalSettings.OutputXlsxFile, GlobalSettings.TopK);

            end = DateTime.Now;
            Console.WriteLine(String.Format("Elapsed Time: {0}", (end - start)));
        }