Esempio n. 1
0
        private void Initialize(int classes, Func <TBinary> initializer)
        {
            if (classes <= 1)
            {
                throw new ArgumentException("Number of classes must be higher than 1.", "classes");
            }

            this.NumberOfOutputs = classes;
            this.NumberOfClasses = classes;
            int total = (classes * (classes - 1)) / 2;

            models  = new TBinary[classes - 1][];
            indices = new ClassPair[total];
            int k = 0;

            for (int i = 0; i < Models.Length; i++)
            {
                models[i] = new TBinary[i + 1];
                for (int j = 0; j < models[i].Length; j++)
                {
                    indices[k++] = new ClassPair(i + 1, j);
                    var model = initializer();
                    models[i][j] = model;
                    if (model != null)
                    {
                        NumberOfInputs = model.NumberOfInputs;
                    }
                }
            }

            this.lastDecisionPath = new ThreadLocal <Decision[]>(() => new Decision[NumberOfOutputs - 1]);
            this.Track            = true;
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InnerParameters{TBinary, TInput}"/> class.
 /// </summary>
 ///
 /// <param name="model">The binary model to be learned.</param>
 /// <param name="inputs">The inputs to be used.</param>
 /// <param name="outputs">The outputs to be used.</param>
 /// <param name="pair">The class labels for the problem to be learned.</param>
 ///
 public InnerParameters(TBinary model, TInput[] inputs, bool[] outputs, ClassPair pair)
 {
     Model   = model;
     Inputs  = inputs;
     Outputs = outputs;
     Pair    = pair;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Decision"/> struct.
        /// </summary>
        /// <param name="i">The first class index.</param>
        /// <param name="j">The second class index.</param>
        /// <param name="winner">The class index that won.</param>
        public Decision(int i, int j, int winner)
        {
            if (winner != i && winner != j)
            {
                throw new ArgumentOutOfRangeException("winner");
            }

            this.pair   = new ClassPair(i, j);
            this.winner = winner;
        }