Hello Omry,
You have hit upon one of the biggest problems with cmeans at the moment - notably, that the API is overly complex. A longstanding intent of mine is to expose this in a sklearn-like way; perhaps I should move this up in my priority queue. In the meantime I can help you, but keep in mind the API will likely change in the future.
Basically, you need to present the transpose of data to the algorithm. As written the algorithm believes you have two input points instead of four, sees you are asking for two outputs, so it returns your original two points as cntr - this is the trivial case!
If you do this, executing
cntr, U, U0, d, Jm, p, fpc=skfuzzy.cmeans(data.T,c=2, m=2, error=None, maxiter=10, U_init=None, seed=None)
you will find the following:
>>> cntr
array([[ 2.99950869, 1.00061844],
[ 1.26601391, 2.99910802]])
>>> U
array([[ 0.009, 0.013, 0.007, 0.999 ],
[ 0.991, 0.987, 0.993, 0.000]])
Which tells you the locations of the calculated cluster centers in cntr, as well as the final fuzzy partitions for each point in U. In this case, as your book predicts, the first three data points belong to one cluster while the fourth belongs to a different cluster.
Also note that since initialization is random if you ran this algorithm several times you would find nearly identical results - but the identities of the cluster centers could be transposed. Which is why I worded my prior paragraph carefully (“one cluster”, “a different cluster”) rather than outright claiming the first or second cluster. This is typical for unsupervised algorithms.
If you need to then use these results to predict the fuzzy clustering of a different dataset, the function skfuzzy.cmeans_predict will be of assistance.
Again, these are functional at the moment but the API will change to something more akin to Scikit-Learn in the near future.
Best regards,
Josh Warner
skfuzzy.cmeans_predict as I did for cmeans ?