Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Machine Learning with R Quick Start Guide

You're reading from   Machine Learning with R Quick Start Guide A beginner's guide to implementing machine learning techniques from scratch using R 3.5

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781838644338
Length 250 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Iván Pastor Sanz Iván Pastor Sanz
Author Profile Icon Iván Pastor Sanz
Iván Pastor Sanz
Arrow right icon
View More author details
Toc

Predicting country ratings using macroeconomic information

In our clustering model, discussed in Chapter 6, Visualizing Economic Problems in the European Union, using self-organizing maps, all the available data was used. Now, in order to train a model to be able to predict sovereign ratings, we need to split the data into two samples: train and test.

That's not new for us. When we tried to develop different models to predict a bank's failures, we used the caTools package to split the data, while considering our target variable.

The same procedure is used again here:

library(caTools)

index = sample.split(macroeconomic_data$RatingMayT1, SplitRatio = .75)

train_macro<-subset(macroeconomic_data, index == TRUE)
test_macro<-subset(macroeconomic_data, index == FALSE)

Now, you can print the following statements:

print(paste("The number of observations in the train...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image