# Summarizing dataset to apply machine learning – exercises

**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Dear reader,

If you are a newbie in the world of machine learning, then this tutorial is exactly what you need in order to introduce yourself to this exciting new part of the data science world.

This post includes a full machine learning project that will guide you step by step to create a “template,” which you can use later on other datasets.

Before proceeding, please follow our short tutorial.

Look at the examples given and try to understand the logic behind them. Then try to solve the exercises below using R and without looking at the answers. Then check the solutions.

to check your answers.

**Exercise 1**

Create a list of 80% of the rows in the original dataset to use for training. **HINT**: Use `createDataPartition()`

.

**Exercise 2**

Select 20% of the data for validation.

**Exercise 3**

Use the remaining 80% of data to train and test the models.

**Exercise 4**

Find the dimensions of the “iris” dataset. **HINT**: Use `dim()`

.

**Exercise 5**

Find the type of each attribute in your dataset. **HINT**: Use `sapply()`

.

**Exercise 6**

Take a look at the first 5 rows of your dataset. **HINT**: Use `head()`

.

**Exercise 7**

Find the levels of the variable “Species.” **HINT**: Use `levels()`

.

**Exercise 8**

Find the percentages of rows that belong to the labels you found in Exercise 7. **HINT**: Use `prop.table()`

and `table()`

.

**Exercise 9**

Display the absolute count of instances for each class as well as its percentage. **HINT**: Use `cbind()`

.

**Exercise 10**

Display the summary of the “iris” dataset. **HINT**: Use `summary()`

.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.