Example #1
0
        /// <summary>
        /// Converts a time series training data set into something that looks
        /// like a normal data set with some number of inputs.
        /// </summary>
        /// <returns>Read the summary section</returns>
        private GPTrainingData ConvertTSToModeling(int InputDimension, int PredictionDistance)
        {
            GPTrainingData TSTraining = new GPTrainingData();

            TSTraining.TimeSeriesSource = true;

            //
            // The number of rows is the number of rows in the Training
            // set minus the input dimension and the prediction distance.  We subtract this off
            // because we can't predict anything before the first 'n' input values.
            int Rows = Training.Rows - InputDimension - PredictionDistance + 1;

            TSTraining.ConstructStorage(Rows, InputDimension, 1);

            //
            // Now, put together the rows of input data and the objective for each
            // of these rows.
            for (int Row = 0; Row < Rows; Row++)
            {
                //
                // Set the inputs
                for (int Column = 0; Column < InputDimension; Column++)
                {
                    TSTraining[Row, Column] = Training[Row + Column, 0];
                }

                //
                // Set the objective
                TSTraining.ObjectiveRow(Row)[0] = Training[Row + InputDimension + PredictionDistance - 1, 0];
            }

            return(TSTraining);
        }
Example #2
0
        /// <summary>
        /// Manages importing the data into the database
        /// </summary>
        /// <param name="Filename"></param>
        /// <param name="DelInit"></param>
        /// <param name="DelIncrement"></param>
        /// <param name="TempData"></param>
        /// <returns></returns>
        private bool ImportToDB(String Filename, DELInitProgress DelInit, DELIncrementProgress DelIncrement, List <List <double> > TempData)
        {
            //
            // Create the internal array and get the Training copied into it.  We
            // currently support a single objective, so a 1 for the last param.
            m_Training.ConstructStorage(TempData.Count, TempData[0].Count - 1, 1);
            for (int Row = 0; Row < TempData.Count; Row++)
            {
                //
                // Copy the values in
                for (int Column = 0; Column < (TempData[0].Count - 1); Column++)
                {
                    m_Training[Row, Column] = TempData[Row][Column];
                }

                m_Training.ObjectiveRow(Row)[0] = TempData[Row][TempData[Row].Count - 1];
            }

            //
            // Decide if this is a time series file (single column)
            if (TempData[0].Count == 1)
            {
                this.TimeSeries = true;
            }
            else
            {
                this.TimeSeries = false;
            }

            //
            // Have the UI prepare itself
            DelInit(this.Rows);

            //
            // Import this Training into the database - Let the user know the records
            // are being imported, that's what the 'DelIncrement' delegate is for.
            String[] FileParts = Filename.Split('\\');
            ImportDataToDB(FileParts[FileParts.Length - 1], Filename, DelIncrement);

            this.Name        = FileParts[FileParts.Length - 1];
            this.Description = Filename;

            return(true);
        }