Giter Site home page Giter Site logo

adaptive-neuro-fuzzy's Introduction

.NET ANFIS

This is WIP project

About

This C# implementation of ANFIS (Adaptive Neuro Fuzzy Inference System) is designed to solve task y=f(x) in form of IF–THEN rules

if x is Ai then y is Bi
where x is an m dimensional input vector, and y is an n dimensional vector of desired output, Ai is fuzzy set and Bi is consequence part of *i*-th rule.

Current version performs inference based on zero-order Sugeno fuzzy model (special case of the Mamdani Fuzzy inference system).

Algorithm
  1. Perform clustering on datasets x and y, where x is an input dataset and y is a dataset of desired outputs .
  2. Initialize fuzzy sets Ai and consequences Bi with use of obtained clusters.
  3. Tune ANFIS parameters with backprop in order to improve inference of the system.
  4. (Optional) if during training occurs situation when input case is not firing any rule, then it is possible to add new rule to database or adjust parameters of existing rules to fix issue.
Supported membership functions
  1. Triangle
  2. Bell-shaped
  3. Gaussian
Example of usage

Following code generates training datasets of logistic map evolution in form (xn-1, xn) → xn+1 and build ANFIS which can predict xn+1 on two previouse values (xn-1, xn) (testing and crossvalidation are omitted for simplicity).

int trainingSamples = 2000;
double[][] x = new double[trainingSamples][];
double[][] y = new double[trainingSamples][];

double px = 0.1;
double r = 3.8;
double lx = r * px * (1 - px);

//generate training set
for (int i = 0; i < trainingSamples; i++)
{
    x[i] = new double[] { px, lx };
    px = lx;
    lx = r * lx * (1 - lx);
    y[i] = new double[] { lx };
}

//initialize trainig algorithm
Backprop bprop = new Backprop(1e-2);
//if during training you faced an unknown sample which is not firing any rule
// you can manage this situation with callback bprop.UnknownCaseFaced += .... ;

//initialize clustering algo to provide initial rule set
KMEANSExtractorIO extractor = new KMEANSExtractorIO(10);
//Build IS with Gaussian membershib functions, backprop training and kmeans for rule initialization
ANFIS fis = ABuilder<GaussianRule>.Build(x, y, extractor, bprop, 1000);
//[Backprop - GaussianRule] Error 0,000690883407351925	Elapsed 00:00:31.1691934	RuleBase 10

Now you can use trained fis as folowing

double[] y = fis.Inference(x);

For more examples look into testANFIS.cs.

adaptive-neuro-fuzzy's People

Contributors

dependabot[bot] avatar kenoma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

adaptive-neuro-fuzzy's Issues

ABuild

Hello,

The class ABuilder is used to create a new IS but I can not find a definition of the class at anywhere in the code.

ANFIS fis = ABuilder.Build(x, y, extractor, bprop, 1000);

Is some code still missing in the project?

Best regards,
Patrick

Question

Please explain how are you calculating stand. deviation from the euclidean distance from the nearest neighbor in Gaussian Rule (and in Gaussian Rule 2) function
Why are you keeping same repeated (identical) values of stand. deviation (denoted by "a") in the end portion of your parameters array in Gaussian Rule. In Gaussian Rule 2, you are keeping only one stand. deviation value (denoted by "a")

I want to know Manual Mechanism this ANFIS

may i know the manual mechanism or flow of this project? i try to read theory of anfis but i cannot match with every part of your code, i still dont understand,
thanks for your amazing code

Missing file

The file rextractors\kmeanExtractorI.cs is mssing.
Jacques

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.