0

I am trying to implement fuzzy c means algorithm in Python..I have used the builtin function to do the same in Matlab.I would like to know whether there is any such simple method in Python also.I tried

http://peach.googlecode.com/hg/doc/build/html/tutorial/fuzzy-c-means.html

I have tried this :

from numpy import *
import peach as p

    x = array( [
        [ 0., 0. ], [ 0., 1. ], [ 0., 2. ], [ 1., 0. ], [ 1., 1. ], [ 1., 2. ],
        [ 2., 0. ], [ 2., 1. ], [ 2., 2. ], [ 5., 5. ], [ 5., 6. ], [ 5., 7. ],
        [ 6., 5. ], [ 6., 6. ], [ 6., 7. ], [ 7., 5. ], [ 7., 6. ], [ 7., 7. ] ] )

    mu = array( [
        [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ],
        [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.7, 0.3 ], [ 0.3, 0.7 ],
        [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ],
        [ 0.3, 0.7 ], [ 0.3, 0.7 ], [ 0.3, 0.7 ] ] )


    m = 2.0

    fcm = p.FuzzyCMeans(x, mu, m)

    print "After 20 iterations, the algorithm converged to the centers:"
    print fcm(emax=0)
    print "The membership values for the examples are given below:"
    print fcm.mu

but getting * ImportError: No module named bitarray *

Can anyone help?

Kishore
  • 819
  • 9
  • 20
puja
  • 47
  • 1
  • 2
  • 10
  • please post your code. – Kishore Apr 26 '15 at 05:50
  • 1
    Did you try installing it? – Ignacio Vazquez-Abrams Apr 26 '15 at 05:53
  • @Kishore I have edited my post.plz go thru – puja Apr 26 '15 at 05:57
  • @IgnacioVazquez-Abrams Yes I tried installing bitarray-0.8.1 but it seems like it is not installed properly..I am using windows 8 32 bit. – puja Apr 26 '15 at 06:01
  • spin up a python console and check if this - `from bitarray import bitarray` works. If you get an `importError`, check in the python dist-packages directory if the module exists. – Kishore Apr 26 '15 at 06:09
  • @Kishore I tried and couldnt find the module in site-package directory ..So how can I proceed?I have downloaded the bitarray package zip file..but I dont know where is it to be extracted?in site-package directory?It have tried that also..but didnt work.. – puja Apr 26 '15 at 06:49
  • Have a look at this - https://pypi.python.org/pypi/bitarray/ – Kishore Apr 26 '15 at 07:17

2 Answers2

3

I had this problem. Forgot the sudo when doing pip install bitarray

Ignas
  • 4,092
  • 17
  • 28
1

Sometimes it is just because you are in the installed folder of the package so that you could not import it. Try to go somewhere else and rerun it.