Search is not available for this dataset
text
stringlengths
75
104k
def read_graph(filename): """! @brief Read graph from file in GRPR format. @param[in] filename (string): Path to file with graph in GRPR format. @return (graph) Graph that is read from file. """ file = open(filename, 'r'); comments = ""; space_descr ...
def draw_graph(graph_instance, map_coloring = None): """! @brief Draw graph. @param[in] graph_instance (graph): Graph that should be drawn. @param[in] map_coloring (list): List of color indexes for each vertex. Size of this list should be equal to size of graph (number of vertices). ...
def process(self): """! @brief Performs cluster analysis in line with Fuzzy C-Means algorithm. @see get_clusters() @see get_centers() @see get_membership() """ if self.__ccore is True: self.__process_by_ccore() else: s...
def __process_by_ccore(self): """! @brief Performs cluster analysis using C/C++ implementation. """ result = wrapper.fcm_algorithm(self.__data, self.__centers, self.__m, self.__tolerance, self.__itermax) self.__clusters = result[wrapper.fcm_package_indexer.INDEX_CLUSTERS...
def __process_by_python(self): """! @brief Performs cluster analysis using Python implementation. """ self.__data = numpy.array(self.__data) self.__centers = numpy.array(self.__centers) self.__membership = numpy.zeros((len(self.__data), len(self.__centers))) ...
def __calculate_centers(self): """! @brief Calculate center using membership of each cluster. @return (list) Updated clusters as list of clusters. Each cluster contains indexes of objects from data. @return (numpy.array) Updated centers. """ dimension = self._...
def __update_membership(self): """! @brief Update membership for each point in line with current cluster centers. """ data_difference = numpy.zeros((len(self.__centers), len(self.__data))) for i in range(len(self.__centers)): data_difference[i] = numpy.sum(n...
def __calculate_changes(self, updated_centers): """! @brief Calculate changes between centers. @return (float) Maximum change between centers. """ changes = numpy.sum(numpy.square(self.__centers - updated_centers), axis=1).T return numpy.max(changes)
def collect_global_best(self, best_chromosome, best_fitness_function): """! @brief Stores the best chromosome and its fitness function's value. @param[in] best_chromosome (list): The best chromosome that were observed. @param[in] best_fitness_function (float): Fitness function v...
def collect_population_best(self, best_chromosome, best_fitness_function): """! @brief Stores the best chromosome for current specific iteration and its fitness function's value. @param[in] best_chromosome (list): The best chromosome on specific iteration. @param[in] best_fitnes...
def collect_mean(self, fitness_functions): """! @brief Stores average value of fitness function among chromosomes on specific iteration. @param[in] fitness_functions (float): Average value of fitness functions among chromosomes. """ if not self._need_mean_ff: ...
def show_evolution(observer, start_iteration = 0, stop_iteration=None, ax=None, display=True): """! @brief Displays evolution of fitness function for the best chromosome, for the current best chromosome and average value among all chromosomes. @param[in] observer (ga_obs...
def show_clusters(data, observer, marker='.', markersize=None): """! @brief Shows allocated clusters by the genetic algorithm. @param[in] data (list): Input data that was used for clustering process by the algorithm. @param[in] observer (ga_observer): Observer that was used for ...
def animate_cluster_allocation(data, observer, animation_velocity=75, movie_fps=5, save_movie=None): """! @brief Animate clustering process of genetic clustering algorithm. @details This method can be also used for rendering movie of clustering process and 'ffmpeg' is required for that purpuse. ...
def process(self): """! @brief Perform clustering procedure in line with rule of genetic clustering algorithm. @see get_clusters() """ # Initialize population chromosomes = self._init_population(self._count_clusters, len(self._data), self._chromosome_co...
def _select(chromosomes, data, count_clusters, select_coeff): """! @brief Performs selection procedure where new chromosomes are calculated. @param[in] chromosomes (numpy.array): Chromosomes """ # Calc centers centres = ga_math.get_centres(chromosomes,...
def _crossover(chromosomes): """! @brief Crossover procedure. """ # Get pairs to Crossover pairs_to_crossover = np.array(range(len(chromosomes))) # Set random pairs np.random.shuffle(pairs_to_crossover) # Index offset ( pairs_to_crossover split...
def _mutation(chromosomes, count_clusters, count_gen_for_mutation, coeff_mutation_count): """! @brief Mutation procedure. """ # Count gens in Chromosome count_gens = len(chromosomes[0]) # Get random chromosomes for mutation random_idx_chromosomes = np.a...
def _crossover_a_pair(chromosome_1, chromosome_2, mask): """! @brief Crossovers a pair of chromosomes. @param[in] chromosome_1 (numpy.array): The first chromosome for crossover. @param[in] chromosome_2 (numpy.array): The second chromosome for crossover. @param[in] mask (...
def _get_crossover_mask(mask_length): """! @brief Crossover mask to crossover a pair of chromosomes. @param[in] mask_length (uint): Length of the mask. """ # Initialize mask mask = np.zeros(mask_length) # Set a half of array to 1 mask[:...
def _init_population(count_clusters, count_data, chromosome_count): """! @brief Returns first population as a uniform random choice. @param[in] count_clusters (uint): Amount of clusters that should be allocated. @param[in] count_data (uint): Data size that is used for clustering...
def _get_best_chromosome(chromosomes, data, count_clusters): """! @brief Returns the current best chromosome. @param[in] chromosomes (list): Chromosomes that are used for searching. @param[in] data (list): Input data that is used for clustering process. @param[in] count_...
def _calc_fitness_function(centres, data, chromosomes): """! @brief Calculate fitness function values for chromosomes. @param[in] centres (list): Cluster centers. @param[in] data (list): Input data that is used for clustering process. @param[in] chromosomes (list): Chrom...
def get_distance(self, entry, type_measurement): """! @brief Calculates distance between two clusters in line with measurement type. @details In case of usage CENTROID_EUCLIDIAN_DISTANCE square euclidian distance will be returned. Square root should be taken from t...
def get_centroid(self): """! @brief Calculates centroid of cluster that is represented by the entry. @details It's calculated once when it's requested after the last changes. @return (list) Centroid of cluster that is represented by the entry. """ ...
def get_radius(self): """! @brief Calculates radius of cluster that is represented by the entry. @details It's calculated once when it's requested after the last changes. @return (double) Radius of cluster that is represented by the entry. """ ...
def get_diameter(self): """! @brief Calculates diameter of cluster that is represented by the entry. @details It's calculated once when it's requested after the last changes. @return (double) Diameter of cluster that is represented by the entry. """ ...
def __get_average_inter_cluster_distance(self, entry): """! @brief Calculates average inter cluster distance between current and specified clusters. @param[in] entry (cfentry): Clustering feature to which distance should be obtained. @return (double) Average inter...
def __get_average_intra_cluster_distance(self, entry): """! @brief Calculates average intra cluster distance between current and specified clusters. @param[in] entry (cfentry): Clustering feature to which distance should be obtained. @return (double) Average intra...
def __get_variance_increase_distance(self, entry): """! @brief Calculates variance increase distance between current and specified clusters. @param[in] entry (cfentry): Clustering feature to which distance should be obtained. @return (double) Variance increase dis...
def get_distance(self, node, type_measurement): """! @brief Calculates distance between nodes in line with specified type measurement. @param[in] node (cfnode): CF-node that is used for calculation distance to the current node. @param[in] type_measurement (measurement_type)...
def insert_successor(self, successor): """! @brief Insert successor to the node. @param[in] successor (cfnode): Successor for adding. """ self.feature += successor.feature; self.successors.append(successor); successor...
def remove_successor(self, successor): """! @brief Remove successor from the node. @param[in] successor (cfnode): Successor for removing. """ self.feature -= successor.feature; self.successors.append(successor); succe...
def merge(self, node): """! @brief Merge non-leaf node to the current. @param[in] node (non_leaf_node): Non-leaf node that should be merged with current. """ self.feature += node.feature; for child in node.successors: ...
def get_farthest_successors(self, type_measurement): """! @brief Find pair of farthest successors of the node in line with measurement type. @param[in] type_measurement (measurement_type): Measurement type that is used for obtaining farthest successors. @return (l...
def get_nearest_successors(self, type_measurement): """! @brief Find pair of nearest successors of the node in line with measurement type. @param[in] type_measurement (measurement_type): Measurement type that is used for obtaining nearest successors. @return (list...
def insert_entry(self, entry): """! @brief Insert new clustering feature to the leaf node. @param[in] entry (cfentry): Clustering feature. """ self.feature += entry; self.entries.append(entry);
def remove_entry(self, entry): """! @brief Remove clustering feature from the leaf node. @param[in] entry (cfentry): Clustering feature. """ self.feature -= entry; self.entries.remove(entry);
def merge(self, node): """! @brief Merge leaf node to the current. @param[in] node (leaf_node): Leaf node that should be merged with current. """ self.feature += node.feature; # Move entries from merged node for entry...
def get_farthest_entries(self, type_measurement): """! @brief Find pair of farthest entries of the node. @param[in] type_measurement (measurement_type): Measurement type that is used for obtaining farthest entries. @return (list) Pair of farthest entries of the no...
def get_nearest_index_entry(self, entry, type_measurement): """! @brief Find nearest index of nearest entry of node for the specified entry. @param[in] entry (cfentry): Entry that is used for calculation distance. @param[in] type_measurement (measurement_type): Measurement ...
def get_nearest_entry(self, entry, type_measurement): """! @brief Find nearest entry of node for the specified entry. @param[in] entry (cfentry): Entry that is used for calculation distance. @param[in] type_measurement (measurement_type): Measurement type that is used for o...
def get_level_nodes(self, level): """! @brief Traverses CF-tree to obtain nodes at the specified level. @param[in] level (uint): CF-tree level from that nodes should be returned. @return (list) List of CF-nodes that are located on the specified level of the CF-tre...
def __recursive_get_level_nodes(self, level, node): """! @brief Traverses CF-tree to obtain nodes at the specified level recursively. @param[in] level (uint): Current CF-tree level. @param[in] node (cfnode): CF-node from that traversing is performed. @ret...
def insert_cluster(self, cluster): """! @brief Insert cluster that is represented as list of points where each point is represented by list of coordinates. @details Clustering feature is created for that cluster and inserted to the tree. @param[in] cluster (list): Cluster t...
def insert(self, entry): """! @brief Insert clustering feature to the tree. @param[in] entry (cfentry): Clustering feature that should be inserted. """ if (self.__root is None): node = leaf_node(entry, None, [ entry ], None)...
def find_nearest_leaf(self, entry, search_node = None): """! @brief Search nearest leaf to the specified clustering feature. @param[in] entry (cfentry): Clustering feature. @param[in] search_node (cfnode): Node from that searching should be started, if None then search proc...
def __recursive_insert(self, entry, search_node): """! @brief Recursive insert of the entry to the tree. @details It performs all required procedures during insertion such as splitting, merging. @param[in] entry (cfentry): Clustering feature. @param[in] search_node...
def __insert_for_leaf_node(self, entry, search_node): """! @brief Recursive insert entry from leaf node to the tree. @param[in] entry (cfentry): Clustering feature. @param[in] search_node (cfnode): None-leaf node from that insertion should be started. @re...
def __insert_for_noneleaf_node(self, entry, search_node): """! @brief Recursive insert entry from none-leaf node to the tree. @param[in] entry (cfentry): Clustering feature. @param[in] search_node (cfnode): None-leaf node from that insertion should be started. ...
def __merge_nearest_successors(self, node): """! @brief Find nearest sucessors and merge them. @param[in] node (non_leaf_node): Node whose two nearest successors should be merged. @return (bool): True if merging has been successfully performed, otherwise False. ...
def __split_procedure(self, split_node): """! @brief Starts node splitting procedure in the CF-tree from the specify node. @param[in] split_node (cfnode): CF-tree node that should be splitted. """ if (split_node is self.__root): self.__root =...
def __split_nonleaf_node(self, node): """! @brief Performs splitting of the specified non-leaf node. @param[in] node (non_leaf_node): Non-leaf node that should be splitted. @return (list) New pair of non-leaf nodes [non_leaf_node1, non_leaf_node2]. ...
def __split_leaf_node(self, node): """! @brief Performs splitting of the specified leaf node. @param[in] node (leaf_node): Leaf node that should be splitted. @return (list) New pair of leaf nodes [leaf_node1, leaf_node2]. @warning Splitted node ...
def show_feature_destibution(self, data = None): """! @brief Shows feature distribution. @details Only features in 1D, 2D, 3D space can be visualized. @param[in] data (list): List of points that will be used for visualization, if it not specified than feature will be displa...
def process(self): """! @brief Performs cluster analysis in line with rules of agglomerative algorithm and similarity. @see get_clusters() """ if (self.__ccore is True): self.__clusters = wrapper.agglomerative_algorithm(self.__pointer_data, ...
def __merge_similar_clusters(self): """! @brief Merges the most similar clusters in line with link type. """ if (self.__similarity == type_link.AVERAGE_LINK): self.__merge_by_average_link(); elif (self.__similarity == type_link.CENTROID_LINK...
def __merge_by_average_link(self): """! @brief Merges the most similar clusters in line with average link type. """ minimum_average_distance = float('Inf'); for index_cluster1 in range(0, len(self.__clusters)): for index_cluster2 in range(in...
def __merge_by_centroid_link(self): """! @brief Merges the most similar clusters in line with centroid link type. """ minimum_centroid_distance = float('Inf'); indexes = None; for index1 in range(0, len(self.__centers)): for index2 i...
def __merge_by_complete_link(self): """! @brief Merges the most similar clusters in line with complete link type. """ minimum_complete_distance = float('Inf'); indexes = None; for index_cluster1 in range(0, len(self.__clusters)): for...
def __calculate_farthest_distance(self, index_cluster1, index_cluster2): """! @brief Finds two farthest objects in two specified clusters in terms and returns distance between them. @param[in] (uint) Index of the first cluster. @param[in] (uint) Index of the second cluster. ...
def __merge_by_signle_link(self): """! @brief Merges the most similar clusters in line with single link type. """ minimum_single_distance = float('Inf'); indexes = None; for index_cluster1 in range(0, len(self.__clusters)): for index...
def __calculate_nearest_distance(self, index_cluster1, index_cluster2): """! @brief Finds two nearest objects in two specified clusters and returns distance between them. @param[in] (uint) Index of the first cluster. @param[in] (uint) Index of the second cluster. ...
def __calculate_center(self, cluster): """! @brief Calculates new center. @return (list) New value of the center of the specified cluster. """ dimension = len(self.__pointer_data[cluster[0]]); center = [0] * dimension; for index_point i...
def som_create(rows, cols, conn_type, parameters): """! @brief Create of self-organized map using CCORE pyclustering library. @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 columns). @param[in] conn...
def som_load(som_pointer, weights, award, capture_objects): """! @brief Load dump of the network to SOM. @details Initialize SOM using existed weights, amount of captured objects by each neuron, captured objects by each neuron. Initialization is not performed if weights are empty. @...
def som_train(som_pointer, data, epochs, autostop): """! @brief Trains self-organized feature map (SOM) using CCORE pyclustering library. @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): Numb...
def som_simulate(som_pointer, pattern): """! @brief Processes input pattern (no learining) and returns index of neuron-winner. @details Using index of neuron winner catched object can be obtained using property capture_objects. @param[in] som_pointer (c_pointer): pointer to object of self-orga...
def som_get_winner_number(som_pointer): """! @brief Returns of number of winner at the last step of learning process. @param[in] som_pointer (c_pointer): pointer to object of self-organized map. """ ccore = ccore_library.get() ccore.som_get_winner_number.restype = c_size_...
def som_get_size(som_pointer): """! @brief Returns size of self-organized map (number of neurons). @param[in] som_pointer (c_pointer): pointer to object of self-organized map. """ ccore = ccore_library.get() ccore.som_get_size.restype = c_size_t return ccore.som_get_...
def som_get_capture_objects(som_pointer): """! @brief Returns list of indexes of captured objects by each neuron. @param[in] som_pointer (c_pointer): pointer to object of self-organized map. """ ccore = ccore_library.get() ccore.som_get_capture_objects.restype = POI...
def allocate_sync_ensembles(self, tolerance = 0.1, threshold_steps = 1): """! @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @param[in] tolerance (double): Maximum err...
def outputs(self, values): """! @brief Sets outputs of neurons. """ self._outputs = [val for val in values]; self._outputs_buffer = [val for val in values];
def _neuron_states(self, inputs, t, argv): """! @brief Returns new value of the neuron (oscillator). @param[in] inputs (list): Initial values (current) of the neuron - excitatory. @param[in] t (double): Current time of simulation. @param[in] argv (tuple): Extra arg...
def simulate_static(self, steps, time, solution = solve_type.RK4, collect_dynamic = False): """! @brief Performs static simulation of hysteresis oscillatory network. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] time (double): Time of si...
def _calculate_states(self, solution, t, step, int_step): """! @brief Calculates new states for neurons using differential calculus. Returns new states for neurons. @param[in] solution (solve_type): Type solver of the differential equation. @param[in] t (double): Current ti...
def output(self): """! @brief Returns output dynamic of the network. """ if (self.__ccore_legion_dynamic_pointer is not None): return wrapper.legion_dynamic_get_output(self.__ccore_legion_dynamic_pointer); return self.__output;
def inhibitor(self): """! @brief Returns output dynamic of the global inhibitor of the network. """ if (self.__ccore_legion_dynamic_pointer is not None): return wrapper.legion_dynamic_get_inhibitory_output(self.__ccore_legion_dynamic_pointer); ...
def time(self): """! @brief Returns simulation time. """ if (self.__ccore_legion_dynamic_pointer is not None): return wrapper.legion_dynamic_get_time(self.__ccore_legion_dynamic_pointer); return list(range(len(self)));
def allocate_sync_ensembles(self, tolerance = 0.1): """! @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 for allocation of synchronous ensemble os...
def __create_stimulus(self, stimulus): """! @brief Create stimulus for oscillators in line with stimulus map and parameters. @param[in] stimulus (list): Stimulus for oscillators that is represented by list, number of stimulus should be equal number of oscillators. ...
def __create_dynamic_connections(self): """! @brief Create dynamic connection in line with input stimulus. """ if (self._stimulus is None): raise NameError("Stimulus should initialed before creation of the dynamic connections in the network."); ...
def simulate(self, steps, time, stimulus, solution = solve_type.RK4, collect_dynamic = True): """! @brief Performs static simulation of LEGION oscillatory network. @param[in] steps (uint): Number steps of simulations during simulation. @param[in] time (double): Time of simu...
def _calculate_states(self, solution, t, step, int_step): """! @brief Calculates new state of each oscillator in the network. @param[in] solution (solve_type): Type solver of the differential equation. @param[in] t (double): Current time of simulation. @param[in] s...
def _global_inhibitor_state(self, z, t, argv): """! @brief Returns new value of global inhibitory @param[in] z (dobule): Current value of inhibitory. @param[in] t (double): Current time of simulation. @param[in] argv (tuple): It's not used, can be ignored. ...
def _legion_state_simplify(self, inputs, t, argv): """! @brief Returns new values of excitatory and inhibitory parts of oscillator of oscillator. @details Simplify model doesn't consider oscillator potential. @param[in] inputs (list): Initial values (current) of oscillator ...
def _legion_state(self, inputs, t, argv): """! @brief Returns new values of excitatory and inhibitory parts of oscillator and potential of oscillator. @param[in] inputs (list): Initial values (current) of oscillator [excitatory, inhibitory, potential]. @param[in] t (double)...
def allocate_map_coloring(self, tolerance = 0.1): """! @brief Allocates coloring map for graph that has been processed. @param[in] tolerance (double): Defines maximum deviation between phases. @return (list) Colors for each node (index of node in graph), for example [co...
def _create_connections(self, graph_matrix): """! @brief Creates connection in the network in line with graph. @param[in] graph_matrix (list): Matrix representation of the graph. """ for row in range(0, len(graph_matrix)): for column in rang...
def _phase_kuramoto(self, teta, t, argv): """! @brief Returns result of phase calculation for oscillator in the network. @param[in] teta (double): Value of phase of the oscillator with index argv in the network. @param[in] t (double): Unused, can be ignored. @param[in] a...
def process(self, order = 0.998, solution = solve_type.FAST, collect_dynamic = False): """! @brief Performs simulation of the network (performs solving of graph coloring problem). @param[in] order (double): Defines when process of synchronization in the network is over, range from 0 to ...
def allocate_clusters(self, eps = 0.01, indexes = None, iteration = None): """! @brief Returns list of clusters in line with state of ocillators (phases). @param[in] eps (double): Tolerance level that define maximal difference between phases of oscillators in one cluster. @...
def animate_cluster_allocation(dataset, analyser, animation_velocity = 75, tolerance = 0.1, save_movie = None, title = None): """! @brief Shows animation of output dynamic (output of each oscillator) during simulation on a circle from [0; 2pi]. @param[in] dataset (list): Input data ...
def _create_connections(self, radius): """! @brief Create connections between oscillators in line with input radius of connectivity. @param[in] radius (double): Connectivity radius between oscillators. """ if (self._ena_conn_weight is True): ...
def process(self, order = 0.998, solution = solve_type.FAST, collect_dynamic = True): """! @brief Peforms cluster analysis using simulation of the oscillatory network. @param[in] order (double): Order of synchronization that is used as indication for stopping processing. @p...
def _phase_kuramoto(self, teta, t, argv): """! @brief Overrided method for calculation of oscillator phase. @param[in] teta (double): Current value of phase. @param[in] t (double): Time (can be ignored). @param[in] argv (uint): Index of oscillator whose phase repre...
def show_network(self): """! @brief Shows connections in the network. It supports only 2-d and 3-d representation. """ if ( (self._ccore_network_pointer is not None) and (self._osc_conn is None) ): self._osc_conn = sync_connectivity_matrix(self._ccore...
def simulate_static(self, steps, time, solution = solve_type.RK4): """! @brief Performs static simulation of oscillatory network based on Hodgkin-Huxley neuron model. @details Output dynamic is sensible to amount of steps of simulation and solver of differential equation. P...
def _calculate_states(self, solution, t, step, int_step): """! @brief Caclculates new state of each oscillator in the network. Returns only excitatory state of oscillators. @param[in] solution (solve_type): Type solver of the differential equations. @param[in] t (double): C...
def __update_peripheral_neurons(self, t, step, next_membrane, next_active_sodium, next_inactive_sodium, next_active_potassium): """! @brief Update peripheral neurons in line with new values of current in channels. @param[in] t (doubles): Current time of simulation. @param[i...