How to use the pyclustering.core.wrapper.ccore_library.get function in pyclustering

To help you get started, we’ve selected a few pyclustering examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github annoviko / pyclustering / pyclustering / core / dbscan_wrapper.py View on Github external
def dbscan(sample, eps, min_neighbors, data_type):
    pointer_data = package_builder(sample, c_double).create()
    c_data_type = convert_data_type(data_type)
    
    ccore = ccore_library.get()
    
    ccore.dbscan_algorithm.restype = POINTER(pyclustering_package)
    package = ccore.dbscan_algorithm(pointer_data, c_double(eps), c_size_t(min_neighbors), c_data_type)

    list_of_clusters = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    noise = list_of_clusters[len(list_of_clusters) - 1]
    list_of_clusters.remove(noise)

    return list_of_clusters, noise
github annoviko / pyclustering / pyclustering / core / silhouette_wrapper.py View on Github external
def silhoeutte_ksearch(sample, kmin, kmax, allocator):
    pointer_data = package_builder(sample, c_double).create()

    ccore = ccore_library.get()
    ccore.silhouette_ksearch_algorithm.restype = POINTER(pyclustering_package)
    package = ccore.silhouette_ksearch_algorithm(pointer_data, c_size_t(kmin), c_size_t(kmax), c_size_t(allocator))

    results = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)

    return (results[silhouette_ksearch_package_indexer.SILHOUETTE_KSEARCH_PACKAGE_INDEX_AMOUNT][0],
            results[silhouette_ksearch_package_indexer.SILHOUETTE_KSEARCH_PACKAGE_INDEX_SCORE][0],
            results[silhouette_ksearch_package_indexer.SILHOUETTE_KSEARCH_PACKAGE_INDEX_SCORES])
github annoviko / pyclustering / pyclustering / core / som_wrapper.py View on Github external
def som_get_weights(som_pointer):
    """!
    @brief Returns list of weights of each neuron.
    
    @param[in] som_pointer (c_pointer): pointer to object of self-organized map.
    
    """
    
    ccore = ccore_library.get()
    
    ccore.som_get_weights.restype = POINTER(pyclustering_package)
    package = ccore.som_get_weights(som_pointer)
    
    result = package_extractor(package).extract()
    return result
github annoviko / pyclustering / pyclustering / core / agglomerative_wrapper.py View on Github external
def agglomerative_algorithm(data, number_clusters, link):
    pointer_data = package_builder(data, c_double).create();

    ccore = ccore_library.get();
    ccore.agglomerative_algorithm.restype = POINTER(pyclustering_package);
    package = ccore.agglomerative_algorithm(pointer_data, c_size_t(number_clusters), c_size_t(link));

    result = package_extractor(package).extract();
    ccore.free_pyclustering_package(package);

    return result;
github annoviko / pyclustering / pyclustering / core / metric_wrapper.py View on Github external
def __del__(self):
        if self.__pointer:
            ccore = ccore_library.get()
            ccore.metric_destroy(self.__pointer)
github annoviko / pyclustering / pyclustering / core / xmeans_wrapper.py View on Github external
def xmeans(sample, centers, kmax, tolerance, criterion, repeat):
    pointer_data = package_builder(sample, c_double).create()
    pointer_centers = package_builder(centers, c_double).create()
    
    ccore = ccore_library.get()
    
    ccore.xmeans_algorithm.restype = POINTER(pyclustering_package)
    package = ccore.xmeans_algorithm(pointer_data, pointer_centers, c_size_t(kmax), c_double(tolerance), c_uint(criterion), c_size_t(repeat))
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result
github annoviko / pyclustering / pyclustering / core / som_wrapper.py View on Github external
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_type (type_conn): Type of connection between oscillators in the network (grid four, grid eight, honeycomb, function neighbour).
    @param[in] parameters (som_parameters): Other specific parameters.
    
    @return (POINTER) C-pointer to object of self-organized feature in memory.
    
    """  

    ccore = ccore_library.get()
    
    c_params = c_som_parameters()
    
    c_params.init_type = parameters.init_type
    c_params.init_radius = parameters.init_radius
    c_params.init_learn_rate = parameters.init_learn_rate
    c_params.adaptation_threshold = parameters.adaptation_threshold
    
    ccore.som_create.restype = POINTER(c_void_p)
    som_pointer = ccore.som_create(c_uint(rows), c_uint(cols), c_uint(conn_type), pointer(c_params))
    
    return som_pointer
github annoviko / pyclustering / pyclustering / core / kmedians_wrapper.py View on Github external
def kmedians(sample, centers, tolerance, itermax, metric_pointer):
    pointer_data = package_builder(sample, c_double).create()
    pointer_centers = package_builder(centers, c_double).create()
    
    ccore = ccore_library.get()
    
    ccore.kmedians_algorithm.restype = POINTER(pyclustering_package)
    package = ccore.kmedians_algorithm(pointer_data, pointer_centers, c_double(tolerance), c_size_t(itermax), metric_pointer)
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result[0], result[1]
github annoviko / pyclustering / pyclustering / core / mbsas_wrapper.py View on Github external
def mbsas(sample, amount, threshold, metric_pointer):
    pointer_data = package_builder(sample, c_double).create();

    ccore = ccore_library.get();

    ccore.mbsas_algorithm.restype = POINTER(pyclustering_package);
    package = ccore.mbsas_algorithm(pointer_data, c_size_t(amount), c_double(threshold), metric_pointer);

    result = package_extractor(package).extract();
    ccore.free_pyclustering_package(package);

    return result[0], result[1];
github annoviko / pyclustering / pyclustering / core / bsas_wrapper.py View on Github external
def bsas(sample, amount, threshold, metric_pointer):
    pointer_data = package_builder(sample, c_double).create()

    ccore = ccore_library.get()

    ccore.bsas_algorithm.restype = POINTER(pyclustering_package)
    package = ccore.bsas_algorithm(pointer_data, c_size_t(amount), c_double(threshold), metric_pointer)

    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)

    return result[0], result[1]