Book Image

Machine Learning with R Quick Start Guide

By : Iván Pastor Sanz
Book Image

Machine Learning with R Quick Start Guide

By: Iván Pastor Sanz

Overview of this book

Machine Learning with R Quick Start Guide takes you on a data-driven journey that starts with the very basics of R and machine learning. It gradually builds upon core concepts so you can handle the varied complexities of data and understand each stage of the machine learning pipeline. From data collection to implementing Natural Language Processing (NLP), this book covers it all. You will implement key machine learning algorithms to understand how they are used to build smart models. You will cover tasks such as clustering, logistic regressions, random forests, support vector machines, and more. Furthermore, you will also look at more advanced aspects such as training neural networks and topic modeling. By the end of the book, you will be able to apply the concepts of machine learning, deal with data-related problems, and solve them using the powerful yet simple language that is R.
Table of Contents (9 chapters)

Structuring data

After having acquired our target variable and knowing our dataset, we can now move on to the actual data collection based on our target. Here, we will try acquiring the data of the bank according to different years as described in the Collecting the target variable section.

To do this, we create a new variable extracting only the year when a bank went bankrupt, and then we count the number of banks by year:

failed_banks$year<-as.numeric(format(failed_banks$Closing.Date, "%Y"))

Failed_by_Year<-as.data.frame(table(failed_banks$year))
colnames(Failed_by_Year)<-c("year","Number_of_banks")

print(Failed_by_Year)
## year Number_of_banks
## 1 2000 2
## 2 2001 4
## 3 2002 11
## 4 2003 3
## 5 2004 4
## 6 2007 3
## 7 2008 25
...