MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to visualise regression analysis in R?

# How to visualise regression analysis in R?

This recipe helps you to visualise a regression analysis in R using ggplot()

This recipe uses the ggplot () package in R to visualize the output of a regression analysis. This visualization combines a regression line with confidence intervals and prediction intervals.

**What is Regression Analysis ?**

Regression analysis is a statistical technique used to find the relationship between 2 or more variables. It is used in business to understand what factors impact a specific outcome. Regression allows you to determine which factors matter most, which factors can be ignored, and how these factors influence each other. In order to conduct a regression analysis, you'll need to define a dependent variable that you hypothesize is being influenced by one or several independent variables.

**What is R ?**

R is a programming language used for statistics and data science computing. R has very powerful libraries (almost 12,000) for performing data analytics including regression, classification, visualisation etc.

In [ ]:

```
# --------------------------------------------------------------
# Regression Analysis in R - How to visualise predict() function
# --------------------------------------------------------------
# load libraries
library(mlbench)
library(gridExtra)
library(ggpubr)
# Visualise prediction with CI and PI
# 1. Build linear model
data("cars", package = "datasets")
model <- lm(dist ~ speed, data = cars)
# 2. Add predictions
pred.int <- predict(model, interval = "prediction")
mydata <- cbind(cars, pred.int)
# 3. Regression line + confidence intervals
library("ggplot2")
p1 <- ggplot(mydata, aes(speed, dist)) +
geom_point() +
stat_smooth(method = lm)
# 4. Add prediction intervals
p2 <- p1 + geom_line(aes(y = lwr), color = "red", linetype = "dashed")+
geom_line(aes(y = upr), color = "red", linetype = "dashed")
# plot
grid.arrange(p1,p2, nrow=1)
```

In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.