omadson / fuzzy-c-means

A simple python implementation of Fuzzy C-means algorithm.
https://fuzzy-c-means.rtfd.io
MIT License
175 stars 43 forks source link

'FCM' object has no attribute 'partition_coefficient' on Windows #21

Closed Habiba-Farrukh closed 3 years ago

Habiba-Farrukh commented 3 years ago

I get this error when I try to access the partition_coefficient used in the provided examples. I tried updating the package but I get this error: "Could not find a version that satisfies the requirement jaxlib<0.2.0,>=0.1.57" Could you please guide on how I can access this attribute on a Windows system?

omadson commented 3 years ago

Hi, @Habiba-Farrukh. Thanks for your interest in this package.

So, in this release, the fuzzy-c-means don't have support to the Windows system because now I'm using jax as the main dependency, but I'll to create a fork of this repository and change it to NumPy for Windows' users.

I'll leave this issue open and when I create the fork, I'll let you know here.

Habiba-Farrukh commented 3 years ago

Thank you very much @omadson. It'll be great to have support for Windows.

WJ-Huang commented 3 years ago

Hi, I also have this problem. Looking forward to hearing good news from you!

omadson commented 3 years ago

Hello, @Habiba-Farrukh @WJ-Huang.

I am updating the library so that it can work on both Windows and Unix systems.

yadiwiguna commented 3 years ago

Hi,

I just installed using windows version

pip install fuzzy-c-means[windows]

but still got the same problem

omadson commented 3 years ago

@yadiwiguna can you send the python version, your code, and the traceback?

If possible, try to create a minimal, reproducible example.

Anyway, if you want to calculate with your own hands, after fitting, use:

partition_coefficient = np.sum(fcm.u ** 2) / fcm.n_samples
yadiwiguna commented 3 years ago

Hi @omadson ,

Thank for your immediate response, here the requirements as you mentioned earlier

Python version : Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Code :

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from fcmeans import FCM

n_clusters_list = [2, 3, 4, 5, 6, 7]
models =list()
for n_clusters in n_clusters_list:
    fcm = FCM(n_clusters)
    fcm.fit(data_south_pca[['CV_AR','component_south']].to_numpy())
    models.append(fcm)

num_clusters = len(n_clusters_list)
rows = int(np.ceil(np.sqrt(num_clusters)))
cols = int(np.ceil(num_clusters / rows))
f, axes = plt.subplots(rows, cols, figsize=(11,16))
for n_clusters, model, axe in zip(n_clusters_list, models, axes.ravel()):
    # get validation metrics
    pc = model.partition_coefficient
    pec = model.partition_entropy_coefficient

    fcm_centers = model.centers
    fcm_labels = model.predict(data_south_pca[['CV_AR','component_south']].to_numpy())

Traceback :

AttributeError                            Traceback (most recent call last)
<ipython-input-9-1fa9a741491b> in <module>
      5 for n_clusters, model, axe in zip(n_clusters_list, models, axes.ravel()):
      6     # get validation metrics
----> 7     pc = model.partition_coefficient
      8     pec = model.partition_entropy_coefficient
      9 

AttributeError: 'FCM' object has no attribute 'partition_coefficient'
omadson commented 3 years ago

Hello, @yadiwiguna. I don't know what can be happening.

Can you send the FCM version installed? Try to type:

pip list
yadiwiguna commented 3 years ago

Hi @omadson , I upgraded FCM version, but it keeps show me that it has 1.0.0 version

omadson commented 3 years ago

Hi @yadiwiguna, try to uninstall.

pip uninstall fuzzy-c-means

and reinstall

pip install fuzzy-c-means[windows]

After that, try list the version.

yadiwiguna commented 3 years ago

It keeps giving me 1.0.0 version, but after successful installation this warning always appeared on the prompt

WARNING: fuzzy-c-means 1.2.4 does not provide the extra 'windows'

omadson commented 3 years ago

Hello @yadiwiguna. The 1.4.0 version of fuzzy-c-means just works on Python >= 3.8. You need to update your Python version and after that, install fuzzy-c-means library with

pip install fuzzy-c-means[windows]
yadiwiguna commented 3 years ago

I'm running on python 3.8.8 version but somehow still get the same problem

omadson commented 3 years ago

Hello, guys. This issue is solved by #40. I change the main dependency to just numpy instead jax.