Ejemplo n.º 1
0
        internal void train(List <TInputData> data)
        {
            bool sourceMatrixCreated = false;

            double[,] sourceMatrix = new double[0, 0];
            int[] labels = new int[0];
            //Accord.Math.Matrix.

            int index = 0;

            foreach (TInputData input in data)
            {
                DoubleArrayFeatureVector fv = this.InternalExtractor.extractFeatureVector(input);

                if (!sourceMatrixCreated)
                {
                    sourceMatrix        = new double[data.Count(), fv.FeatureVector.Count()];
                    labels              = new int[data.Count()];
                    sourceMatrixCreated = true;
                }
                Accord.Math.Matrix.SetRow <double>(sourceMatrix, index, fv.FeatureVector);
                index++;
            }

            method.train(sourceMatrix, labels);
        }
Ejemplo n.º 2
0
        public DoubleArrayFeatureVector extractFeatureVector(TInputData input)
        {
            DoubleArrayFeatureVector fv = internalExtractor.extractFeatureVector(input);

            double[] data = method.project(fv.FeatureVector);
            return(new DoubleArrayFeatureVector(data));
        }