Ejemplo n.º 1
0
        /// <summary>
        /// this function parses resource csv file in order to set list of CorrelatedFeatures.
        /// </summary>
        void learnNormal()
        {
            // read correlatedFeatures from resource csv
            using (var stream = Assembly
                                .GetExecutingAssembly()
                                .GetManifestResourceStream("MinCircleDLL.regFlightCsvModel.resources"))
                using (StreamReader csvReader = new StreamReader(stream))
                {
                    // skip the first row, where the columns names are mentioned.
                    string        currLine     = csvReader.ReadLine();
                    string[]      columns      = { };
                    List <string> lineData     = new List <string>();
                    char          colSeparator = ',';

                    // for each row in the csv file
                    while ((currLine = csvReader.ReadLine()) != null)
                    {
                        lineData = currLine.Split(colSeparator).Select(x => x.ToString()).ToList();

                        // if the new line is empty
                        if (lineData[0] == "")
                        {
                            break;
                        }

                        // parse the row into a correlatedFeatures object
                        CorrelatedFeatures corrFeature = new CorrelatedFeatures();
                        corrFeature.feature1   = lineData[0];
                        corrFeature.feature2   = lineData[1];
                        corrFeature.corrlation = double.Parse(lineData[2]);
                        corrFeature.threshold  = double.Parse(lineData[3]);
                        corrFeature.minCircle  = new Circle(new Point(double.Parse(lineData[4]), double.Parse(lineData[5])), double.Parse(lineData[6]));

                        this.cf.Add(corrFeature);
                    }
                }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///  this function checks if there is a significant deviation between the given point and the regression line of the correalted features.
 /// </summary>
 /// <param name="corrFeature"> a correlated feature </param>
 /// <param name="p"> a point </param>
 /// <returns> true - if there is a significant deviation, false if not.  </returns>
 bool detectedDev(CorrelatedFeatures corrFeature, Point p)
 {
     return(corrFeature.minCircle.radius * 1.1 < distance(corrFeature.minCircle.center, p));
 }