daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public static double[][] ToCategorical(int[] data, uint numberOfClass)
  2.         {
  3.             double[][] categoricalArray = new double[data.Length][];
  4.             Dictionary<int, uint> classes = new Dictionary<int, uint>();
  5.             uint index = 0;
  6.             for (int i = 0; i < data.Length; i++)
  7.             {
  8.                 double[] row = new double[numberOfClass];
  9.                 if (!classes.ContainsKey(data[i]))
  10.                 {
  11.                     classes.Add(data[i], index++);
  12.                 }
  13.                 row[classes[data[i]]] = 1f;
  14.                 categoricalArray[i] = row;
  15.             }
  16.             return categoricalArray;
  17.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top