Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement