Ejemplo n.º 1
0
        /// <summary>
        /// Performs feature scaling on the supplied array and returns a copy
        /// </summary>
        /// <param name="column">Column array to compute</param>
        /// <returns></returns>
        public static double[] FeatureScale(double[] column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("Column was null");
            }

            double[] result = new double[column.Length];

            double avg = column.Average();
            double sdv = column.StandardDeviation(c => c, false);

            for (int x = 0; x < column.Length; x++)
            {
                result[x] = FeatureNormalizer.FeatureScale(column[x], avg, sdv);
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Performs feature scaling on the supplied column vector and returns a copy
 /// </summary>
 /// <param name="column">Column vector to compute</param>
 /// <returns></returns>
 public static Vector FeatureScale(Vector column)
 {
     double[] temp = column.ToArray();
     return(new Vector(FeatureNormalizer.FeatureScale(temp)));
 }