程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Introduction of fuzzy c-means clustering (FCM) algorithm and its Python implementation

編輯:Python

This article was written by the landlord by doing his homework long ago , If there is any problem, Mina sang is suggested to solve it by herself ~

Catalog

    • One 、 The theory is introduced
    • Two 、 Algorithm implementation ideas
    • 3、 ... and 、FCM Algorithm core code python Realization
    • Four 、 Examples of use
      • 1. Clustering the data
      • 2. Image segmentation
    • 5、 ... and 、 Summary of implementation errors
    • 6、 ... and 、 Source link

One 、 The theory is introduced




Two 、 Algorithm implementation ideas

The basic idea of the algorithm is given below :
1. You can initialize a membership matrix first U( The sum of membership degree of each sample to each class is 1).
2. according to U Start with the class center matrix C Calculate .
3. According to C Calculation U.
4. loop 2,3 Step until the cycle conditions are met , end .

3、 ... and 、FCM Algorithm core code python Realization




Four 、 Examples of use

1. Clustering the data

Next I use np Of random Generate some data to FCM To display
Example 1:

Example 2:

Example 3:


2. Image segmentation


The results of image segmentation are shown below ~

grayscale :( The cluster center shown below is 2 and 15 Two kinds of )

Ps: Do not set the cluster center too large , Don't make the picture too big !!!

Color picture :

You can see , After segmentation, the image can still have a clear outline , Only the number of types of grayscale or color is reduced .



5、 ... and 、 Summary of implementation errors

6、 ... and 、 Source link

Click here to , Mixed food is the best


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved