Skip to content

Commit

Permalink
Fix DiviK saver function
Browse files Browse the repository at this point in the history
  • Loading branch information
gmrukwa committed Jan 19, 2021
1 parent 0952343 commit aff2145
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
62 changes: 46 additions & 16 deletions divik/_cli/fit_clusters.gin
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
import divik.cluster
DunnDiviK.gap_trials = 10
DunnDiviK.leaf_size = 0.01
DunnDiviK.distance = 'correlation'
DunnDiviK.minimal_size = 200
DunnDiviK.rejection_size = 20
DunnDiviK.minimal_features_percentage = 0.05
DunnDiviK.fast_kmeans_iter = 100
DunnDiviK.k_max = 10
DunnDiviK.sample_size = 1000
DunnDiviK.normalize_rows = True
DunnDiviK.use_logfilters = True
DunnDiviK.filter_type = 'auto'
DunnDiviK.n_jobs = -1
DunnDiviK.random_seed = 42
DunnDiviK.verbose = True

KMeans.n_clusters = 1
KMeans.distance = "correlation"
KMeans.init = "kdtree_percentile"
KMeans.leaf_size = 0.01
KMeans.percentile = 99.0
KMeans.max_iter = 100
KMeans.normalize_rows = True

GAPSearch.kmeans = @KMeans()
GAPSearch.max_clusters = 2
GAPSearch.n_jobs = -1
GAPSearch.seed = 42
GAPSearch.n_trials = 10
GAPSearch.sample_size = 10000
GAPSearch.drop_unfit = True
GAPSearch.verbose = True

DunnSearch.kmeans = @KMeans()
DunnSearch.max_clusters = 10
DunnSearch.method = "auto"
DunnSearch.inter = "closest"
DunnSearch.intra = "furthest"
DunnSearch.sample_size = 10000
DunnSearch.seed = 42
DunnSearch.n_jobs = -1
DunnSearch.drop_unfit = True
DunnSearch.verbose = True

DiviK.kmeans = @DunnSearch()
DiviK.fast_kmeans = @GAPSearch()
DiviK.distance = "correlation"
DiviK.minimal_size = 200
DiviK.rejection_size = 20
DiviK.minimal_features_percentage = 0.05
DiviK.features_percentage = 1.0
DiviK.normalize_rows = True
DiviK.use_logfilters = True
DiviK.filter_type = "gmm"
DiviK.n_jobs = -1
DiviK.verbose = True

load_data.path = 'data.csv'
load_xy.path = 'xy.csv'
experiment.model = @DunnDiviK()
experiment.model = @DiviK()
experiment.destination = 'result'
experiment.omit_datetime = False
experiment.verbose = True
experiment.exist_ok = False
2 changes: 1 addition & 1 deletion divik/core/io/_model_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def save_summary(model, fname_fn, **kwargs):
if not hasattr(model, "labels_"):
return
logging.info("Saving JSON summary.")
n_clusters = getattr(model, "n_clusters_", np.unique(model.label_).size)
n_clusters = getattr(model, "n_clusters_", np.unique(model.labels_).size)
with open(fname_fn("summary.json"), "w") as smr:
json.dump(
{
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "divik"
version = "3.0.2"
version = "3.0.3"
description = "Divisive iK-means algorithm implementation"
authors = ["Grzegorz Mrukwa <g.mrukwa@gmail.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit aff2145

Please sign in to comment.