Book Image

R Machine Learning Essentials

By : Michele Usuelli
Book Image

R Machine Learning Essentials

By: Michele Usuelli

Overview of this book

Table of Contents (15 chapters)
R Machine Learning Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Identifying a homogeneous group of items


Our data describes each country flag. Is there any way to identify groups of countries with similar flag attributes? We can use some clustering techniques that are machine learning algorithms that define homogeneous clusters using the data.

Starting from the flag attributes, in the previous chapter, we built a feature table and we stored it into the dtFeatures.txt file. In order to load the file into R, the first step is to define the directory containing the file using setwd. Then, we can load the file into the dfFeatures data frame using read.table, and we can convert it into the dtFeatures data table, as shown:

# load the flag features
setwd('<INSER YOUR DIRECTORY/PATH>")
dfFeatures <- read.table(file = 'dtFeatures.txt')
library("data.table")
dtFeatures <- data.table(dfFeatures)

Let's take a look at the data using str, similar to the previous chapters:

# explore the features
str(dtFeatures)
Classes 'data.table' and 'data.frame':	194 obs...