private static double WriteDoubleWithMagnitudeNoLargerThanOne(BinaryArrayReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            return(reader.ReadInt() / _doubleToIntMultiplier);
        }
        public static SupportVectorMachine <Linear> Deserialise(byte[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var reader                 = new BinaryArrayReader(data);
            var numberOfInputs         = reader.ReadInt();
            var numberOfSupportVectors = reader.ReadInt();
            var supportVectors         = new double[numberOfSupportVectors][];

            for (var supportVectorIndex = 0; supportVectorIndex < numberOfSupportVectors; supportVectorIndex++)
            {
                var numberOfValues = reader.ReadInt();
                supportVectors[supportVectorIndex] = new double[numberOfValues];
                for (var valueIndex = 0; valueIndex < numberOfValues; valueIndex++)
                {
                    supportVectors[supportVectorIndex][valueIndex] = WriteDoubleWithMagnitudeNoLargerThanOne(reader);
                }
            }
            var numberOfWeights = reader.ReadInt();
            var weights         = new double[numberOfWeights];

            for (var weightIndex = 0; weightIndex < numberOfWeights; weightIndex++)
            {
                weights[weightIndex] = WriteDoubleWithMagnitudeNoLargerThanOne(reader);
            }
            var threshold = WriteDoubleWithMagnitudeNoLargerThanOne(reader);

            return(new SupportVectorMachine <Linear>(numberOfInputs, new Linear())
            {
                SupportVectors = supportVectors,
                Weights = weights,
                Threshold = threshold
            });
        }