Skip to content

heriopaz/active-constrained-clustering

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

active-constrained-clustering

Active constrained clustering algorithms for scikit-learn.

Algorithms

Semi-supervised clustering

  • Seeded K-Means
  • Constrained K-Means

Constrained clustering

  • Metric K-Means (MK-Means)
  • Pairwise constrained K-Means (PCK-Means)
  • Constrained K-Means (COPK-Means)
  • Metric pairwise constrained K-Means (MPCK-Means)

New additions:

  • Constrained spectral clustering (CSP)
  • Agglomerative hierarchical clustering with constraints (AHCC)

Active learning of pairwise clustering

  • Explore-Consolidate
  • Min-Max
  • Normalized point-based uncertainty (NPU)

New additions:

  • Borderline MST heuristic
  • Distant MST heuristic
  • Unified borderline and distant MST heuristics
  • Explore-NPU

Installation

sudo apt-get update
sudo apt-get install git
pip install --upgrade git:git://github.com/heriosousa/active-constrained-clustering.git

Usage

from sklearn import datasets, metrics
from active_semi_clustering.semi_supervised.pairwise_constraints import PCKMeans
from active_semi_clustering.active.pairwise_constraints import ExampleOracle, ExploreConsolidate, MinMax
X, y = datasets.load_iris(return_X_y=True)

First, obtain some pairwise constraints from an oracle.

# TODO implement your own oracle that will, for example, query a domain expert via GUI or CLI
oracle = ExampleOracle(y, max_queries_cnt=10)

active_learner = MinMax(n_clusters=3)
active_learner.fit(X, oracle=oracle)
pairwise_constraints = active_learner.pairwise_constraints_

Then, use the constraints to do the clustering.

clusterer = PCKMeans(n_clusters=3)
clusterer.fit(X, ml=pairwise_constraints[0], cl=pairwise_constraints[1])

Evaluate the clustering using Adjusted Rand Score.

metrics.adjusted_rand_score(y, clusterer.labels_)

About

Active constrained clustering algorithms

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%