Esempio n. 1
0
        private GlassTypes increaseTypeCount(GlassTypes types, int type)
        {
            switch (type)
            {
            case 1:
                types.type1++;
                break;

            case 2:
                types.type2++;
                break;

            case 3:
                types.type3++;
                break;

            case 4:
                types.type4++;
                break;

            case 5:
                types.type5++;
                break;

            case 6:
                types.type6++;
                break;

            case 7:
                types.type7++;
                break;
            }

            return(types);
        }
Esempio n. 2
0
        public void trainClassifier(List <Glass> glasses)
        {
            GlassTypes typeCounters = new GlassTypes();

            foreach (Glass glass in glasses)
            {
                glassTypeAnalise(refractive_index, glass.refractive_index, glass.group_type);
                glassTypeAnalise(sodium, glass.sodium, glass.group_type);
                glassTypeAnalise(magnesium, glass.magnesium, glass.group_type);
                glassTypeAnalise(aluminum, glass.aluminum, glass.group_type);
                glassTypeAnalise(silicon, glass.silicon, glass.group_type);
                glassTypeAnalise(potassium, glass.potassium, glass.group_type);
                glassTypeAnalise(iron, glass.iron, glass.group_type);

                typeCounters = increaseTypeCount(typeCounters, glass.group_type);
            }
            calculateProbabilities(refractive_index, refractive_indexProbability, typeCounters);
            calculateProbabilities(sodium, sodiumProbability, typeCounters);
            calculateProbabilities(magnesium, magnesiumProbability, typeCounters);
            calculateProbabilities(aluminum, aluminumProbability, typeCounters);
            calculateProbabilities(silicon, siliconProbability, typeCounters);
            calculateProbabilities(potassium, potassiumProbability, typeCounters);
            calculateProbabilities(iron, ironProbability, typeCounters);

            calculateTypesApperance(typeCounters);
        }
Esempio n. 3
0
        private void calculateTypesApperance(GlassTypes types)
        {
            typesApperance.type1Probobility = types.type1 / dataSetSize;
            typesApperance.type2Probobility = types.type2 / dataSetSize;
            typesApperance.type3Probobility = types.type3 / dataSetSize;
            typesApperance.type4Probobility = types.type4 / dataSetSize;
            typesApperance.type5Probobility = types.type5 / dataSetSize;
            typesApperance.type6Probobility = types.type6 / dataSetSize;
            typesApperance.type7Probobility = types.type7 / dataSetSize;

            typesApperance.changeZeros();
        }
Esempio n. 4
0
        private void glassTypeAnalise(Dictionary <double, GlassTypes> dict, double value, int type)
        {
            GlassTypes types;

            if (dict.ContainsKey(value))
            {
                types       = dict[value];
                dict[value] = increaseTypeCount(types, type);
            }
            else
            {
                types = new GlassTypes();
                dict.Add(value, increaseTypeCount(types, type));
            }
        }
Esempio n. 5
0
        private TypesProbabilities calculateTypesProbabilities(GlassTypes types, GlassTypes typesCounters)
        {
            TypesProbabilities tp = new TypesProbabilities();

            tp.type2Probobility = calculateProbability(types.type1, typesCounters.type1);
            tp.type2Probobility = calculateProbability(types.type2, typesCounters.type2);
            tp.type3Probobility = calculateProbability(types.type3, typesCounters.type3);
            tp.type4Probobility = calculateProbability(types.type4, typesCounters.type4);
            tp.type5Probobility = calculateProbability(types.type5, typesCounters.type5);
            tp.type6Probobility = calculateProbability(types.type6, typesCounters.type6);
            tp.type7Probobility = calculateProbability(types.type7, typesCounters.type7);

            tp.changeZeros();

            return(tp);
        }
Esempio n. 6
0
 private void calculateProbabilities(Dictionary <double, GlassTypes> dict, Dictionary <double, TypesProbabilities> probList, GlassTypes typeCounters)
 {
     foreach (KeyValuePair <double, GlassTypes> item in dict)
     {
         probList.Add(item.Key, calculateTypesProbabilities(item.Value, typeCounters));
     }
 }