private void MakeNumerical(Mushroom mushroom)
        {
            IsEdible        = mushroom.IsEdible;
            CapShapeValue   = (int)mushroom.CapShapeValue;
            CapSurfaceValue = (int)mushroom.CapSurfaceValue;
            CapColorValue   = (int)mushroom.CapColorValue;

            BruisesValue = (int)mushroom.BruisesValue;
            OdorValue    = (int)mushroom.OdorValue;

            GillAttachmentValue = (int)mushroom.GillAttachmentValue;
            GillSpacingValue    = (int)mushroom.GillSpacingValue;
            GillSizeValue       = (int)mushroom.GillSizeValue;
            GillColorValue      = (int)mushroom.GillColorValue;

            StalkShapeValue            = (int)mushroom.StalkShapeValue;
            StalkRootValue             = (int)mushroom.StalkRootValue;
            StalkSurfaceAboveRingValue = (int)mushroom.StalkSurfaceAboveRingValue;
            StalkSurfaceBelowRingValue = (int)mushroom.StalkSurfaceBelowRingValue;
            StalkColorAboveRingValue   = (int)mushroom.StalkColorAboveRingValue;
            StalkColorBelowRingValue   = (int)mushroom.StalkColorBelowRingValue;

            VeilTypeValue  = (int)mushroom.VeilTypeValue;
            VeilColorValue = (int)mushroom.VeilColorValue;

            RingNumberValue = (int)mushroom.RingNumberValue;
            RingTypeValue   = (int)mushroom.RingTypeValue;

            SporePrintColorValue = (int)mushroom.SporePrintColorValue;
            PopulationValue      = (int)mushroom.PopulationValue;
            HabitatValue         = (int)mushroom.HabitatValue;
        }
Esempio n. 2
0
        private decimal getPoisonousProbability(Mushroom shroom, bool useDimensionReduction = false)
        {
            // Using enum, decimal Tuple just for debugging, decimal List would suffice
            List <Tuple <Enum, decimal> > probabilities = new List <Tuple <Enum, decimal> >();
            var attributes = shroom.getAttributes();

            for (int i = 0; i < attributes.Length; i++)
            {
                if (useDimensionReduction && !selectedDimensionsIndexes.Contains(i))
                {
                    continue;
                }
                var     attribute  = attributes[i];
                decimal Ppoisonous = poisonousProbabilityTable.ContainsKey(attribute) ? poisonousProbabilityTable[attribute] : defaultProbabilityMain;
                probabilities.Add(new Tuple <Enum, decimal>(attribute, Ppoisonous));
            }

            probabilities.Sort((a, b) => Math.Abs(b.Item2 - neutralProbabilityMain).CompareTo(Math.Abs(a.Item2 - neutralProbabilityMain)));
            decimal probabilityProduct        = 1.0M;
            decimal probabilityInverseProduct = 1.0M;
            int     n = probabilities.Count;//useDimensionReduction ? probabilities.Count : nOfAttributesToCheckMain;//

            for (int i = 0; i < n; i++)
            {
                probabilityProduct        *= probabilities[i].Item2;
                probabilityInverseProduct *= (1 - probabilities[i].Item2);
            }
            decimal probabilityThatShroomIsPoisonous = probabilityProduct / (probabilityProduct + probabilityInverseProduct);

            return(probabilityThatShroomIsPoisonous);
        }
 public MushroomNumerical(Mushroom mushroom)
 {
     MakeNumerical(mushroom);
 }