ImportError: No module named bitarray

puja picture puja · Apr 26, 2015 · Viewed 8.5k times · Source

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?

Answer

Gavin Haslehurst picture Gavin Haslehurst · Feb 18, 2018

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