numl.Math.LinearAlgebra.Matrix.Slice C# (CSharp) Method

Slice() public static method

Slices.
public static Slice ( Matrix m, IEnumerable indices ) : Matrix
m Matrix Input Matrix.
indices IEnumerable The indices.
return Matrix
        public static Matrix Slice(Matrix m, IEnumerable<int> indices)
        {
            return MatrixExtensions.Slice(m, indices, VectorType.Row);
        }

Same methods

Matrix::Slice ( Matrix m, IEnumerable indices, VectorType t ) : Matrix

Usage Example

Example #1
0
        public override IModel Generate(Matrix x, Vector y)
        {
            int N = y.Length;
            Vector a = Vector.Zeros(N);

            // compute kernel
            Matrix K = Kernel.Compute(x);

            int n = 1;

            // hopefully enough to converge right? ;)
            // need to be smarter about storing SPD kernels...
            bool found_error = true;
            while (n < 500 && found_error)
            {
                found_error = false;
                for (int i = 0; i < N; i++)
                {
                    found_error = y[i] * a.Dot(K[i]) <= 0;
                    if (found_error) a[i] += y[i];
                }

                n++;
            }

            // anything that *matters*
            // i.e. support vectors
            var indices = a.Indices(d => d != 0);

            // slice up examples to contain
            // only support vectors
            return new KernelPerceptronModel
            {
                Kernel = Kernel,
                A = a.Slice(indices),
                Y = y.Slice(indices),
                X = x.Slice(indices)
            };
        }
All Usage Examples Of numl.Math.LinearAlgebra.Matrix::Slice