Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Predictive Analytics with R

You're reading from  Mastering Predictive Analytics with R

Product type Book
Published in Jun 2015
Publisher
ISBN-13 9781783982806
Pages 414 pages
Edition 1st Edition
Languages
Authors (2):
Rui Miguel Forte Rui Miguel Forte
Profile icon Rui Miguel Forte
Rui Miguel Forte Rui Miguel Forte
Profile icon Rui Miguel Forte
View More author details

Table of Contents (19) Chapters

Mastering Predictive Analytics with R
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Gearing Up for Predictive Modeling 2. Linear Regression 3. Logistic Regression 4. Neural Networks 5. Support Vector Machines 6. Tree-based Methods 7. Ensemble Methods 8. Probabilistic Graphical Models 9. Time Series Analysis 10. Topic Modeling 11. Recommendation Systems Index

Simple linear regression


Before looking at some real-world data sets, it is very helpful to try to train a model on artificially generated data. In an artificial scenario such as this, we know what the true output function is beforehand, something that as a rule is not the case when it comes to real-world data. The advantage of performing this exercise is that it gives us a good idea of how our model works under the ideal scenario when all of our assumptions are fully satisfied, and it helps visualize what happens when we have a good linear fit. We'll begin by simulating a simple linear regression model. The following R snippet is used to create a data frame with 100 simulated observations of the following linear model with a single input feature:

Here is the code for the simple linear regression model:

> set.seed(5427395)
> nObs = 100
> x1minrange = 5
> x1maxrange = 25
> x1 = runif(nObs, x1minrange, x1maxrange)
> e = rnorm(nObs, mean = 0, sd = 2.0)
> y = 1.67 * x1 - 2...
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 $15.99/month. Cancel anytime}