public static byte[] Serialise(SupportVectorMachine <Linear> svm)
        {
            if (svm == null)
            {
                throw new ArgumentNullException(nameof(svm));
            }

            var writer = new BinaryListWriter();

            writer.WriteInt(svm.NumberOfInputs);
            writer.WriteInt(svm.SupportVectors.Length);
            foreach (var supportVector in svm.SupportVectors)
            {
                writer.WriteInt(supportVector.Length);
                foreach (var value in supportVector)
                {
                    WriteDoubleWithMagnitudeNoLargerThanOne(writer, value);
                }
            }
            writer.WriteInt(svm.Weights.Length);
            foreach (var weight in svm.Weights)
            {
                WriteDoubleWithMagnitudeNoLargerThanOne(writer, weight);
            }
            WriteDoubleWithMagnitudeNoLargerThanOne(writer, svm.Threshold);
            return(writer.ToArray());
        }
        private static void WriteDoubleWithMagnitudeNoLargerThanOne(BinaryListWriter writer, double value)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (Math.Abs(value) > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(value));
            }

            writer.WriteInt((int)(value * _doubleToIntMultiplier));
        }