Giter Club home page Giter Club logo

fuzzy-c-means's Introduction

Hi there 👋

I'm Madson Dias, I'm from Fortaleza, Ceará, Brazil. I have an MSc degree (2017) in Computer Science from Federal Institute of Ceará and currently, I'm pursuing a doctorate in Computer Science at Federal University of Ceará (UFC). I'm an associate researcher at the Logic and Artificial Intelligence Research Group (LogIA) at the Department of Computer Science, UFC. There I work under the supervision of Prof. César Lincoln Cavalcante Mattos.

Linkedin URL Twitter URL Researchgate URL Scholar URL Gmail URL

fuzzy-c-means's People

Contributors

danich1 avatar dependabot[bot] avatar dirknbr avatar omadson avatar zealberth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fuzzy-c-means's Issues

Question about the parameters

in the parameters:

m: represent exponent for the fuzzy partition matrix.
What represent 30% ? m=1.3 or m=30 ?

Thanks!

info due to invalid metadata entry 'name'

im using python 3.11, jupyter notebook 7

pip install fuzzy-c-means

WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'
Requirement already satisfied: fuzzy-c-means in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (1.7.0)
Requirement already satisfied: joblib<2.0.0,>=1.2.0 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (1.2.0)
Requirement already satisfied: numpy<2.0.0,>=1.21.1 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (1.24.3)
Requirement already satisfied: pydantic<2.0.0,>=1.9.0 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (1.10.13)
Requirement already satisfied: tabulate<0.9.0,>=0.8.9 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (0.8.10)
Requirement already satisfied: tqdm<5.0.0,>=4.64.1 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (4.65.0)
Requirement already satisfied: typer<0.5.0,>=0.4.0 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from fuzzy-c-means) (0.4.2)
Requirement already satisfied: typing-extensions>=4.2.0 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from pydantic<2.0.0,>=1.9.0->fuzzy-c-means) (4.6.3)
Requirement already satisfied: colorama in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from tqdm<5.0.0,>=4.64.1->fuzzy-c-means) (0.4.6)
Requirement already satisfied: click<9.0.0,>=7.1.1 in c:\users\lenovo\appdata\local\programs\python\python311\lib\site-packages (from typer<0.5.0,>=0.4.0->fuzzy-c-means) (8.1.3)
WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'
WARNING: Skipping C:\Users\Lenovo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip-23.2.1.dist-info due to invalid metadata entry 'name'

An issue with the partition coefficient calculation

for a given no. of clusters c, the value of partition clusters should be in the range [1/c,1] according to the research paper you linked, however here for c=2, I get:

Image 30-06-24 at 8 30 PM

which is clearly less than c=1/2=0.5

is there something wrong here?

is there Auto Cluster number ?

Hi,

I examined examples stages. I didn't see calculation auto cluster number. I guess, I have to manual enter cluster number. Is this true? Actually, I am searching something look like dbscan clustering.

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

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?

[feature] Clustering validation techniques

As remembered in issue #14, we can use some metrics to validate our model. I read section 4.3.3.2. of the paper On clustering validation techniques and verified that there are some cool metrics to be implemented. I will list below the metrics that I will implement in the next few days.

  • Partition coefficient (PR #15 - v1.2.2)
  • Partition entropy coefficient
  • Purity

'FCM' object has no attribute 'partition_coefficient'

Hi 👋🏻,

I am trying to reproduce the example "02 Validation". However, when I get to the point saying:

`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` 

I get an error saying:
'FCM' object has no attribute 'partition_coefficient'

Do I need to import something else in addition the usual packages?
It seems like it doesn't recognise the attribute partition.coefficient.

(the data X_embedded is the tSNE output as (415, 2))

Screenshot 2020-12-14 at 19 22 48 (2)

Cosine similarity is not a distance

Perhaps I'm wrong but shouldn't a distance matrix used for clustering have small values if the samples are close and large values when they are very different? With the current implementation of the cosine similarity, we obtain +1 for the same samples and -1 for very different samples. So I think we want to change the following

def _cosine_similarity(A: NDArray, B: NDArray) -> NDArray:
"""Compute the cosine similarity between two matrices"""
p1 = np.sqrt(np.sum(A**2,axis=1))[:,np.newaxis]
p2 = np.sqrt(np.sum(B**2,axis=1))[np.newaxis,:]
return np.dot(A,B.T) / (p1*p2)

to something like

 def _cosine_similarity(A: NDArray, B: NDArray) -> NDArray:
      """Compute the cosine similarity between two matrices"""
      p1 = np.sqrt(np.sum(A**2,axis=1))[:,np.newaxis]
      p2 = np.sqrt(np.sum(B**2,axis=1))[np.newaxis,:]
      return np.dot(A,B.T) / (p1*p2)

def _cosine(A: NDArray, B: NDArray) -> NDArray:
    """Compute the cosine distance between two matrices"""
    return np.abs(1 - _cosine_similarity(A, B))

and then use use _cosine instead of _cosine_similarity for computing the distance matrix.

PS: I can open a PR if required

Trying to run on GPUs

Hey,

Really nice implementation of FCMeans. Thank you for this. I'm trying to run it on a personal server with 8 Titan Xp cards. I know they're old but I can't seem to get your model to recognize a GPU is available when I set CUDA_VISIBLE_DEVICES as an environment variable.

Am I missing something?

I get this output when I initialize the code:
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)

Error check: array must not contain infs or NaNs

I try the code below:

	from sklearn import datasets
	X, y = datasets.load_iris(return_X_y=True)
	mod = FCM(n_clusters=14, max_iter=150, m=2)
	mod.fit(X.T)

and then got this error: array must not contain infs or NaNs

I think maybe the parameter u has the nan and then norm(u - u2) wouldn't be calculated.
Hence, I have the suggestion that you can add the below code before norm(u - u2)

	if True in pd.isnull(u):
		u = u2
		break

Thanks.

Support for custom distance metrics

Hello,
I could not find it, but is there support for custom distance metrics such a cosine similarity which is widely used in clustering in this package? Or does the FCM algorithm just use the euclidean squared distance metric?
Thanks and please let me know.

Error to run fcm fit on CLI

hi, @omadson.

First of all, congratulations to your work.

I'm trying to use the CLI to fit a model on the example on the sample of README.

I just create a virtualenv and install the library. After that, I start the python REPL and type this lines:

import numpy as np

n_samples = 3000

X = np.concatenate((
    np.random.normal((-2, -2), size=(n_samples, 2)),
    np.random.normal((2, 2), size=(n_samples, 2))
))
np.savetxt("data.csv", X, delimiter=",")

After save the dataset file, I tried to use this command:

fcm fit data.csv

And I receive the following traceback:

Reading data set... Data set read without errors...
Traceback (most recent call last):
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/bin/fcm", line 8, in <module>
    sys.exit(app())
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/typer/main.py", line 497, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/gustavo/.cache/pypoetry/virtualenvs/teste-fuzzy-Pa30dWmR-py3.8/lib/python3.8/site-packages/fcmeans/cli.py", line 118, in fit
    model = FCM(n_clusters, max_iter, m, error, random_state)
  File "pydantic/main.py", line 397, in pydantic.main.BaseModel.__init__
TypeError: __init__() takes exactly 1 positional argument (6 given)

I'm using Python 3.8.10 on a Manjaro 5.12.19.

Can you help me on this issue?

[feature] Add Poetry as dependency management system and packaging

Currently, we use the classical setuptools with a setup.py for building the package. However, with the changes introduced by PEP517, we can now use more modern and cleaner tools, like Poetry.

These are the issues that need to be resolved:

  • Create of the pyproject.toml with the necessary information about dependencies
  • Document changes into the README.md to show the package building process

Error when using more than 100 clusters

Hello,

I am trying to perform clustering with 300 clusters but I am getting an error. Is it possible to increase the maximum number of clusters?

Thank you,
Shahvaiz Hanif

FCM error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.