Commit 45926e5a authored by Stanislav's avatar Stanislav
Browse files

p_max_cluster_count wieder eingeführt

parent 8e367827
......@@ -22,7 +22,7 @@ p_attr_weights = {
} # attributes that are not given in the data are not used
p_clusteval_mode = 'silhouette'
p_clustering_mode = 'kmeans' # optional, default: kmeans
# p_max_cluster_count = 25 # np.NaN # cluster-count (optional, default: np.NaN which leads to automatic k determination)
p_max_cluster_count = np.NaN # np.NaN # cluster-count (optional, default: np.NaN which leads to automatic k determination)
p_ocel_file_type = 'json' # json|xml
p_graph_file_type = 'svg' # svg|png
# END PARAMETERS
......@@ -38,7 +38,7 @@ print('p_attr_weights:')
print(p_attr_weights)
print('p_clusteval_mode: "' + str(p_clusteval_mode) + '".')
print('p_clustering_mode: "' + str(p_clustering_mode) + '".')
# print('p_max_cluster_count: "' + str(p_max_cluster_count) + '".')
print('p_max_cluster_count: "' + str(p_max_cluster_count) + '".')
print('p_ocel_file_type: "' + str(p_ocel_file_type) + '".')
print('p_graph_file_type: "' + str(p_graph_file_type) + '".')
print('-------------------------------------------------------')
......@@ -82,16 +82,20 @@ index_to_oid_map = res['index']
algo = algorithms[p_clustering_mode]
# try:
# max_cluster_count = int(p_max_cluster_count)
# except:
# max_cluster_count = 25
try:
max_cluster_count = int(p_max_cluster_count)
except:
max_cluster_count = 0
# assert max_cluster_count >= 2, 'cluster_count needs to be at least 2'
# assert max_cluster_count < len(index_to_oid_map), 'cluster_count needs to be less than the count of distinct objects in the ocel-data.'
# max_cluster darf jetzt auch 0 sein, dann wird by default der Algorithmus entscheiden, wieviele cluster nötig zu berechnen sind.
assert max_cluster_count < len(index_to_oid_map), 'cluster_count needs to be less than the count of distinct objects in the ocel-data.'
# cluster_count = cluster.determine_optimal_k(distance_matrix, algorithm=algo, k_max=max_cluster_count)
results = clusteval(evaluate = p_clusteval_mode).fit(distance_matrix)
if (max_cluster_count == 0):
results = clusteval(evaluate = p_clusteval_mode).fit(distance_matrix)
else:
results = clusteval(evaluate = p_clusteval_mode, max_clust=max_cluster_count).fit(distance_matrix)
cluster_count = results['score']['clusters'].iloc[np.where(results['score']['score'] == results['score']['score'].max())[0][0]]
algo.set_params(n_clusters=cluster_count)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment