BigML.Utils.isNumericType C# (CSharp) Method

isNumericType() public static method

public static isNumericType ( this o ) : bool
o this
return bool
        public static bool isNumericType(this object o)
        {
            switch (Type.GetTypeCode(o.GetType()))
            {
                case TypeCode.Byte:
                case TypeCode.SByte:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.Decimal:
                case TypeCode.Double:
                case TypeCode.Single:
                    return true;
                default:
                    return false;
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// Check if this is a regression model
        /// </summary>
        /// <returns> {boolean} True if all the predictions are numbers. </returns>
        private bool is_regression()
        {
            int index, len;
            Dictionary <object, object> prediction;

            for (index = 0, len = this.predictions.Length; index < len; index++)
            {
                prediction = this.predictions[index];
                if (!(Utils.isNumericType(prediction["prediction"])))
                {
                    return(false);
                }
            }
            return(true);
        }