GithubHelp home page GithubHelp logo

anfis's Introduction

ANFIS

anfis is a Python implementation of an Adaptive Neuro Fuzzy Inference System.

This ANFIS package is essentially a Python refactoring of the R code created by the team a the BioScience Data Mining Group, the original documentaion of which can be found here:

http://www.bdmg.com.ar/?page_id=176

As an exmaple of an ANFIS system, this Python code works (install and run the tests.py script to see it fit the some test data) but there is much left to do in order to improve the project. This is very much an early beta version. My python code is cruddy and NOT at all idiomatic. Documentation and doc strings need large amounts of work.

All useful contributions to make this a better project will be happily received.

Contributions

If you would like to contribute, please see the Issues section for ideas about what most needs attention.

Features

  • Currently the implementation will support the use of three types of membership function:

  • gaussmf: Gaussian

  • gbellmf: Generalized bell

  • sigmf: Sigmoid

This naming is taken from scikit-fuzzy, a fuzzy logic toolkit for SciPy, which can be found here: https://github.com/scikit-fuzzy/scikit-fuzzy

Each input variable can have an arbitrary number and mix of these membership functions.

  • A user can define the number of epochs that will be run

  • The returned ANFIS object can plot training errors, fitted results and the current shape of its membership functions (pre or post training)

Installation

anfis may then be installed by running:

$ pip install anfis

Dependencies

  • Python
  • numpy
  • scikit-fuzzy
  • matplotlib

Quickstart

Install anfis and navigate to the location of anfis/tests.py

From the command line run:

python tests.py

Alternatively, from the same location launch ipython and run:

run tests.py

This will set up and fit an ANFIS model based on the data contained in 'trainingSet.txt', using 10 epochs. Plots of the fitting errors and the model predicted output are graphed.

Contact

For other questions, please contact [email protected].

anfis's People

Contributors

arash-afshar avatar moonburnt avatar twmeggs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anfis's Issues

how to plot "plotMF"?

I cannot plot the anfis.plotMF. I don't know what to use as x and as InputVar. I tried several things, but the error “only integer scalar arrays can be converted to a scalar index” occurs everytime. Has someone an example?

As you used 4 membership function for each variable in example model. Can we use 3 membership function for each variable in our model with same ANFIS library ?

As you used 4 membership function for each variable in example model. Can we use 3 membership function for each variable in our model with same ANFIS library ?

In my model input variables are 12 and output variable is 1, if I use 4 mf for each variable, then total rules becoming
rules = 4 ^12 = 16777216
Consequent Parameters = 16777216 * ( 12 + 1) = 218103808

So my query is Can we use 3 membership function for each variable in our model with same ANFIS library ?

One more query How many observation do we need at least to model this data ( Consequent Parameters = 218103808)

AttributeError: module 'anfis' has no attribute 'ANFIS'

how to fix it?


AttributeError Traceback (most recent call last)
Cell In[7], line 6
1 mf = [[['gaussmf',{'mean':0.,'sigma':1.}],['gaussmf',{'mean':-1.,'sigma':2.}],['gaussmf',{'mean':-4.,'sigma':10.}],['gaussmf',{'mean':-7.,'sigma':7.}]],
2 [['gaussmf',{'mean':1.,'sigma':2.}],['gaussmf',{'mean':2.,'sigma':3.}],['gaussmf',{'mean':-2.,'sigma':10.}],['gaussmf',{'mean':-10.5,'sigma':5.}]]]
5 mfc = anfis.membershipfunction.MemFuncs(mf)
----> 6 anf = anfis.ANFIS(X, Y, mfc)
7 anf.trainHybridJangOffLine(epochs=20)
9 print (round(anf.consequents[-1][0],6))

AttributeError: module 'anfis' has no attribute 'ANFIS'

Update PyPI release

Project's readme says to install it with pip, yet version available on pypi is not up to date with upstream and crashes on literally every python3 installation. If possible, it could be nice to get newer release there

how to plot membership functions

I cannot plot the anfis.plotMF. I don't know what to use as x and as InputVar. I tried several things, but the error “only integer scalar arrays can be converted to a scalar index” occurs everytime. Has someone an example?

I have been try to use this function like this:

print("Plotting membership_function")
anf.plotMF(X,0)

But the results are so bad
e433f67abb626cd5106a2fa6c56d247

whatever I set this InputVar as '0' or '1', the results just as bad as I show

No module named 'membership'

AppData\Local\Programs\Python\Python310\lib\site-packages\anfis_init_.py", line 2, in
from membership import membershipfunction
ModuleNotFoundError: No module named 'membership'

Gaussian mean and sigma

Hhow can i integrate the decision of the mean and sigma for Gaussian based on neuronal networks (I want to make it automatically). Because the main feature, as I andertand the Anfis, is that it uses neuronal approch to decide, how membership functions look like.

(How did you estimate your menas and sigmas?)
Thx for your help in advance.
Rgrds,
Leyla

Syntax error

Someone please fix this issue. I had some trouble using the membershipfunction, but then I did the following but still get an error:
On my notebook, I use import anfis and from anfis.membership import membershipfunction. The rest is as the current code on github is.
I get this error:
File "/opt/anaconda3/lib/python3.8/site-packages/anfis/membership/membershipfunction.py", line 19
if len(rowInput) <> len(self.MFList):
^
SyntaxError: invalid syntax

Different number of MF for each input variable

i define the MF for four of my input variables as below:
mf = [[['gaussmf',{'mean':13.45,'sigma':3.2}], ['gaussmf',{'mean':25.7,'sigma':3.2}]], [['gaussmf',{'mean':41.74,'sigma':6.3}], ['gaussmf',{'mean':54.53,'sigma':6.3}], ['gaussmf',{'mean':66.51,'sigma':6.3}]], [['sigmf',{'b':1014.26,'c':-0.6}], ['sigmf',{'b':1012.1,'c':0.6}]], [['sigmf',{'b':60,'c':-0.6}], ['gaussmf',{'mean':73.31,'sigma':7.3}], ['sigmf',{'b':88,'c':0.6}]]]

but resulted in error when i run anf.trainHybridJangOffLine(epochs=3) like below:

image

i don't know how to solve this. please help me @twmeggs

IndexError: list index out of range

Hello

I have a dataset with 3 features and one output but I face this problem and I do not know how to solve it?

Any idea?

Error:

Number of variables does not match number of rule sets

IndexError Traceback (most recent call last)
in ()
51 #################################################################
52
---> 53 anf.trainHybridJangOffLine(epochs=epochs_anfis)
54
55 ####################################################################

3 frames
in (.0)
22 print("Number of variables does not match number of rule sets")
23
---> 24 return [[self.funcDictself.MFList[i][k][0] for k in range(len(self.MFList[i]))] for i in range(len(rowInput))]

IndexError: list index out of range

Example won't work

Hi!

Thanks for your work, but I'm afraid your example isn't working. The error just keeps going up and up, even raising the epochs number. There is no going down...

figure_1
figure_2

Is there any way to fix this?

Thanks in advance!

No module named 'membership'

I installed the anfis package using anaconda prompt and pip. I am using python 3.6 and the error that appears is: "ModuleNotFoundError: No module named 'membership'".

What could be happening?

Thanks in advance!

PD: the membership folder is inside the anfis folder and contains all the functions. Furthermore, the anfis package is inside the anaconda lib folder.

clustering type

What kind of clustering algorithm does this system work with?
gridPartion, subClustering, or FCM? And where can these values be set?

Current error increasing with the number of epochs (from epoch 20)

Hi,
I would like to know if anyone has encountered this problem:
When using the function for a more complex problem, I noticed that the current model error starts to increase.
I thought it was an error in my program, but when I tested the repository example, when I increased the epochs a little more, I found the same problem.

I leave below the image referring to the results of the example of the repository for more than 20 epochs:

image

On the one hand, I don't know if I should let the model evolve a little in this sense, hoping that it is just trying not to overfit.
However, I think that the assumption is always that the error decreases or at least stabilizes.
I tried to "fix" this by putting a simple "if" inside the anfis.py function itself that when the error increases more than 0.001, for more than 3 times (for exemple), it stops the training loop. However, I don't know to what extent this cannot be detrimental to the results

Thanks in advance

python 3 compatability

Hi, just an fyi that the membership folder is coming out as nested in the anfis/anfis folder and so in order to get to run the membership folder needs to placed in the parent dir and imported separately to both the test and anfis.py files. It wont run otherwise.

Shouldn't we use fuzzy multiplication?

Hi. Normal multiplication is used with the np.product(x) fuction in the ANFIS codes .
Shouldn't it be necessary to use fuzzy multiplication and addition operations because membership degrees are used?
If it should be as used in the codes, can you write the reason?
This answer is so important for me. I would be very grateful if you could answer.

please drop imp!

in new update of python imp dropped and after run tests.py raise error ModuleNotFoundError: No module named 'imp'

please fix this,

thansk alot

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.