Exemple #1
0
        public static DataSet <FeatureType, LabelType> Read <FeatureType2, LabelType2>(BinaryReader reader, IBinaryReader <FeatureType> reader_features, IBinaryReader <LabelType> reader_labels)
        {
            DataContext           data_context = DataSet.DataContext.Read(reader);
            IList <FeatureType[]> feature_data = ToolsCollection.ConvertToArrayArray(reader_features.ReadArray2D());
            IList <bool []>       missing_data = ToolsCollection.ConvertToArrayArray(reader.ReadBooleanArray2D());
            IList <LabelType[]>   label_data   = ToolsCollection.ConvertToArrayArray(reader_labels.ReadArray2D());

            return(new DataSet <FeatureType, LabelType>(data_context, feature_data, missing_data, label_data));
        }
        public static IModelDiscrete <double, int> Read(BinaryReader reader)
        {
            IDataContext data_context = DataSet.DataContext.Read(reader);
            ModelNearestNeighborKDTreeDefault model = new ModelNearestNeighborKDTreeDefault(data_context);

            double[][]             instance_features = ToolsCollection.ConvertToArrayArray(reader.ReadFloat64Array2D());
            bool[][]               instance_missings = ToolsCollection.ConvertToArrayArray(new bool[instance_features.GetLength(0), instance_features.GetLength(1)]);
            int[][]                instance_labels   = ToolsCollection.ConvertToArrayArray(reader.ReadInt32Array2D());
            IDataSet <double, int> training_set      = new DataSet <double, int>(data_context, instance_features, instance_missings, instance_labels);

            return(model.GenerateModelDiscrete(training_set));
        }
Exemple #3
0
        //Main Contructor
        public DataSet(
            IDataContext data_context,
            IList <FeatureType[]> feature_data,
            IList <bool[]> missing_data,
            IList <LabelType[]> label_data)
        {
            if (data_context == null)
            {
                throw new NullReferenceException();
            }
            if (feature_data == null)
            {
                throw new NullReferenceException();
            }
            if (missing_data == null)
            {
                throw new NullReferenceException();
            }
            if (label_data == null)
            {
                throw new NullReferenceException();
            }

            if (ToolsCollection.IsStaggered(feature_data))
            {
                throw new Exception("Does not accept staggered feature data");
            }

            if (ToolsCollection.IsStaggered(missing_data))
            {
                throw new Exception("Does not accept staggered missing data");
            }
            //TODO check that feature_data is of equal size as missing data
            if (ToolsCollection.IsStaggered(label_data))
            {
                throw new Exception("Does not accept staggered label data");
            }

            if (!ToolsCollection.AreEqualSize(feature_data, missing_data))
            {
                throw new Exception("Must have missing data for every feature");
            }

            if (feature_data.Count != label_data.Count)
            {
                throw new Exception("Feature and label instances must be equal");
            }

            this.DataContext  = data_context;
            this.feature_data = ToolsCollection.ConvertToArrayArray(feature_data);
            this.missing_data = ToolsCollection.ConvertToArrayArray(missing_data);
            this.label_data   = ToolsCollection.ConvertToArrayArray(label_data);
        }