예제 #1
0
        public void Test()
        {
            int        l = 30;
            int        k = 10;
            double     ratioSeparable = 0;
            int        numSeparable   = 0;
            ExampleSet set            = new ExampleSet();


            for (int d = 10; d < 50; d = d + 10)
            {
                numSeparable = 0;

                for (int n = 0; n < k; n++)
                {
                    set.Examples.Clear();

                    for (int i = 0; i < l; i++)
                    {
                        SparseVector x = new SparseVector(d);

                        for (int j = 0; j < d; j++)
                        {
                            x[j] = m_rand.NextDouble();
                        }

                        Category c = GetRandCategory();
                        Example  e = new Example(c);
                        e.X = x;
                        set.AddExample(e);
                    }

                    SimpleLLM llm = new SimpleLLM(set, d);
                    //Logging.Info(string.Format("IsLinearSeparable: {0}", llm.IsLinearSeparable()));
                    //System.Console.WriteLine(string.Format("IsLinearSeparable: {0}", llm.IsLinearSeparable()));
                    if (llm.IsLinearSeparable())
                    {
                        numSeparable++;
                    }
                }

                ratioSeparable = 1.0 * numSeparable / k;

                System.Console.WriteLine(string.Format("d: {0}, l: {1}, Separable ratio: {2}", d, l, ratioSeparable));
            }
        }
예제 #2
0
        public void Test()
        {
            int l = 30;
            int k = 10;
            double ratioSeparable = 0;
            int numSeparable = 0;
            ExampleSet set = new ExampleSet();

            for (int d = 10; d < 50; d=d+10)
            {
                numSeparable = 0;

                for (int n = 0; n < k; n++)
                {
                    set.Examples.Clear();

                    for (int i = 0; i < l; i++)
                    {
                        SparseVector x = new SparseVector(d);

                        for (int j = 0; j < d; j++)
                        {
                            x[j] = m_rand.NextDouble();
                        }

                        Category c = GetRandCategory();
                        Example e = new Example(c);
                        e.X = x;
                        set.AddExample(e);
                    }

                    SimpleLLM llm = new SimpleLLM(set, d);
                    //Logging.Info(string.Format("IsLinearSeparable: {0}", llm.IsLinearSeparable()));
                    //System.Console.WriteLine(string.Format("IsLinearSeparable: {0}", llm.IsLinearSeparable()));
                    if (llm.IsLinearSeparable())
                    {
                        numSeparable++;
                    }

                }

                ratioSeparable = 1.0 * numSeparable / k;

                System.Console.WriteLine(string.Format("d: {0}, l: {1}, Separable ratio: {2}", d, l, ratioSeparable));
            }
        }