daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public static Tuple<double[][], Dictionary<int, uint>> ToCategorical(int[] data, uint numberOfClass, Dictionary<int, uint> classes = null)
  2.         {
  3.             double[][] categoricalArray = new double[data.Length][];
  4.             if (classes == null)
  5.                 classes = new Dictionary<int, uint>();
  6.             uint index = 0;
  7.             for (int i = 0; i < data.Length; i++)
  8.             {
  9.                 double[] row = new double[numberOfClass];
  10.                 if (!classes.ContainsKey(data[i]))
  11.                 {
  12.                     classes.Add(data[i], index++);
  13.                 }
  14.                 row[classes[data[i]]] = 1f;
  15.                 categoricalArray[i] = row;
  16.             }
  17.             return Tuple.Create(categoricalArray, classes);
  18.         }
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