Skip to content

Commit

Permalink
Merge pull request #41 from jpfairbanks/patch-1
Browse files Browse the repository at this point in the history
Update kmeans.rst
  • Loading branch information
lindahua committed Mar 19, 2015
2 parents f83803d + 2066a65 commit 3c6b280
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions doc/source/kmeans.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,20 @@ If you already have a set of initial center vectors, you may use ``kmeans!`` ins
# M[:,k] is the mean vector of the k-th cluster
M = R.centers
Example with plot

.. code-block:: julia
using RDatasets
iris = dataset("datasets", "iris")
head(iris)
# K-means Clustering unsupervised machine learning example
using Clustering
features = array(iris[:, 1:4])' # use matrix() on Julia v0.2
result = kmeans( features, 3 ) # onto 3 clusters
plot(iris, x = "PetalLength", y = "PetalWidth", color = result.assignments, Geom.point)

0 comments on commit 3c6b280

Please sign in to comment.