#### Overview of this book

This is the go-to book for anyone interested in the steps needed to develop predictive analytics solutions with examples from the world of marketing, healthcare, and retail. We'll get started with a brief history of predictive analytics and learn about different roles and functions people play within a predictive analytics project. Then, we will learn about various ways of installing R along with their pros and cons, combined with a step-by-step installation of RStudio, and a description of the best practices for organizing your projects. On completing the installation, we will begin to acquire the skills necessary to input, clean, and prepare your data for modeling. We will learn the six specific steps needed to implement and successfully deploy a predictive model starting from asking the right questions through model development and ending with deploying your predictive model into production. We will learn why collaboration is important and how agile iterative modeling cycles can increase your chances of developing and deploying the best successful model. We will continue your journey in the cloud by extending your skill set by learning about Databricks and SparkR, which allow you to develop predictive models on vast gigabytes of data.
Title Page
Credits
www.PacktPub.com
Customer Feedback
Preface
Free Chapter
Getting Started with Predictive Analytics
The Modeling Process
Inputting and Exploring Data
Introduction to Regression Algorithms
Introduction to Decision Trees, Clustering, and SVM
Using Survival Analysis to Predict and Analyze Customer Churn
Introduction to Spark Using R
Exploring Large Datasets Using Spark
Spark Machine Learning - Regression and Cluster Models
Spark Models – Rule-Based Learning

## Automating the regressions

Now that we have seen how we can run a single time series regression, we can move on to automating separate regressions and extracting the coefficients over all of the categories.

There are several ways to do this. One way is by using the `do()` function within the `dplyr` package. Here is the sequence of events:

• The data is first grouped by category.
• Then, a linear regression (`lm()` function) is run for each category, with `Year` as the independent variable, and `Not.Covered` as the dependent variable. This is all wrapped within a do() function.
• The coefficient is extracted from the model. The coefficient will act as a proxy for the direction and magnitude of the trend.
• Finally, a dataframe of lists is created (`fitted.models`), where the coefficients and intercepts are stored for each regression run on every category. The categories that have the highest positive coefficients exhibit the greatest increasing linear trend, while the declining trend is indicated by negative coefficients...