Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@param[in] type_conn (conn_type): Type of connection between oscillators in the network.
@param[in] type_conn_represent (conn_represent): Internal representation of connection in the network: matrix or list.
@param[in] ccore (bool): If True then all interaction with object will be performed via CCORE library (C++ implementation of pyclustering).
"""
self._params = None; # parameters of the network
self.__ccore_legion_pointer = None;
self._params = parameters;
# set parameters of the network
if (self._params is None):
self._params = legion_parameters();
if ( (ccore is True) and ccore_library.workable() ):
self.__ccore_legion_pointer = wrapper.legion_create(num_osc, type_conn, self._params);
else:
super().__init__(num_osc, type_conn, type_conn_represent);
# initial states
self._excitatory = [ random.random() for _ in range(self._num_osc) ];
self._inhibitory = [0.0] * self._num_osc;
self._potential = [0.0] * self._num_osc;
self._coupling_term = None; # coupling term of each oscillator
self._global_inhibitor = 0; # value of global inhibitory
self._stimulus = None; # stimulus of each oscillator
self._dynamic_coupling = None; # dynamic connection between oscillators
self._coupling_term = [0.0] * self._num_osc;
@param[in] number_clusters (uint): Defines number of clusters that should be allocated from the input data set.
@param[in] threshold (double): Value that defines degree of normalization that influences on choice of clusters for merging during processing.
@param[in] ccore (bool): Defines should be CCORE (C++ pyclustering library) used instead of Python code or not.
"""
self.__pointer_data = data
self.__eps = eps
self.__number_clusters = number_clusters
self.__threshold = threshold
self.__clusters = None
self.__ccore = ccore
if self.__ccore:
self.__ccore = ccore_library.workable()
self.__verify_arguments()
self.__degree_normalization = 1.0 + 2.0 * ((1.0 - threshold) / (1.0 + threshold))
self.__adjacency_matrix = None
self.__create_adjacency_matrix()
"""
self.__data = data
self.__clusters = []
self.__centers = initial_centers
self.__membership = []
self.__tolerance = kwargs.get('tolerance', 0.001)
self.__itermax = kwargs.get('itermax', 200)
self.__m = kwargs.get('m', 2)
self.__degree = 2.0 / (self.__m - 1)
self.__ccore = kwargs.get('ccore', True)
if self.__ccore is True:
self.__ccore = ccore_library.workable()
self.__verify_arguments()
self.__data = data
self.__kmin = kmin
self.__kmax = kmax
self.__algorithm = kwargs.get('algorithm', silhouette_ksearch_type.KMEANS)
self.__return_index = self.__algorithm == silhouette_ksearch_type.KMEDOIDS
self.__amount = -1
self.__score = -1.0
self.__scores = {}
self.__verify_arguments()
self.__ccore = kwargs.get('ccore', True)
if self.__ccore:
self.__ccore = ccore_library.workable()
@param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'ccore', 'initializer').
<b>Keyword Args:</b><br>
- ccore (bool): If True then CCORE (C++ implementation of pyclustering library) is used (by default True).
- initializer (callable): Center initializer that is used by K-Means algorithm (by default K-Means++).
"""
self.__initializer = kwargs.get('initializer', kmeans_plusplus_initializer)
self.__ccore = kwargs.get('ccore', True) or \
isinstance(self.__initializer, kmeans_plusplus_initializer) or \
isinstance(self.__initializer, random_center_initializer)
if self.__ccore:
self.__ccore = ccore_library.workable()
self.__data = data
self.__kmin = kmin
self.__kmax = kmax
self.__wce = []
self.__elbows = []
self.__kvalue = -1
self.__verify_arguments()
self.__centers = numpy.array(initial_centers)
self.__tolerance = tolerance
self.__total_wce = 0.0
self.__observer = kwargs.get('observer', None)
self.__metric = kwargs.get('metric', distance_metric(type_metric.EUCLIDEAN_SQUARE))
self.__itermax = kwargs.get('itermax', 100)
if self.__metric.get_type() != type_metric.USER_DEFINED:
self.__metric.enable_numpy_usage()
else:
self.__metric.disable_numpy_usage()
self.__ccore = ccore and self.__metric.get_type() != type_metric.USER_DEFINED
if self.__ccore is True:
self.__ccore = ccore_library.workable()
self.__verify_arguments()
@param[in] density_threshold (uint): Minimum number of points that should contain CLIQUE block to consider its
points as non-outliers.
@param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'ccore').
<b>Keyword Args:</b><br>
- ccore (bool): By default is True. If True then C++ implementation is used for cluster analysis, otherwise
Python implementation is used.
"""
self.__data = data
self.__amount_intervals = amount_intervals
self.__density_threshold = density_threshold
self.__ccore = kwargs.get('ccore', True)
if self.__ccore:
self.__ccore = ccore_library.workable()
self.__clusters = []
self.__noise = []
self.__cells = []
self.__cells_map = {}
self.__validate_arguments()
With larger 'repeat' values suggesting higher probability of finding global optimum.
"""
self.__data = data
self.__k_init = k_init
self.__clusters = []
self.__centers = []
self.__total_wce = 0.0
self.__ccore = ccore
self.__tolerance = kwargs.get('tolerance', 0.025)
self.__repeat = kwargs.get('repeat', 3)
if self.__ccore is True:
self.__ccore = ccore_library.workable()
self._verify_arguments()
"""!
@brief Constructor of oscillatory network is based on Kuramoto model.
@param[in] num_osc (uint): Number of oscillators in the network.
@param[in] weight (double): Coupling strength of the links between oscillators.
@param[in] frequency (double): Multiplier of internal frequency of the oscillators.
@param[in] type_conn (conn_type): Type of connection between oscillators in the network (all-to-all, grid, bidirectional list, etc.).
@param[in] representation (conn_represent): Internal representation of connection in the network: matrix or list.
@param[in] initial_phases (initial_type): Type of initialization of initial phases of oscillators (random, uniformly distributed, etc.).
@param[in] ccore (bool): If True simulation is performed by CCORE library (C++ implementation of pyclustering).
"""
self._ccore_network_pointer = None; # Pointer to CCORE Sync implementation of the network.
if ( (ccore is True) and ccore_library.workable() ):
self._ccore_network_pointer = wrapper.sync_create_network(num_osc, weight, frequency, type_conn, initial_phases);
self._num_osc = num_osc;
self._conn_represent = conn_represent.MATRIX;
else:
super().__init__(num_osc, type_conn, representation);
self._weight = weight;
self._phases = list();
self._freq = list();
random.seed();
for index in range(0, num_osc, 1):
if (initial_phases == initial_type.RANDOM_GAUSSIAN):
self._phases.append(random.random() * 2 * pi);
self.__clusters = []
if initial_centers is not None:
self.__centers = initial_centers[:]
else:
self.__centers = kmeans_plusplus_initializer(data, 2).initialize()
self.__kmax = kmax
self.__tolerance = tolerance
self.__criterion = criterion
self.__total_wce = 0.0
self.__repeat = kwargs.get('repeat', 1)
self.__ccore = ccore
if self.__ccore:
self.__ccore = ccore_library.workable()
self.__verify_arguments()