diff --git a/wise_pizza/cluster.py b/wise_pizza/cluster.py index 72e35ce..f4e185f 100644 --- a/wise_pizza/cluster.py +++ b/wise_pizza/cluster.py @@ -25,6 +25,7 @@ def guided_kmeans(X: np.ndarray, power_transform: bool = True) -> np.ndarray: best_score = -1 best_labels = None + best_n = -1 # If we allow 2 clusters, it almost always just splits positive vs negative - boring! for n_clusters in range(3, int(len(X) / 2) + 1): cluster_labels = KMeans(n_clusters=n_clusters, init="k-means++", n_init=10).fit_predict(X) diff --git a/wise_pizza/explain.py b/wise_pizza/explain.py index f49d1af..82ca8f8 100644 --- a/wise_pizza/explain.py +++ b/wise_pizza/explain.py @@ -25,6 +25,7 @@ def explain_changes_in_average( how: str = "totals", force_add_up: bool = False, constrain_signs: bool = True, + cluster_values: bool = False, verbose: int = 0, ): """ @@ -85,6 +86,7 @@ def explain_changes_in_average( how=how, force_add_up=force_add_up, constrain_signs=constrain_signs, + cluster_values=cluster_values, verbose=verbose, ) @@ -118,7 +120,7 @@ def explain_changes_in_totals( how: str = "totals", force_add_up: bool = False, constrain_signs: bool = True, - cluster_values: bool=True, + cluster_values: bool=False, verbose: int = 0, ): """ @@ -256,7 +258,7 @@ def explain_levels( verbose=0, force_add_up: bool = False, constrain_signs: bool = True, - cluster_values: bool=True + cluster_values: bool=False ): """ Find segments whose average is most different from the global one