0

我正在尝试在 Python 中实现模糊 c 均值算法。我在 Matlab 中使用了内置函数来做同样的事情。我想知道 Python 中是否也有这样简单的方法。我试过了

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

我试过这个:

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

但得到* ImportError: No module named bitarray *

任何人都可以帮忙吗?

4

2 回答 2

1

我有这个问题。忘记sudo什么时候做pip install bitarray

于 2018-02-18T21:41:52.427 回答
1

有时只是因为您在包的已安装文件夹中,因此您无法导入它。尝试去其他地方并重新运行它。

于 2017-03-14T16:26:55.863 回答