Reader small image

You're reading from  Learning Predictive Analytics with R

Product typeBook
Published inSep 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781782169352
Edition1st Edition
Languages
Right arrow
Author (1)
Eric Mayor
Eric Mayor
author image
Eric Mayor

Eric Mayor is a senior researcher and lecturer at the University of Neuchatel, Switzerland. He is an enthusiastic user of open source and proprietary predictive analytics software packages, such as R, Rapidminer, and Weka. He analyzes data on a daily basis and is keen to share his knowledge in a simple way.
Read more about Eric Mayor

Right arrow

Using k-means with public datasets


In what follows, we are going to learn more about partition clustering with k-means while exploring a dataset from the cluster.datasets package. This package contains datasets that were published in the book, Clustering algorithms, by Hartigan (1975), with examples of analyses. So let's start by installing this dataset on your machine, and loading it.

install.packages("cluster.datasets")
library(cluster.datasets)

Understanding the data with the all.us.city.crime.1970 dataset

We will first focus on getting to know the data, scaling the data to a common metric, and cluster interpretability. Our first exploration will concern the crime rates among different US cities in 1970. The dataset all.us.city.crime.1970 affords such investigation:

data(all.us.city.crime.1970)
crime = all.us.city.crime.1970

Let's investigate the attributes in the dataset:

ncol(crime)
names(crime)
summary(crime)

There are 10 attributes. A look at the R manual page (type ?all.us.city.crime.1970...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Predictive Analytics with R
Published in: Sep 2015Publisher: PacktISBN-13: 9781782169352

Author (1)

author image
Eric Mayor

Eric Mayor is a senior researcher and lecturer at the University of Neuchatel, Switzerland. He is an enthusiastic user of open source and proprietary predictive analytics software packages, such as R, Rapidminer, and Weka. He analyzes data on a daily basis and is keen to share his knowledge in a simple way.
Read more about Eric Mayor