LinearAlgebra.DenseMatrix.IndexOfVerticalMax C# (CSharp) Method

IndexOfVerticalMax() public method

public IndexOfVerticalMax ( ) : int[]
return int[]
		public int[] IndexOfVerticalMax()
		{
			int[] IdxVerticalMax = new int[nCols];
			float[] ValVerticalMax = new float[nCols];

			for (int IdxCol = 0; IdxCol < nCols; IdxCol++ )
			{
				ValVerticalMax[IdxCol] = DenseMatrixValue[IdxCol].VectorValue[0];
				IdxVerticalMax[IdxCol] = 0;
				for (int IdxRow = 1; IdxRow < nRows; IdxRow++)
				{
					if (DenseMatrixValue[IdxCol].VectorValue[IdxRow] > ValVerticalMax[IdxCol])
					{
						ValVerticalMax[IdxCol] = DenseMatrixValue[IdxCol].VectorValue[IdxRow];
						IdxVerticalMax[IdxCol] = IdxRow;
					}
				}
			}

			return IdxVerticalMax;
		}

Usage Example

Beispiel #1
0
		/*
         * Compute the training error at the given batch
         */
		public static int ComputeNumberOfErrors(SparseMatrix Dt, DenseMatrix y)
		{
			if (Dt.nCols != y.nCols)
			{
				throw new Exception("The numbers of samples from label and prediction do not match.");
			}
			int nTotError = 0;
			int[] PredictedClass = y.IndexOfVerticalMax();
			for (int IdxCol = 0; IdxCol < Dt.nCols; IdxCol++)
			{
				if (Dt.SparseColumnVectors[IdxCol].Key[0] != PredictedClass[IdxCol])
				{
					nTotError++;
				}
			}
			return nTotError;
		}