Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Tuple<double[][], Dictionary<int, uint>> ToCategorical(int[] data, uint numberOfClass, Dictionary<int, uint> classes = null)
- {
- double[][] categoricalArray = new double[data.Length][];
- if (classes == null)
- classes = new Dictionary<int, uint>();
- uint index = 0;
- for (int i = 0; i < data.Length; i++)
- {
- double[] row = new double[numberOfClass];
- if (!classes.ContainsKey(data[i]))
- {
- classes.Add(data[i], index++);
- }
- row[classes[data[i]]] = 1f;
- categoricalArray[i] = row;
- }
- return Tuple.Create(categoricalArray, classes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement