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
Machine Learning with R
Machine Learning with R

Machine Learning with R: Expert techniques for predictive modeling , Third Edition

eBook
€8.99 €35.99
Paperback
€44.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Machine Learning with R

Chapter 2. Managing and Understanding Data

A key early component of any machine learning project involves managing and understanding data. Although this may not be as gratifying as building and deploying models—the stages in which you begin to see the fruits of your labor—it is unwise to ignore this important preparatory work.

Any learning algorithm is only as good as its input data, and in many cases, the input data is complex, messy, and spread across multiple sources and formats. Due to this complexity, often the largest portion of effort invested in machine learning projects is spent on data preparation and exploration.

This chapter approaches data preparation in three ways. The first section discusses the basic data structures R uses to store data. You will become very familiar with these structures as you create and manipulate datasets. The second section is practical, as it covers several functions that are used for getting data in and...

R data structures

There are numerous types of data structures across programming languages, each with strengths and weaknesses suited to specific tasks. Since R is a programming language used widely for statistical data analysis, the data structures it utilizes were designed with this type of work in mind.

The R data structures used most frequently in machine learning are vectors, factors, lists, arrays, matrices, and data frames. Each is tailored to a specific data management task, which makes it important to understand how they will interact in your R project. In the sections that follow, we will review their similarities and differences.

Vectors

The fundamental R data structure is the vector, which stores an ordered set of values called elements. A vector can contain any number of elements. However, all of its elements must be of the same type; for instance, a vector cannot contain both numbers and text. To determine the type of vector v, use the typeof(v) command.

Several...

Managing data with R

One of the challenges faced while working with massive datasets involves gathering, preparing, and otherwise managing data from a variety of sources. Although we will cover data preparation, data cleaning, and data management in depth by working on real-world machine learning tasks in later chapters, this section highlights the basic functionality for getting data in and out of R.

Saving, loading, and removing R data structures

When you have spent a lot of time getting a data frame into the desired form, you shouldn't need to recreate your work each time you restart your R session. To save a data structure to a file that can be reloaded later or transferred to another system, use the save() function. The save() function writes one or more R data structures to the location specified by the file parameter. R data files have an .RData extension.

Suppose you had three objects named x, y, and z that you would like to save to a permanent file. Regardless of whether...

Exploring and understanding data

After collecting data and loading it into R data structures, the next step in the machine learning process involves examining the data in detail. It is during this step that you will begin to explore the data's features and examples, and realize the peculiarities that make your data unique. The better you understand your data, the better you will be able to match a machine learning model to your learning problem.

The best way to learn the process of data exploration is by example. In this section, we will explore the usedcars.csv dataset, which contains actual data about used cars advertised for sale on a popular US website in the year 2012.

Tip

The usedcars.csv dataset is available for download on the Packt Publishing support page for this book. If you are following along with the examples, be sure that this file has been downloaded and saved to your R working directory.

Since the dataset is stored in CSV form, we can use the read.csv...

Summary

In this chapter, we learned about the basics of managing data in R. We started by taking an in-depth look at the structures used for storing various types of data. The foundational R data structure is the vector, which is extended and combined into more complex data types, such as lists and data frames. The data frame is an R data structure that corresponds to the notion of a dataset having both features and examples. R provides functions for reading and writing data frames to spreadsheet-like tabular data files.

We then explored a real-world dataset containing prices of used cars. We examined numeric variables using common summary statistics of center and spread, and visualized relationships between prices and odometer readings with a scatterplot. Next, we examined nominal variables using tables. In examining the used car data, we followed an exploratory process that can be used to understand any dataset. These skills will be required for the other projects throughout...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Third edition of the bestselling, widely acclaimed R machine learning book, updated and improved for R 3.6 and beyond
  • Harness the power of R to build flexible, effective, and transparent machine learning models
  • Learn quickly with a clear, hands-on guide by experienced machine learning teacher and practitioner, Brett Lantz

Description

Machine learning, at its core, is concerned with transforming data into actionable knowledge. R offers a powerful set of machine learning methods to quickly and easily gain insight from your data. Machine Learning with R, Third Edition provides a hands-on, readable guide to applying machine learning to real-world problems. Whether you are an experienced R user or new to the language, Brett Lantz teaches you everything you need to uncover key insights, make new predictions, and visualize your findings. This new 3rd edition updates the classic R data science book to R 3.6 with newer and better libraries, advice on ethical and bias issues in machine learning, and an introduction to deep learning. Find powerful new insights in your data; discover machine learning with R.

Who is this book for?

Data scientists, students, and other practitioners who want a clear, accessible guide to machine learning with R.

What you will learn

  • Discover the origins of machine learning and how exactly a computer learns by example
  • Prepare your data for machine learning work with the R programming language
  • Classify important outcomes using nearest neighbor and Bayesian methods
  • Predict future events using decision trees, rules, and support vector machines
  • Forecast numeric data and estimate financial values using regression methods
  • Model complex processes with artificial neural networks — the basis of deep learning
  • Avoid bias in machine learning models
  • Evaluate your models and improve their performance
  • Connect R to SQL databases and emerging big data technologies such as Spark, H2O, and TensorFlow

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 15, 2019
Length: 458 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788295864
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Apr 15, 2019
Length: 458 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788295864
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 119.97
Mastering Machine Learning with R
€32.99
Python Machine Learning
€41.99
Machine Learning with R
€44.99
Total 119.97 Stars icon
Banner background image

Table of Contents

15 Chapters
1. Introducing Machine Learning Chevron down icon Chevron up icon
2. Managing and Understanding Data Chevron down icon Chevron up icon
3. Lazy Learning – Classification Using Nearest Neighbors Chevron down icon Chevron up icon
4. Probabilistic Learning – Classification Using Naive Bayes Chevron down icon Chevron up icon
5. Divide and Conquer – Classification Using Decision Trees and Rules Chevron down icon Chevron up icon
6. Forecasting Numeric Data – Regression Methods Chevron down icon Chevron up icon
7. Black Box Methods – Neural Networks and Support Vector Machines Chevron down icon Chevron up icon
8. Finding Patterns – Market Basket Analysis Using Association Rules Chevron down icon Chevron up icon
9. Finding Groups of Data – Clustering with k-means Chevron down icon Chevron up icon
10. Evaluating Model Performance Chevron down icon Chevron up icon
11. Improving Model Performance Chevron down icon Chevron up icon
12. Specialized Machine Learning Topics Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Leave a review - let other readers know what you think Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(46 Ratings)
5 star 67.4%
4 star 10.9%
3 star 6.5%
2 star 6.5%
1 star 8.7%
Filter icon Filter
Top Reviews

Filter reviews by




Andrew Horn Jan 14, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is an outstanding book and by far the best machine learning book of the several I have read. I highly recommend.1) The author writes this in a way that you can perform machine learning tasks in R without any prior experience using R or ML. He gets you up to speed quickly on how to download R Studio and explains everything you need to know about R in order to perform the ML tasks that are described later in the book. He doesn't explain all of the things you can do in R as in many other books, because you don't necessarily need to know everything about R to perform ML tasks and this book is about ML. So this is obviously not a book that is exhaustive of everything possible in R.2) The structure of this book is outstanding and very logical. Within each of the chapters on Machine Learning models, he describes the model and how it works, includes a section covering the model's syntax in R, the strengths and weaknesses of each model, compares the model to the prior models discussed, and then uses that foundation to walk you through an example of applying each model to real data. Within the examples, he uses the 5 steps of a modeling process: 1) collecting data, 2) exploring and prepping the data, 3) training the model, 4) evaluating model performance, and 5) Improving model performance. I love this structure!3) His explanations of everything are outstanding. I've read several ML books and he by far is the best at explaining things in a way that people can clearly understand. If the model involves statistical concepts, he explains what you need to know very well.4) The book covers many ML models: K-Nearest Neighbors, Naive Bayes, Decision Trees, Classification Rules, Regression, Regression Trees, Model Trees, Neural Networks, Support Vector Machines, Association Rules, K-Means Clustering, and Random Forests. For an advanced Data Scientist, this may not seem like an exhaustive list. However, I feel that for a beginning data scientist or someone that is just interested in getting a good overview of data modeling, I feel this is a great choice of model coverage.Bottom line- if you're at all interested in machine learning in R, this is the book to get. If you're already an advanced data scientist with years of experience, this may not be the best text for you, though.
Amazon Verified review Amazon
Andreas Dorta Jan 11, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Most other books I know on this topic are far too theoretical for me.Brett provides a very practical approach.
Amazon Verified review Amazon
Ariful Islam Mondal Apr 27, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book. I have come across one of the best books so far on Machine Learning using R. The author has made sure that the book is readable for both for a new users of R programming as well as who are new to machine learning with multiple case studies. This is also a great book for people who want to refresh their memories in key techniques of machine learning. I am an experience data science professional and I would recommend this book to readers looking to understand how to build machine learning models using R. Thanks to author for writing this book.
Amazon Verified review Amazon
floren25 Jun 28, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Puede resultar chocante, como poco, ver que alguien califica de «entretenido» un libro más bien técnico como éste, pero resulta que el calificativo es bastante apropiado. Lo es porque Brett lantz ha escrito una obra muy bien estructurada y pedagógicamente escrita sobre un tema que a muchos puede resultar intimidatorio, pero que él se las ingenia para volver atractivo.El libro es una introducción amable y facilitada a catorce algoritmos de «Machine Learning» (expresión que suele traducirse al castellano como «aprendizaje automático»), una muestra representativa, aunque desde luego no exhaustiva, de los métodos de Machine Learning en circulación. Los catorce algoritmos cubren desde k-nearest neighbors hasta Random Forests, pasando por Decision trees y Association rules. Los distintos algoritmos (de aprendizaje supervisado, no supervisado y de meta-aprendizaje) cubren cuatro tipos de tareas: clasificar, predecir, detectar patrones y agrupar.Aunque ya tenía noticia de ello, me parece digno de ser resaltado que los algoritmos más potentes, como Artificial Neural Networks o Support Vector Machines, son lo que Lantz llama «algoritmos de caja negra»: sabemos que funcionan bien pero no sabemos por qué funcionan bien.Uno de los problemas frecuentes con este tipo de libros es que hay complementos que tienes que bajar de Internet y que no siempre se comportan como deberían. En este caso, ¡loado sea el cielo!, no es así: las bases de datos y el código escrito en el lenguaje R funcionan sin problemas. Sólo en los tres últimos capítulos me he llevado algún tropezón. Especialmente en el último, que es con diferencia el de contenido más avanzado: computación en la nube, big data y demás.Pero, a pesar de lo que acabo de decir, se aprende mucho con este texto, dado el esmero que pone el autor en explicar todos los detalles (como las líneas de código que pudieran resultar más intrigantes) y en no dejar a nadie atrás.En suma, una excelente iniciación a Machine Learning usando el software R, el más empleado por los estadísticos, aunque no el más común en aprendizaje automático.
Amazon Verified review Amazon
Ashish Tambadkar May 13, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I am a complete beginner to R as well as Machine learning, this book has clearly stated every concept and made me understand machine learning even better. I highly recommend this book
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.