Search is not available for this dataset
text
stringlengths
75
104k
def __update_centers(self): """! @brief Calculate centers of clusters in line with contained objects. @return (numpy.array) Updated centers. """ dimension = self.__pointer_data.shape[1] centers = numpy.zeros((len(self.__clusters), dimen...
def __calculate_total_wce(self): """! @brief Calculate total within cluster errors that is depend on metric that was chosen for K-Means algorithm. """ dataset_differences = self.__calculate_dataset_difference(len(self.__clusters)) self.__total_wce = 0 for inde...
def __calculate_dataset_difference(self, amount_clusters): """! @brief Calculate distance from each point to each cluster center. """ dataset_differences = numpy.zeros((amount_clusters, len(self.__pointer_data))) for index_center in range(amount_clusters): if ...
def __calculate_changes(self, updated_centers): """! @brief Calculates changes estimation between previous and current iteration using centers for that purpose. @param[in] updated_centers (array_like): New cluster centers. @return (float) Maximum changes between centers. ...
def initialize(self, **kwargs): """! @brief Generates random centers in line with input parameters. @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'return_index'). <b>Keyword Args:</b><br> - return_index (bool): If True then returns indexes of points...
def __create_center(self, return_index): """! @brief Generates and returns random center. @param[in] return_index (bool): If True then returns index of point from input data instead of point itself. """ random_index_point = random.randint(0, len(self.__data[0])) ...
def __check_parameters(self): """! @brief Checks input parameters of the algorithm and if something wrong then corresponding exception is thrown. """ if (self.__amount <= 0) or (self.__amount > len(self.__data)): raise AttributeError("Amount of cluster centers '" + str(self....
def __get_next_center(self, centers, return_index): """! @brief Calculates the next center for the data. @param[in] centers (array_like): Current initialized centers. @param[in] return_index (bool): If True then return center's index instead of point. @return (array_like) Next ...
def __get_initial_center(self, return_index): """! @brief Choose randomly first center. @param[in] return_index (bool): If True then return center's index instead of point. @return (array_like) First center.<br> (uint) Index of first center. """ index_...
def __calculate_probabilities(self, distances): """! @brief Calculates cumulative probabilities of being center of each point. @param[in] distances (array_like): Distances from each point to closest center. @return (array_like) Cumulative probabilities of being center of each point. ...
def __get_probable_center(self, distances, probabilities): """! @brief Calculates the next probable center considering amount candidates. @param[in] distances (array_like): Distances from each point to closest center. @param[in] probabilities (array_like): Cumulative probabilities of be...
def initialize(self, **kwargs): """! @brief Calculates initial centers using K-Means++ method. @param[in] **kwargs: Arbitrary keyword arguments (available arguments: 'return_index'). <b>Keyword Args:</b><br> - return_index (bool): If True then returns indexes of points from...
def twenty_five_neurons_mix_stimulated(): "Object allocation" "If M = 0 then only object will be allocated" params = pcnn_parameters(); params.AF = 0.1; params.AL = 0.0; params.AT = 0.7; params.VF = 1.0; params.VL = 1.0; params.VT = 10.0; params.M = 0.0; ...
def hundred_neurons_mix_stimulated(): "Allocate several clusters: the first contains borders (indexes of oscillators) and the second objects (indexes of oscillators)" params = pcnn_parameters(); params.AF = 0.1; params.AL = 0.1; params.AT = 0.8; params.VF = 1.0; params.VL = 1.0;...
def __get_canonical_separate(self, input_separate): """! @brief Return unified representation of separation value. @details It represents list whose size is equal to amount of dynamics, where index of dynamic will show where it should be displayed. @param[in] inp...
def set_canvas_properties(self, canvas, x_title=None, y_title=None, x_lim=None, y_lim=None, x_labels=True, y_labels=True): """! @brief Set properties for specified canvas. @param[in] canvas (uint): Index of canvas whose properties should changed. @param[in] x_title (string): Title ...
def append_dynamic(self, t, dynamic, canvas=0, color='blue'): """! @brief Append single dynamic to specified canvas (by default to the first with index '0'). @param[in] t (list): Time points that corresponds to dynamic values and considered on a X axis. @param[in] dynamic (list): V...
def append_dynamics(self, t, dynamics, canvas=0, separate=False, color='blue'): """! @brief Append several dynamics to canvas or canvases (defined by 'canvas' and 'separate' arguments). @param[in] t (list): Time points that corresponds to dynamic values and considered on a X axis. ...
def show(self, axis=None, display=True): """! @brief Draw and show output dynamics. @param[in] axis (axis): If is not 'None' then user specified axis is used to display output dynamic. @param[in] display (bool): Whether output dynamic should be displayed or not, if not, then user ...
def output(self): """! @brief (list) Returns oscillato outputs during simulation. """ if self.__ccore_pcnn_dynamic_pointer is not None: return wrapper.pcnn_dynamic_get_output(self.__ccore_pcnn_dynamic_pointer) return self.__dynamic
def time(self): """! @brief (list) Returns sampling times when dynamic is measured during simulation. """ if self.__ccore_pcnn_dynamic_pointer is not None: return wrapper.pcnn_dynamic_get_time(self.__ccore_pcnn_dynamic_pointer) return list(ra...
def allocate_sync_ensembles(self): """! @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @return (list) Grours (lists) of indexes of synchronous oscillators. ...
def allocate_spike_ensembles(self): """! @brief Analyses output dynamic of network and allocates spikes on each iteration as a list of indexes of oscillators. @details Each allocated spike ensemble represents list of indexes of oscillators whose output is active. @return (l...
def allocate_time_signal(self): """! @brief Analyses output dynamic and calculates time signal (signal vector information) of network output. @return (list) Time signal of network output. """ if self.__ccore_pcnn_dynamic_pointer is not None: ...
def show_time_signal(pcnn_output_dynamic): """! @brief Shows time signal (signal vector information) using network dynamic during simulation. @param[in] pcnn_output_dynamic (pcnn_dynamic): Output dynamic of the pulse-coupled neural network. """ ...
def show_output_dynamic(pcnn_output_dynamic, separate_representation = False): """! @brief Shows output dynamic (output of each oscillator) during simulation. @param[in] pcnn_output_dynamic (pcnn_dynamic): Output dynamic of the pulse-coupled neural network. @param[in] separ...
def animate_spike_ensembles(pcnn_output_dynamic, image_size): """! @brief Shows animation of output dynamic (output of each oscillator) during simulation. @param[in] pcnn_output_dynamic (pcnn_dynamic): Output dynamic of the pulse-coupled neural network. @param[in] image_siz...
def simulate(self, steps, stimulus): """! @brief Performs static simulation of pulse coupled neural network using. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] stimulus (list): Stimulus for oscillators, number of stimulus should be equa...
def _calculate_states(self, stimulus): """! @brief Calculates states of oscillators in the network for current step and stored them except outputs of oscillators. @param[in] stimulus (list): Stimulus for oscillators, number of stimulus should be equal to number of oscillators. ...
def size(self): """! @brief Return size of self-organized map that is defined by total number of neurons. @return (uint) Size of self-organized map (number of neurons). """ if self.__ccore_som_pointer is not None: self._size = wrapper.som_g...
def weights(self): """! @brief Return weight of each neuron. @return (list) Weights of each neuron. """ if self.__ccore_som_pointer is not None: self._weights = wrapper.som_get_weights(self.__ccore_som_pointer) return sel...
def awards(self): """! @brief Return amount of captured objects by each neuron after training. @return (list) Amount of captured objects by each neuron. @see train() """ if self.__ccore_som_pointer is not None: self._award = wrap...
def capture_objects(self): """! @brief Returns indexes of captured objects by each neuron. @details For example, network with size 2x2 has been trained on 5 sample, we neuron #1 has won one object with index '1', neuron #2 - objects with indexes '0', '3', '4', neuron #3 - n...
def __initialize_locations(self, rows, cols): """! @brief Initialize locations (coordinates in SOM grid) of each neurons in the map. @param[in] rows (uint): Number of neurons in the column (number of rows). @param[in] cols (uint): Number of neurons in the row (number of col...
def __initialize_distances(self, size, location): """! @brief Initialize distance matrix in SOM grid. @param[in] size (uint): Amount of neurons in the network. @param[in] location (list): List of coordinates of each neuron in the network. @return (list) D...
def _create_initial_weights(self, init_type): """! @brief Creates initial weights for neurons in line with the specified initialization. @param[in] init_type (type_init): Type of initialization of initial neuron weights (random, random in center of the input data, random distributed...
def _create_connections(self, conn_type): """! @brief Create connections in line with input rule (grid four, grid eight, honeycomb, function neighbour). @param[in] conn_type (type_conn): Type of connection between oscillators in the network. """ ...
def _competition(self, x): """! @brief Calculates neuron winner (distance, neuron index). @param[in] x (list): Input pattern from the input data set, for example it can be coordinates of point. @return (uint) Returns index of neuron that is winner. ...
def _adaptation(self, index, x): """! @brief Change weight of neurons in line with won neuron. @param[in] index (uint): Index of neuron-winner. @param[in] x (list): Input pattern from the input data set. """ dimension = len(self._weight...
def train(self, data, epochs, autostop=False): """! @brief Trains self-organized feature map (SOM). @param[in] data (list): Input data - list of points where each point is represented by list of features, for example coordinates. @param[in] epochs (uint): Number of epochs for train...
def simulate(self, input_pattern): """! @brief Processes input pattern (no learining) and returns index of neuron-winner. Using index of neuron winner catched object can be obtained using property capture_objects. @param[in] input_pattern (list): Input pattern...
def _get_maximal_adaptation(self, previous_weights): """! @brief Calculates maximum changes of weight in line with comparison between previous weights and current weights. @param[in] previous_weights (list): Weights from the previous step of learning process. @ret...
def get_winner_number(self): """! @brief Calculates number of winner at the last step of learning process. @return (uint) Number of winner. """ if self.__ccore_som_pointer is not None: self._award = wrapper.som_get_awards(self.__cco...
def show_distance_matrix(self): """! @brief Shows gray visualization of U-matrix (distance matrix). @see get_distance_matrix() """ distance_matrix = self.get_distance_matrix() plt.imshow(distance_matrix, cmap = plt.get_cmap('hot'), inte...
def get_distance_matrix(self): """! @brief Calculates distance matrix (U-matrix). @details The U-Matrix visualizes based on the distance in input space between a weight vector and its neighbors on map. @return (list) Distance matrix (U-matrix). @see show_...
def show_density_matrix(self, surface_divider = 20.0): """! @brief Show density matrix (P-matrix) using kernel density estimation. @param[in] surface_divider (double): Divider in each dimension that affect radius for density measurement. @see show_distance_matrix(...
def get_density_matrix(self, surface_divider = 20.0): """! @brief Calculates density matrix (P-Matrix). @param[in] surface_divider (double): Divider in each dimension that affect radius for density measurement. @return (list) Density matrix (P-Matrix). ...
def show_winner_matrix(self): """! @brief Show winner matrix where each element corresponds to neuron and value represents amount of won objects from input dataspace at the last training iteration. @see show_distance_matrix() """ ...
def show_network(self, awards = False, belongs = False, coupling = True, dataset = True, marker_type = 'o'): """! @brief Shows neurons in the dimension of data. @param[in] awards (bool): If True - displays how many objects won each neuron. @param[in] belongs (bool): If True...
def calculate_sync_order(oscillator_phases): """! @brief Calculates level of global synchronization (order parameter) for input phases. @details This parameter is tend 1.0 when the oscillatory network close to global synchronization and it tend to 0.0 when desynchronizatio...
def calculate_local_sync_order(oscillator_phases, oscillatory_network): """! @brief Calculates level of local synchorization (local order parameter) for input phases for the specified network. @details This parameter is tend 1.0 when the oscillatory network close to local synchronization and ...
def output(self): """! @brief (list) Returns output dynamic of the Sync network (phase coordinates of each oscillator in the network) during simulation. """ if ( (self._ccore_sync_dynamic_pointer is not None) and ( (self._dynamic is None) or (len(self._dynamic) == 0) ) ): ...
def time(self): """! @brief (list) Returns sampling times when dynamic is measured during simulation. """ if ( (self._ccore_sync_dynamic_pointer is not None) and ( (self._time is None) or (len(self._time) == 0) ) ): self._time = wrapper.sync_dynamic_get_time(se...
def allocate_sync_ensembles(self, tolerance = 0.01, indexes = None, iteration = None): """! @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @param[in] tolerance (double): Maximum error...
def allocate_phase_matrix(self, grid_width = None, grid_height = None, iteration = None): """! @brief Returns 2D matrix of phase values of oscillators at the specified iteration of simulation. @details User should ensure correct matrix sizes in line with following expression grid_width x grid...
def allocate_correlation_matrix(self, iteration = None): """! @brief Allocate correlation matrix between oscillators at the specified step of simulation. @param[in] iteration (uint): Number of iteration of simulation for which correlation matrix should be allocated. ...
def calculate_order_parameter(self, start_iteration = None, stop_iteration = None): """! @brief Calculates level of global synchorization (order parameter). @details This parameter is tend 1.0 when the oscillatory network close to global synchronization and it tend to 0.0 when ...
def calculate_local_order_parameter(self, oscillatory_network, start_iteration = None, stop_iteration = None): """! @brief Calculates local order parameter. @details Local order parameter or so-called level of local or partial synchronization is calculated by following expression: ...
def __get_start_stop_iterations(self, start_iteration, stop_iteration): """! @brief Aplly rules for start_iteration and stop_iteration parameters. @param[in] start_iteration (uint): The first iteration that is used for calculation. @param[in] stop_iteration (uint): The last iterati...
def show_output_dynamic(sync_output_dynamic): """! @brief Shows output dynamic (output of each oscillator) during simulation. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network. @see show_output_dynamics """ ...
def show_correlation_matrix(sync_output_dynamic, iteration = None): """! @brief Shows correlation matrix between oscillators at the specified iteration. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network. @param[in] iteration (uint): Number of...
def show_phase_matrix(sync_output_dynamic, grid_width = None, grid_height = None, iteration = None): """! @brief Shows 2D matrix of phase values of oscillators at the specified iteration. @details User should ensure correct matrix sizes in line with following expression grid_width x grid_heig...
def show_order_parameter(sync_output_dynamic, start_iteration = None, stop_iteration = None): """! @brief Shows evolution of order parameter (level of global synchronization in the network). @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network whose evol...
def show_local_order_parameter(sync_output_dynamic, oscillatory_network, start_iteration = None, stop_iteration = None): """! @brief Shows evolution of local order parameter (level of local synchronization in the network). @param[in] sync_output_dynamic (sync_dynamic): Output dynami...
def animate_output_dynamic(sync_output_dynamic, animation_velocity = 75, save_movie = None): """! @brief Shows animation of output dynamic (output of each oscillator) during simulation on a circle from [0; 2pi]. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sy...
def animate_correlation_matrix(sync_output_dynamic, animation_velocity = 75, colormap = 'cool', save_movie = None): """! @brief Shows animation of correlation matrix between oscillators during simulation. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync netw...
def animate_phase_matrix(sync_output_dynamic, grid_width = None, grid_height = None, animation_velocity = 75, colormap = 'jet', save_movie = None): """! @brief Shows animation of phase matrix between oscillators during simulation on 2D stage. @details If grid_width or grid_height are not spec...
def __get_start_stop_iterations(sync_output_dynamic, start_iteration, stop_iteration): """! @brief Apply rule of preparation for start iteration and stop iteration values. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync network. @param[in] start_it...
def animate(sync_output_dynamic, title = None, save_movie = None): """! @brief Shows animation of phase coordinates and animation of correlation matrix together for the Sync dynamic output on the same figure. @param[in] sync_output_dynamic (sync_dynamic): Output dynamic of the Sync ...
def sync_order(self): """! @brief Calculates current level of global synchorization (order parameter) in the network. @details This parameter is tend 1.0 when the oscillatory network close to global synchronization and it tend to 0.0 when desynchronization is observed in t...
def sync_local_order(self): """! @brief Calculates current level of local (partial) synchronization in the network. @return (double) Level of local (partial) synchronization. @see sync_order() """ if (self._ccore_network_point...
def _phase_kuramoto(self, teta, t, argv): """! @brief Returns result of phase calculation for specified oscillator in the network. @param[in] teta (double): Phase of the oscillator that is differentiated. @param[in] t (double): Current time of simulation. @param[in...
def simulate(self, steps, time, solution = solve_type.FAST, collect_dynamic = True): """! @brief Performs static simulation of Sync oscillatory network. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] time (double): Time of simulation. ...
def simulate_dynamic(self, order = 0.998, solution = solve_type.FAST, collect_dynamic = False, step = 0.1, int_step = 0.01, threshold_changes = 0.0000001): """! @brief Performs dynamic simulation of the network until stop condition is not reached. Stop condition is defined by input argument 'order'. ...
def simulate_static(self, steps, time, solution = solve_type.FAST, collect_dynamic = False): """! @brief Performs static simulation of oscillatory network. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] time (double): Time of simulation. ...
def _calculate_phases(self, solution, t, step, int_step): """! @brief Calculates new phases for oscillators in the network in line with current step. @param[in] solution (solve_type): Type solver of the differential equation. @param[in] t (double): Time of simulation. ...
def _phase_normalization(self, teta): """! @brief Normalization of phase of oscillator that should be placed between [0; 2 * pi]. @param[in] teta (double): phase of oscillator. @return (double) Normalized phase. """ norm_teta = teta; ...
def get_neighbors(self, index): """! @brief Finds neighbors of the oscillator with specified index. @param[in] index (uint): index of oscillator for which neighbors should be found in the network. @return (list) Indexes of neighbors of the specified oscillator. ...
def has_connection(self, i, j): """! @brief Returns True if there is connection between i and j oscillators and False - if connection doesn't exist. @param[in] i (uint): index of an oscillator in the network. @param[in] j (uint): index of an oscillator in the network. ...
def process(self): """! @brief Performs cluster analysis in line with rules of K-Medoids algorithm. @return (kmedoids) Returns itself (K-Medoids instance). @remark Results of clustering can be obtained using corresponding get methods. @see get_clusters() ...
def __create_distance_calculator(self): """! @brief Creates distance calculator in line with algorithms parameters. @return (callable) Distance calculator. """ if self.__data_type == 'points': return lambda index1, index2: self.__metric(self.__pointer_data[i...
def __update_clusters(self): """! @brief Calculate distance to each point from the each cluster. @details Nearest points are captured by according clusters and as a result clusters are updated. @return (list) updated clusters as list of clusters where each cluster contains...
def __update_medoids(self): """! @brief Find medoids of clusters in line with contained objects. @return (list) list of medoids for current number of clusters. """ medoid_indexes = [-1] * len(self.__clusters) for index in range(len(se...
def process(self, collect_dynamic = False, order = 0.999): """! @brief Performs simulation of the oscillatory network. @param[in] collect_dynamic (bool): If True - returns whole dynamic of oscillatory network, otherwise returns only last values of dynamics. @param[in] order...
def __create_sync_layer(self, weights): """! @brief Creates second layer of the network. @param[in] weights (list): List of weights of SOM neurons. @return (syncnet) Second layer of the network. """ sync_layer = syncnet(weights, 0.0, in...
def __has_object_connection(self, oscillator_index1, oscillator_index2): """! @brief Searches for pair of objects that are encoded by specified neurons and that are connected in line with connectivity radius. @param[in] oscillator_index1 (uint): Index of the first oscillator in the ...
def get_som_clusters(self): """! @brief Returns clusters with SOM neurons that encode input features in line with result of synchronization in the second (Sync) layer. @return (list) List of clusters that are represented by lists of indexes of neurons that encode input data. ...
def get_clusters(self, eps = 0.1): """! @brief Returns clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @param[in] eps (double): Maximum error for allocation of synchronous ensemble oscillators. ...
def __process_by_ccore(self): """! @brief Performs cluster analysis using CCORE (C/C++ part of pyclustering library). """ cure_data_pointer = wrapper.cure_algorithm(self.__pointer_data, self.__number_cluster, self.__number_represe...
def __process_by_python(self): """! @brief Performs cluster analysis using python code. """ self.__create_queue() # queue self.__create_kdtree() # create k-d tree while len(self.__queue) > self.__number_cluster: cluster1 = self.__queue[0] # clust...
def __prepare_data_points(self, sample): """! @brief Prepare data points for clustering. @details In case of numpy.array there are a lot of overloaded basic operators, such as __contains__, __eq__. @return (list) Returns sample in list format. """ if isinstance(...
def __validate_arguments(self): """! @brief Check input arguments of BANG algorithm and if one of them is not correct then appropriate exception is thrown. """ if len(self.__pointer_data) == 0: raise ValueError("Empty input data. Data should contain ...
def __insert_cluster(self, cluster): """! @brief Insert cluster to the list (sorted queue) in line with sequence order (distance). @param[in] cluster (cure_cluster): Cluster that should be inserted. """ for index in range(len(self.__queue)): ...
def __relocate_cluster(self, cluster): """! @brief Relocate cluster in list in line with distance order. @param[in] cluster (cure_cluster): Cluster that should be relocated in line with order. """ self.__queue.remove(cluster) self.__ins...
def __closest_cluster(self, cluster, distance): """! @brief Find closest cluster to the specified cluster in line with distance. @param[in] cluster (cure_cluster): Cluster for which nearest cluster should be found. @param[in] distance (double): Closest distance to the previ...
def __insert_represented_points(self, cluster): """! @brief Insert representation points to the k-d tree. @param[in] cluster (cure_cluster): Cluster whose representation points should be inserted. """ for point in cluster.rep: self....
def __delete_represented_points(self, cluster): """! @brief Remove representation points of clusters from the k-d tree @param[in] cluster (cure_cluster): Cluster whose representation points should be removed. """ for point in cluster.rep: ...
def __merge_clusters(self, cluster1, cluster2): """! @brief Merges two clusters and returns new merged cluster. Representation points and mean points are calculated for the new cluster. @param[in] cluster1 (cure_cluster): Cluster that should be merged. @param[in] cluster2 (...
def __create_queue(self): """! @brief Create queue of sorted clusters by distance between them, where first cluster has the nearest neighbor. At the first iteration each cluster contains only one point. @param[in] data (list): Input data that is presented as list of points (objects)...
def __create_kdtree(self): """! @brief Create k-d tree in line with created clusters. At the first iteration contains all points from the input data set. @return (kdtree) k-d tree that consist of representative points of CURE clusters. """ self....