Esempio n. 1
0
 public FeatureRegisteredEventArgs(DataStructureGroup datastructureGroup, int elementSize, double percentC, double percentR, double percentU, double percentD,
                                   string classifiedDS, string currentDS, double predictedProbValue, string nextDS, int regCount)
 {
     this.InterfaceAndSetBagPropertyGroup = datastructureGroup;
     this.ElementSizeAtTimeOfOperation    = elementSize;
     this.PercentC = percentC;
     this.PercentR = percentR;
     this.PercentU = percentU;
     this.PercentD = percentD;
     this.ClassifiedDataStructure               = classifiedDS;
     this.CurrentDataStructure                  = currentDS;
     this.PredictionProbabilityValue            = predictedProbValue;
     this.NextPredictedDataStructure            = nextDS;
     this.RegisteredCountFromLastTransformation = regCount;
 }
Esempio n. 2
0
        /// <summary>
        /// Register feature to the CLassifier
        /// Format:G,N,%C,%R,%U,%D
        /// </summary>
        /// <param name="datastructureGroup"></param>
        /// <param name="elementSize">Number of elements in the data structure at the time of an operation, N</param>
        /// <param name="percentC">%C</param>
        /// <param name="percentR">%R</param>
        /// <param name="percentU">%U</param>
        /// <param name="percentD">%D</param>
        public void RegisterFeature(DataStructureGroup datastructureGroup, int elementSize, double percentC, double percentR, double percentU, double percentD, CrudBasedCollection.C5DataStructure currentDS)
        {
            while (!isBusy)//this is to make sure that the next feature will be registered only after the prior one has been completely registered.
            {
                isBusy = true;
                currentDataStructure = currentDS;


                //1. Encode and normalize the feature values
                double[] x = new double[10];                                                                            //10 input values of the ANN
                double[] encodedNormInterfaceAndSetBagProperty = EncodeNormalizeDataStructureGroup(datastructureGroup); //X1 Feature (5-length array)
                Array.Copy(encodedNormInterfaceAndSetBagProperty, 0, x, 0, 5);                                          //copy to the first 5 arrays
                x[5] = (elementSize - gaussMeanX2) / gaussStdvX2;                                                       //X2 Feature
                x[6] = (percentC - gaussMeanX3) / gaussStdvX3;                                                          //X3 Feature
                x[7] = (percentR - gaussMeanX4) / gaussStdvX4;                                                          //X4 Feature
                x[8] = (percentU - gaussMeanX5) / gaussStdvX5;                                                          //X5 Feature
                x[9] = (percentD - gaussMeanX6) / gaussStdvX6;                                                          //X6 Feature;

                //2. Register to Classifier and compute the data structure
                double[] computed_y = Classifier.ComputeOutputs(x);//9 output values of the ANN
                //using winner-take-all method to evaluate y values
                int    maxComputedYIndex = MaxIndex(computed_y);
                string computedDS        = yValues[maxComputedYIndex];
                ngram.Dequeue();
                ngram.Enqueue(computedDS);

                //3. Register the computed DS as an N-Gram sequence to the Predictor
                Predictor.RegisterSequence(ngram.ToArray());
                string[] ngramMinus1 = new string[NValue - 1];
                Array.Copy(ngram.ToArray(), 1, ngramMinus1, 0, NValue - 1);
                CrudBasedCollection.C5DataStructure predictedDS = GetC5DataStructure(Predictor.PredictNext(ngramMinus1));
                isBusy = false;
                registerCount++;
                //For debugging or simulation purposes only, comment this line to improve performance
                OnFeatureRegistered(new FeatureRegisteredEventArgs(datastructureGroup, elementSize, percentC, percentR, percentU, percentD, computedDS, currentDataStructure.ToString(), Predictor.PredictedProbabilty, predictedDS.ToString(), registerCount));//raise an event

                bool reset = false;

                DecisionMaker.MakeDecision(registerCount, currentDataStructure, predictedDS, Predictor.PredictedProbabilty, out reset);
                if (reset)
                {
                    registerCount = 0;
                }


                break;
            }
        }
Esempio n. 3
0
        private double[] EncodeNormalizeDataStructureGroup(DataStructureGroup datastructureGroup)
        {
            //encoding using 1-of-(N-1)
            //ICollection,0
            //ICollectionBag,1
            //ICollectionSet,2
            //IList,3
            //IListBag,4
            //IListSet,5
            //THIS VALUES ARE STATIC AND SHOULD BE CHANGED ACCORDINGLY BASED ON THE THE VALUES FROM TRAINING DATASET
            double[] icollection    = new double[] { 1.0, 0.0, 0.0, 0.0, 0.0 };
            double[] icollectionBag = new double[] { 0.0, 1.0, 0.0, 0.0, 0.0 };
            double[] icollectionSet = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0 };
            double[] iList          = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0 };
            double[] iListBag       = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0 };
            double[] iListSet       = new double[] { -1.0, -1.0, -1.0, -1.0, -1.0 };

            if (datastructureGroup == DataStructureGroup.ICollection)
            {
                return(icollection);
            }
            else if (datastructureGroup == DataStructureGroup.ICollectionBag)
            {
                return(icollectionBag);
            }
            else if (datastructureGroup == DataStructureGroup.ICollectionSet)
            {
                return(icollectionSet);
            }
            else if (datastructureGroup == DataStructureGroup.IList)
            {
                return(iList);
            }
            else if (datastructureGroup == DataStructureGroup.IListBag)
            {
                return(iListBag);
            }
            else if (datastructureGroup == DataStructureGroup.IListSet)
            {
                return(iListSet);
            }
            else
            {
                return new double[] { 1.0, 1.0, 1.0, 1.0, 1.0 }
            };                                                  //unknown
        }
        private void SetDefaultDataStructure(DataStructureGroup interfaceAndSetBagProp)
        {
            C5DataStructure previousDS = base.CurrentDataStructure;

            //this default setting is based on our prior research experiment
            //please read our paper, "Predicting Data Structures for Energy Efficient Computing"
            if (interfaceAndSetBagProp == DataStructureGroup.ICollection)
            {
                base.CurrentDataStructure = C5DataStructure.HashSet;
            }
            else if (interfaceAndSetBagProp == DataStructureGroup.ICollectionBag)
            {
                base.CurrentDataStructure = C5DataStructure.HashBag;
            }
            else if (interfaceAndSetBagProp == DataStructureGroup.ICollectionSet)
            {
                base.CurrentDataStructure = C5DataStructure.HashSet;
            }
            else if (interfaceAndSetBagProp == DataStructureGroup.IList)
            {
                base.CurrentDataStructure = C5DataStructure.HashedLinkedList;
            }
            else if (interfaceAndSetBagProp == DataStructureGroup.IListBag)
            {
                base.CurrentDataStructure = C5DataStructure.ArrayList;
            }
            else if (interfaceAndSetBagProp == DataStructureGroup.IListSet)
            {
                base.CurrentDataStructure = C5DataStructure.HashedLinkedList;
            }
            else
            {
                base.CurrentDataStructure = C5DataStructure.HashSet;
            }
            //This will make sure that the internal data structure is also changed with the same existing data in it
            if (previousDS != base.CurrentDataStructure)
            {
                base.TransformTo(base.CurrentDataStructure);
            }
        }