Esempio n. 1
0
 static void UpdateAsset(string[] value, ClassValues asset)
 {
     asset.className   = value[1];
     asset.health      = float.Parse(value[2]);
     asset.scoreOnKill = int.Parse(value[3]);
     asset.typeClass   = StringToBehaviour(value[4]);
 }
        private void ResetTargetVariableDependentMembers()
        {
            DeregisterParameterEvents();

            ((IStringConvertibleMatrix)ClassNamesParameter.Value).Columns = 1;
            ((IStringConvertibleMatrix)ClassNamesParameter.Value).Rows    = ClassValuesCache.Count;
            for (int i = 0; i < Classes; i++)
            {
                ClassNamesParameter.Value[i, 0] = "Class " + ClassValuesCache[i];
            }
            ClassNamesParameter.Value.ColumnNames = new List <string>()
            {
                "ClassNames"
            };
            ClassNamesParameter.Value.RowNames = ClassValues.Select(s => "ClassValue: " + s);

            PositiveClassParameter.ValidValues.Clear();
            foreach (var className in ClassNames)
            {
                PositiveClassParameter.ValidValues.Add(new StringValue(className).AsReadOnly());
            }

            ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Rows    = Classes;
            ((IStringConvertibleMatrix)ClassificationPenaltiesParameter.Value).Columns = Classes;
            ClassificationPenaltiesParameter.Value.RowNames    = ClassNames.Select(name => "Actual " + name);
            ClassificationPenaltiesParameter.Value.ColumnNames = ClassNames.Select(name => "Estimated " + name);
            for (int i = 0; i < Classes; i++)
            {
                for (int j = 0; j < Classes; j++)
                {
                    if (i != j)
                    {
                        ClassificationPenaltiesParameter.Value[i, j] = 1;
                    }
                    else
                    {
                        ClassificationPenaltiesParameter.Value[i, j] = 0;
                    }
                }
            }
            RegisterParameterEvents();
        }
Esempio n. 3
0
        public AnovaResult Anova(double probability)
        {
            if (probability > 1 || probability < 0)
            {
                throw new Exception("Probability must be between 1 and 0");
            }

            //Verify if all groups have the same number of datapoints
            List <int> noValues = ClassValues.Select(a => a.Value.Count).Distinct().ToList();

            if (noValues.Count != 1)
            {
                Console.WriteLine(Locus + " does not present quantitation values for all replicates");
                throw new Exception("Number of values in all classes must be the same for anova test");
            }

            string allGroups = string.Join(",", MyChart.Series.Select(a => a.Name).ToList());


            AnovaResult result = MyChart.DataManipulator.Statistics.Anova(probability, allGroups);

            return(result);
        }
Esempio n. 4
0
 public IEnumerable <double> GetEstimatedClassValues(IEnumerable <double> estimatedValues)
 {
     if (!Thresholds.Any() && !ClassValues.Any())
     {
         throw new ArgumentException("No thresholds and class values were set for the current symbolic classification model.");
     }
     foreach (var x in estimatedValues)
     {
         int classIndex = 0;
         // find first threshold value which is larger than x => class index = threshold index + 1
         for (int i = 0; i < thresholds.Length; i++)
         {
             if (x > thresholds[i])
             {
                 classIndex++;
             }
             else
             {
                 break;
             }
         }
         yield return(classValues.ElementAt(classIndex - 1));
     }
 }