Code Monkey home page Code Monkey logo

gap-statistic's Introduction

About

An implementation of the gap statistic algorithm from Tibshirani, Walther, and Hastie's "Estimating the number of clusters in a data set via the gap statistic". A description of the algorithm can be found here.

Examples

	# Single cluster in 5 dimensions
	data = cbind(rnorm(20), rnorm(20), rnorm(20), rnorm(20), rnorm(20))

	png("examples/1_cluster_5d_gaps.png")
	gap_statistic(data)
	dev.off()

Single cluster in 5 dimensions

	# Three clusters in 2 dimensions
	x = c(rnorm(20, mean = 0), rnorm(20, mean = 3), rnorm(20, mean = 5))
	y = c(rnorm(20, mean = 0), rnorm(20, mean = 5), rnorm(20, mean = 0))
	data = cbind(x, y)

	png("examples/3_clusters_2d.png")
	qplot(x, y)
	dev.off()

3 clusters in 2 dimensions

	png("examples/3_clusters_2d_gaps.png")
	gap_statistic(data)
	dev.off()

3 clusters in 2 dimensions

	# Four clusters in 3 dimensions
	x = c(rnorm(20, mean = 0), rnorm(20, mean = 3), rnorm(20, mean = 5), rnorm(20, mean = -10))
	y = rnorm(80, mean = 0)
	z = c(rnorm(40, mean = -5), rnorm(40, mean = 0))
	data = cbind(x, y, z)

	png("examples/4_clusters_3d.png")
	scatterplot3d(x, y, z)
	dev.off()

4 clusters in 3 dimensions

	png("examples/4_clusters_3d_gaps.png")
	gap_statistic(data)
	dev.off()

4 clusters in 3 dimensions

gap-statistic's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.