Accord.Fuzzy.LinguisticVariable.GetLabelMembership C# (CSharp) Method

GetLabelMembership() public method

Calculate the membership of a given value to a given label. Used to evaluate linguistics clauses like "X IS A", where X is a value and A is a linguistic label.
The label indicated in labelName was not found in the linguistic variable.
public GetLabelMembership ( string labelName, float value ) : float
labelName string Label (fuzzy set) to evaluate value's membership.
value float Value which label's membership will to be calculated.
return float
        public float GetLabelMembership( string labelName, float value )
        {
            FuzzySet fs = labels[labelName];
            return fs.GetMembership( value );
        }
    }

Usage Example

Esempio n. 1
0
        // Testing basic functionality of linguistic variables
        private void runLingVarTestButton_Click(object sender, EventArgs e)
        {
            ClearDataSeries();

            // create a linguistic variable to represent temperature
            LinguisticVariable lvTemperature = new LinguisticVariable("Temperature", 0, 80);

            // create the linguistic labels (fuzzy sets) that compose the temperature 
            FuzzySet fsCold = new FuzzySet("Cold", new TrapezoidalFunction(10, 15, TrapezoidalFunction.EdgeType.Right));
            FuzzySet fsCool = new FuzzySet("Cool", new TrapezoidalFunction(10, 15, 20, 25));
            FuzzySet fsWarm = new FuzzySet("Warm", new TrapezoidalFunction(20, 25, 30, 35));
            FuzzySet fsHot = new FuzzySet("Hot", new TrapezoidalFunction(30, 35, TrapezoidalFunction.EdgeType.Left));

            // adding labels to the variable
            lvTemperature.AddLabel(fsCold);
            lvTemperature.AddLabel(fsCool);
            lvTemperature.AddLabel(fsWarm);
            lvTemperature.AddLabel(fsHot);

            // get membership of some points to the cool fuzzy set
            double[][,] chartValues = new double[4][,];
            for (int i = 0; i < 4; i++)
                chartValues[i] = new double[160, 2];

            // showing the shape of the linguistic variable - the shape of its labels memberships from start to end
            int j = 0;
            for (float x = 0; x < 80; x += 0.5f, j++)
            {
                double y1 = lvTemperature.GetLabelMembership("Cold", x);
                double y2 = lvTemperature.GetLabelMembership("Cool", x);
                double y3 = lvTemperature.GetLabelMembership("Warm", x);
                double y4 = lvTemperature.GetLabelMembership("Hot", x);

                chartValues[0][j, 0] = x;
                chartValues[0][j, 1] = y1;
                chartValues[1][j, 0] = x;
                chartValues[1][j, 1] = y2;
                chartValues[2][j, 0] = x;
                chartValues[2][j, 1] = y3;
                chartValues[3][j, 0] = x;
                chartValues[3][j, 1] = y4;
            }

            // plot membership to a chart
            chart.UpdateDataSeries("COLD", chartValues[0]);
            chart.UpdateDataSeries("COOL", chartValues[1]);
            chart.UpdateDataSeries("WARM", chartValues[2]);
            chart.UpdateDataSeries("HOT", chartValues[3]);
        }