Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
def cure_get_means(cure_data_pointer):
ccore = ccore_library.get();
ccore.cure_get_means.restype = POINTER(pyclustering_package);
package = ccore.cure_get_means(cure_data_pointer);
result = package_extractor(package).extract();
ccore.free_pyclustering_package(package);
return result;
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
def syncpr_dynamic_get_output(pointer_dynamic):
ccore = ccore_library.get();
ccore.syncpr_dynamic_get_output.restype = POINTER(pyclustering_package);
package = ccore.syncpr_dynamic_get_output(pointer_dynamic);
result = package_extractor(package).extract();
ccore.free_pyclustering_package(package);
return result;
def elbow(sample, kmin, kmax, initializer):
pointer_data = package_builder(sample, c_double).create()
ccore = ccore_library.get()
if initializer == elbow_center_initializer.KMEANS_PLUS_PLUS:
ccore.elbow_method_ikpp.restype = POINTER(pyclustering_package)
package = ccore.elbow_method_ikpp(pointer_data, c_size_t(kmin), c_size_t(kmax))
elif initializer == elbow_center_initializer.RANDOM:
ccore.elbow_method_irnd.restype = POINTER(pyclustering_package)
package = ccore.elbow_method_irnd(pointer_data, c_size_t(kmin), c_size_t(kmax))
else:
raise ValueError("Not supported type of center initializer '" + str(initializer) + "'.")
results = package_extractor(package).extract()
ccore.free_pyclustering_package(package)
return (results[elbow_package_indexer.ELBOW_PACKAGE_INDEX_AMOUNT][0],
results[elbow_package_indexer.ELBOW_PACKAGE_INDEX_WCE])
@param[in] eps: connectivity radius (similarity threshold), points are neighbors if distance between them is less than connectivity radius.
@param[in] number_clusters: defines number of clusters that should be allocated from the input data set.
@param[in] threshold: value that defines degree of normalization that influences on choice of clusters for merging during processing.
@return List of allocated clusters, each cluster contains indexes of objects in list of data.
"""
pointer_data = package_builder(sample, c_double).create();
ccore = ccore_library.get();
ccore.rock_algorithm.restype = POINTER(pyclustering_package);
package = ccore.rock_algorithm(pointer_data, c_double(eps), c_size_t(number_clusters), c_double(threshold));
list_of_clusters = package_extractor(package).extract();
ccore.free_pyclustering_package(package);
return list_of_clusters;
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 = POINTER(pyclustering_package)
package = ccore.som_get_capture_objects(som_pointer)
result = package_extractor(package).extract()
return result
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])
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]
def som_get_neighbors(som_pointer):
"""!
@brief Returns list of indexes of neighbors of each neuron.
@param[in] som_pointer (c_pointer): pointer to object of self-organized map.
"""
ccore = ccore_library.get()
ccore.som_get_neighbors.restype = POINTER(pyclustering_package)
package = ccore.som_get_neighbors(som_pointer)
result = package_extractor(package).extract()
return result