-
CF-Tree (
pyclustering.container.cftree
);
-
KD-Tree (
pyclustering.container.kdtree
);
Utils (
pyclustering.utils
) that can be used for analysis, visualization, etc.
Installation
The simplest way to install pyclustering library is to use pip:
pip3 install pyclustering
The library can be compiled and manually installed on Linux or MacOS machine wherever you want:
# extract content of the pyclustering library...
# compile CCORE library (core of the pyclustering library).
cd pyclustering/ccore
make ccore_x64 # if platform is x86_64 (64-bit)
# make ccore_x86 # if platform is x86 (32-bit)
# return to parent folder of the pyclustering library
cd ../
# add current folder to python path
PYTHONPATH=`pwd`
export PYTHONPATH=${PYTHONPATH}
Cite the Library
If you are using pyclustering library in a scientific paper, please, cite the library:
Novikov, A., 2019. PyClustering: Data Mining Library. Journal of Open Source Software, 4(36), p.1230. Available at:
http://dx.doi.org/10.21105/joss.01230
.
BibTeX entry:
@article{Novikov2019,
doi = {10.21105/joss.01230},
url = {https://doi.org/10.21105/joss.01230},
year = 2019,
month = {apr},
publisher = {The Open Journal},
volume = {4},
number = {36},
pages = {1230},
author = {Andrei Novikov},
title = {{PyClustering}: Data Mining Library},
journal = {Journal of Open Source Software}
}
Examples
The library provides intuitive and friendly interface. Here is an example how to perform cluster analysis using BIRCH algorithm:
from
pyclustering.samples.definitions
import
FCPS_SAMPLES
birch_instance = birch(sample, 3)
birch_instance.process()
clusters = birch_instance.get_clusters()
visualizer = cluster_visualizer()
visualizer.append_clusters(clusters, sample)
visualizer.show()
Here is an how to perform cluster analysis using well-known K-Means algorithm:
from
pyclustering.samples.definitions
import
FCPS_SAMPLES
sample =
read_sample
(FCPS_SAMPLES.SAMPLE_TWO_DIAMONDS)
initial_centers = kmeans_plusplus_initializer(sample, 2).initialize()
kmeans_instance = kmeans(sample, initial_centers)
kmeans_instance.process()
clusters = kmeans_instance.get_clusters()
final_centers = kmeans_instance.get_centers()
kmeans_visualizer.show_clusters(sample, clusters, final_centers)
An example cluster analysis (that is performed by DBSCAN algorithm) for FCPS samples and visualization of results:
An example of Hodgkin-Huxley oscillatory network simulation with 6 oscillators. The first two oscillators have the same stimulus, as well as the third and fourth oscillators and the last two. Thus three synchronous ensembles are expected after simulation.
params = hhn_parameters()
params.deltah = 400
net = hhn_network(6, [0, 0, 25, 25, 47, 47], params)
(t, dyn_peripheral, dyn_central) = net.simulate(2400, 600)
amount_canvases = 6 + 2
visualizer = dynamic_visualizer(amount_canvases, x_title=
"Time"
, y_title=
"V"
, y_labels=
False
)
visualizer.append_dynamics(t, dyn_peripheral, 0,
True
)
visualizer.append_dynamics(t, dyn_central, amount_canvases - 2,
True
)
visualizer.show()