pyclustering  0.10.1
pyclustring is a Python, C++ data mining library.
pyclustering.cluster.bsas.bsas Class Reference

Class represents BSAS clustering algorithm - basic sequential algorithmic scheme. More...

+ Inheritance diagram for pyclustering.cluster.bsas.bsas:

Public Member Functions

def __init__ (self, data, maximum_clusters, threshold, ccore=True, **kwargs)
 Creates classical BSAS algorithm. More...
 
def process (self)
 Performs cluster analysis in line with rules of BSAS algorithm. More...
 
def get_clusters (self)
 Returns list of allocated clusters, each cluster contains indexes of objects in list of data. More...
 
def get_representatives (self)
 Returns list of representatives of allocated clusters. More...
 
def get_cluster_encoding (self)
 Returns clustering result representation type that indicate how clusters are encoded. More...
 

Detailed Description

Class represents BSAS clustering algorithm - basic sequential algorithmic scheme.

Algorithm has two mandatory parameters: maximum allowable number of clusters and threshold of dissimilarity or in other words maximum distance between points. Distance metric also can be specified using 'metric' parameters, by default 'Manhattan' distance is used. BSAS using following rule for updating cluster representative:

\[ \vec{m}_{C_{k}}^{new}=\frac{ \left ( n_{C_{k}^{new}} - 1 \right )\vec{m}_{C_{k}}^{old} + \vec{x} }{n_{C_{k}^{new}}} \]

Clustering results of this algorithm depends on objects order in input data.

Example:

from pyclustering.cluster.bsas import bsas, bsas_visualizer
from pyclustering.utils import read_sample
from pyclustering.samples.definitions import SIMPLE_SAMPLES
# Read data sample from 'Simple02.data'.
sample = read_sample(SIMPLE_SAMPLES.SAMPLE_SIMPLE2)
# Prepare algorithm's parameters.
max_clusters = 3
threshold = 1.0
# Create instance of BSAS algorithm.
bsas_instance = bsas(sample, max_clusters, threshold)
bsas_instance.process()
# Get clustering results.
clusters = bsas_instance.get_clusters()
representatives = bsas_instance.get_representatives()
# Display results.
bsas_visualizer.show_clusters(sample, clusters, representatives)
See also
pyclustering.cluster.mbsas, pyclustering.cluster.ttsas

Definition at line 62 of file bsas.py.

Constructor & Destructor Documentation

◆ __init__()

def pyclustering.cluster.bsas.bsas.__init__ (   self,
  data,
  maximum_clusters,
  threshold,
  ccore = True,
**  kwargs 
)

Creates classical BSAS algorithm.

Parameters
[in]data(list): Input data that is presented as list of points (objects), each point should be represented by list or tuple.
[in]maximum_clustersMaximum allowable number of clusters that can be allocated during processing.
[in]thresholdThreshold of dissimilarity (maximum distance) between points.
[in]ccore(bool): If True than CCORE (C++ part of the library) will be used for solving.
[in]**kwargsArbitrary keyword arguments (available arguments: 'metric').

Keyword Args:

  • metric (distance_metric): Metric that is used for distance calculation between two points.

Reimplemented in pyclustering.cluster.ttsas.ttsas, and pyclustering.cluster.mbsas.mbsas.

Definition at line 105 of file bsas.py.

Member Function Documentation

◆ get_cluster_encoding()

def pyclustering.cluster.bsas.bsas.get_cluster_encoding (   self)

Returns clustering result representation type that indicate how clusters are encoded.

Returns
(type_encoding) Clustering result representation.
See also
get_clusters()

Definition at line 199 of file bsas.py.

◆ get_clusters()

def pyclustering.cluster.bsas.bsas.get_clusters (   self)

Returns list of allocated clusters, each cluster contains indexes of objects in list of data.

See also
process()
get_representatives()

Definition at line 177 of file bsas.py.

Referenced by pyclustering.samples.answer_reader.get_cluster_lengths(), and pyclustering.cluster.optics.optics.process().

◆ get_representatives()

def pyclustering.cluster.bsas.bsas.get_representatives (   self)

Returns list of representatives of allocated clusters.

See also
process()
get_clusters()

Definition at line 188 of file bsas.py.

◆ process()

def pyclustering.cluster.bsas.bsas.process (   self)

Performs cluster analysis in line with rules of BSAS algorithm.

Returns
(bsas) Returns itself (BSAS instance).
Remarks
Results of clustering can be obtained using corresponding get methods.
See also
get_clusters()
get_representatives()

Reimplemented in pyclustering.cluster.ttsas.ttsas, and pyclustering.cluster.mbsas.mbsas.

Definition at line 135 of file bsas.py.


The documentation for this class was generated from the following file:
pyclustering.cluster.bsas
Cluster analysis algorithm: BSAS (Basic Sequential Algorithmic Scheme).
Definition: bsas.py:1
pyclustering.utils
Utils that are used by modules of pyclustering.
Definition: __init__.py:1
pyclustering.utils.read_sample
def read_sample(filename)
Returns data sample from simple text file.
Definition: __init__.py:30