Clustering, density estimation, and anomaly detection · Partition clustering · UCL007 · Algorithm
Metric K-center / farthest-first traversal
Choose representatives to limit the worst covered observation, useful for coverage, facility placement, and representative subset selection when maximum distance matters more than average distortion.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- k-center (farthest-first) Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through discover.kcenter. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Choose representatives to limit the worst covered observation, useful for coverage, facility placement, and representative subset selection when maximum distance matters more than average distortion.
Question / hypotheses
Which partition best represents the chosen distance-based notion of within-group similarity? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.
Architecture / computational structure
A greedy representative list and a maintained nearest-center distance vector.
Assumptions
An isolated outlier can consume a center because worst-case coverage explicitly values it. Standard K-center does not model noise, group probabilities, or population prevalence. Approximation results for variants with outliers or nonmetric similarities cannot be assumed to apply unchanged.
Formula / computational definition
Minimize . Farthest-first starts with one point and repeatedly selects the point farthest from the current set. For metric distances, this greedy construction gives a factor-two approximation to the optimal radius; the guarantee depends on the triangle inequality.
Parameters and notation
Learned or fitted quantities: Chosen centers and a coverage-radius summary. User-set hyperparameters/design choices: Set , distance, and initial point. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.
Fitting, fine-tuning, and adaptation
Neural fine-tuning is not applicable. Refit after changing the metric or scaling. Where the objective permits, warm-start from previous representatives, then compare against independent restarts; assign new cases using the same stored representation and distance.
How to use and calibrate
Report maximum and high-quantile nearest-center distance, coverage by subgroup, and sensitivity to the initial point. Average silhouette alone misses the optimization target.
Example application
Choose geographic inspection sites that minimize worst uncovered distance. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.
Interpretation / pitfalls
Watch out
The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.
Python and R code examples
Implement natively using a vector of current minimum distances: update it after each selected center and take argmax/which.max. No generic clustering library is necessary; avoid a dense all-pairs matrix when distances can be computed on demand.
Component: Complete farthest-first representative selection on a tiny fixture. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Complete farthest-first representative selection on a tiny fixture. · needs numpy
import numpy as np
x=np.array([0.,1.,4.,8.,9.]); selected=[0]
nearest=np.abs(x-x[0])
for _ in range(2):
j=int(np.argmax(nearest)); selected.append(j)
nearest=np.minimum(nearest,np.abs(x-x[j]))
result=np.array([*x[selected],nearest.max()])
print(result)
Component demo, not a trained model — Complete farthest-first representative selection on a tiny fixture.
x=c(0,1,4,8,9); selected=1; nearest=abs(x-x[1])
for(step in 1:2){j=which.max(nearest); selected=c(selected,j); nearest=pmin(nearest,abs(x-x[j]))}
result=c(x[selected],radius=max(nearest))
print(result)
Sources
- Source 1cs.columbia.edu
From the CodeSplash reference, entry UCL007.