Skip to content

Commit

Permalink
Version updates for v1.0.3 with stratification fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Old-Shatterhand committed May 21, 2024
1 parent 089140d commit 4c0a7c9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion datasail/cluster/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ def cluster(dataset: DataSet, **kwargs) -> DataSet:
dataset.cluster_similarity = dataset.similarity
dataset.cluster_distance = dataset.distance
dataset.cluster_weights = dataset.weights
dataset.cluster_stratification = {name: dataset.strat2oh(name) for name in dataset.cluster_names}

if dataset.cluster_names is None: # No clustering to do?!
return dataset

# if there are too many clusters, reduce their number based on some cluster algorithms.
if any(isinstance(m, np.ndarray) for m in
[dataset.similarity, dataset.cluster_similarity, dataset.cluster_distance]):
[dataset.similarity, dataset.distance, dataset.cluster_similarity, dataset.cluster_distance]):
num_old_cluster = len(dataset.cluster_names) + 1
while dataset.num_clusters < len(dataset.cluster_names) < num_old_cluster:
num_old_cluster = len(dataset.cluster_names)
Expand Down Expand Up @@ -269,12 +270,14 @@ def labels2clusters(
if new_cluster not in new_cluster_stratification:
new_cluster_stratification[new_cluster] = np.zeros(len(dataset.classes))
new_cluster_weights[new_cluster] += dataset.cluster_weights[name]
new_cluster_stratification[new_cluster] += dataset.cluster_stratification[name]

LOGGER.info(f"Reduced number of clusters to {len(new_cluster_names)}.")

dataset.cluster_names = new_cluster_names
dataset.cluster_map = new_cluster_map
dataset.cluster_weights = new_cluster_weights
dataset.cluster_stratification = new_cluster_stratification

# store the matrix at the correct field and set the main diagonal to either 1 or 0 depending on dist or sim
if dataset.cluster_similarity is not None:
Expand Down
2 changes: 1 addition & 1 deletion datasail/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.2"
__version__ = "1.0.3"
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "datasail"
version: '1.0.2'
version: '1.0.3'

source:
path: ..
Expand Down
2 changes: 1 addition & 1 deletion recipe_lite/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: "datasail-lite"
version: '1.0.2'
version: '1.0.3'

source:
path: ..
Expand Down

0 comments on commit 4c0a7c9

Please sign in to comment.