MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to find quantile and quartiles in R?

# How to find quantile and quartiles in R?

This recipe helps you find quantile and quartiles in R

Exploratory Data Analysis is a crucial step before building any machine learning model on a dataset. This also includes gathering statistical inferences from the data. There are a few main terms in stats which describes the variability of the numeric variable. These include IQR, quartiles, quantiles, mean and median. They help us to detect any outliers in the column and the distribution of the column.

This recipe focuses on finding quartile and quantile of the column.

Quantile and Quartile gives the measure of variabilty in the data. Quantiles provides a way to divide the numbers of a given distribution in equal subgroups after sorting the data. Quartiles are the three points in the dataset which divides the number of observations into four equal subgroups.

```
# Data manipulation package
library(tidyverse)
# reading a dataset
customer_seg = read.csv('Mall_Customers.csv')
glimpse(customer_seg)
```

Rows: 200 Columns: 5 $ CustomerID1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1... $ Gender Male, Male, Female, Female, Female, Female, ... $ Age 19, 21, 20, 23, 31, 22, 35, 23, 64, 30, 67, ... $ Annual.Income..k.. 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 19, ... $ Spending.Score..1.100. 39, 81, 6, 77, 40, 76, 6, 94, 3, 72, 14, 99,... Dataset description: It is the basic data about the customers going to the supermarket mall. The variable that we interested in finding the Quantiles and Quartiles of is Annual.Income.

We use the quantile() function to do the task. Let's get the 30th Quantile value of column Annual Income

```
# prob argument represent the nth percentile. In this case it's the 30th percentile.
quantile(customer_seg$Annual.Income..k.., probs = 0.30)
```

30%: 46

We use the quantile() function to do the same task. This time the probs = 25%, 50%, 75%.

```
quantile(customer_seg$Annual.Income..k.., prob = c(0.25,0.50, 0.75))
```

25% 41.5 50% 61.5 75% 78

We use the summary() function to calculate the mean, median and other statistical terms of the column

```
summary(customer_seg$Annual.Income..k..)
```

Min. 1st Qu. Median Mean 3rd Qu. Max.
15.00 41.50 61.50 60.56 78.00 137.00
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

In this loan prediction project you will build predictive models in Python using H2O.ai to predict if an applicant is able to repay the loan or not.

In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

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

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, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.