Package: metacluster
MetaCluster is the largest open-source nature-inspired optimization (Metaheuristic Algorithms) library for
clustering problem in PythonFree software:GNU General Public License (GPL) V3 licenseProvided 3 classes:MetaCluster,MhaKCentersClustering, andMhaKMeansTunerTotal nature-inspired metaheuristic optimizers (Metaheuristic Algorithms): > 200 optimizersTotal objective functions (as fitness): > 40 objectivesTotal supported datasets: 48 datasets from Scikit learn, UCI, ELKI, KEEL...Total performance metrics: > 40 metricsTotal different way of detecting the K value: >= 10 methodsDocumentation:https://metacluster.readthedocs.io/en/latest/Python versions:>= 3.7.xDependencies:numpy, scipy, scikit-learn, pandas, mealpy, permetrics, plotly, kaleidoInstallationInstall thecurrent PyPI release:$pipinstallmetacluster==1.2.0Install directly from source code$gitclonehttps://github.com/thieu1995/metacluster.git
$cdmetacluster
$pythonsetup.pyinstallIn case, you want to install the development version from Github:$pipinstallgit+https://github.com/thieu1995/permetricsAfter installation, you can import MetaCluster as any other Python module:$python
>>>importmetacluster
>>>metacluster.__version__ExamplesLet's go through some examples.1. First, load dataset. You can use the available datasets from MetaCluster:# Load available dataset from MetaClusterfrommetaclusterimportget_dataset# Try unknown dataget_dataset("unknown")# Enter: 1      -> This wil list all of avaialble datasetdata=get_dataset("Arrhythmia")Or you can load your own datasetimportpandasaspdfrommetaclusterimportData# load X and y# NOTE MetaCluster accepts numpy arrays only, hence use the .values attributedataset=pd.read_csv('examples/dataset.csv',index_col=0).valuesX,y=dataset[:,0:-1],dataset[:,-1]data=Data(X,y,name="my-dataset")2. Next, scale your featuresYou should confirm that your dataset is scaled and normalized# MinMaxScalerdata.X,scaler=data.scale(data.X,method="MinMaxScaler",feature_range=(0,1))# StandardScalerdata.X,scaler=data.scale(data.X,method="StandardScaler")# MaxAbsScalerdata.X,scaler=data.scale(data.X,method="MaxAbsScaler")# RobustScalerdata.X,scaler=data.scale(data.X,method="RobustScaler")# Normalizerdata.X,scaler=data.scale(data.X,method="Normalizer",norm="l2")# "l1" or "l2" or "max"3. Next, select Metaheuristic Algorithm, Its parameters, list of objectives, and list of performance metricslist_optimizer=["BaseFBIO","OriginalGWO","OriginalSMA"]list_paras=[{"name":"FBIO","epoch":10,"pop_size":30},{"name":"GWO","epoch":10,"pop_size":30},{"name":"SMA","epoch":10,"pop_size":30}]list_obj=["SI","RSI"]list_metric=["BHI","DBI","DI","CHI","SSEI","NMIS","HS","CS","VMS","HGS"]You can check all supported metaheuristic algorithms from:https://github.com/thieu1995/mealpy.
All supported clustering objectives and metrics from:https://github.com/thieu1995/permetrics.If you don't want to read the documents, you can print out all supported information by:frommetaclusterimportMetaCluster# Get all supported methods and print them outMetaCluster.get_support(name="all")4. Next, create an instance of MetaCluster class and run it.model=MetaCluster(list_optimizer=list_optimizer,list_paras=list_paras,list_obj=list_obj,n_trials=3,seed=10)model.execute(data=data,cluster_finder="elbow",list_metric=list_metric,save_path="history",verbose=False)model.save_boxplots()model.save_convergences()As you can see, you can define different datasets and using the same model to run it.
Remember to set the name to your dataset, because the folder that hold your results is the name of your dataset.
More examples can be foundhereSupportOfficial links (questions, problems)Official source code repo:https://github.com/thieu1995/metaclusterOfficial document:https://metacluster.readthedocs.io/Download releases:https://pypi.org/project/metacluster/Issue tracker:https://github.com/thieu1995/metacluster/issuesNotable changes log:https://github.com/thieu1995/metacluster/blob/master/ChangeLog.mdOfficial chat group:https://t.me/+fRVCJGuGJg1mNDg1This project also related to our another projects which are optimization and machine learning. Check it here:https://github.com/thieu1995/metaheuristicshttps://github.com/thieu1995/mealpyhttps://github.com/thieu1995/mafesehttps://github.com/thieu1995/pfevaluatorhttps://github.com/thieu1995/opfunuhttps://github.com/thieu1995/enoppyhttps://github.com/thieu1995/permetricshttps://github.com/aiir-teamCitation RequestPlease include these citations if you plan to use this library:@software{van_thieu_nguyen_2023_8220709,
  author       = {Nguyen Van Thieu},
  title        = {MetaCluster: An Open-Source Python Library for Metaheuristic-based Clustering Problems},
  month        = aug,
  year         = 2023,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.8214539},
  url          = {https://github.com/thieu1995/metacluster}
}

@article{van2023mealpy,
  title={MEALPY: An open-source library for latest meta-heuristic algorithms in Python},
  author={Van Thieu, Nguyen and Mirjalili, Seyedali},
  journal={Journal of Systems Architecture},
  year={2023},
  publisher={Elsevier},
  doi={10.1016/j.sysarc.2023.102871}
}Supported links1. https://jtemporal.com/kmeans-and-elbow-method/
2. https://medium.com/@masarudheena/4-best-ways-to-find-optimal-number-of-clusters-for-clustering-with-python-code-706199fa957c
3. https://github.com/minddrummer/gap/blob/master/gap/gap.py
4. https://www.tandfonline.com/doi/pdf/10.1080/03610927408827101
5. https://doi.org/10.1016/j.engappai.2018.03.013
6. https://github.com/tirthajyoti/Machine-Learning-with-Python/blob/master/Clustering-Dimensionality-Reduction/Clustering_metrics.ipynb
7. https://elki-project.github.io/
8. https://sci2s.ugr.es/keel/index.php
9. https://archive.ics.uci.edu/datasets
10. https://python-charts.com/distribution/box-plot-plotly/
11. https://plotly.com/python/box-plots/?_ga=2.50659434.2126348639.1688086416-114197406.1688086416#box-plot-styling-mean--standard-deviation