# How Data Visualization Helps in Building the Machine Learning Model

Data visualization is an important tool for building machine learning models. It allows us to easily understand and analyze complex data sets, and to identify patterns and trends that can inform our modeling efforts.

#### Let’s take a look at these benefits of visualization before we jump into examples of visualization :

One of the primary benefits of data visualization is that it allows us to quickly identify relationships between different variables in our data. By visualizing the data, we can see how different variables are correlated with one another, and use this information to inform our modeling efforts.

Another benefit of data visualization is that it can help us to identify potential biases or anomalies in our data. By visualizing the data, we can see if certain groups or variables are underrepresented or overrepresented, and adjust our modeling efforts accordingly.

In addition to these benefits, data visualization can also help us to communicate our findings to others. By creating clear and visually appealing charts and graphs, we can effectively convey our results and insights to a wider audience.

#### We have covered the benefits of visualization, now let’s dive into some of these basic visualization charts :
**1. Distribution Chart**

2. Interquartile (IQR) Boxplot Chart

**Distribution Chart**

A **distribution chart**, also known as a **histogram**, is a visualization tool that is commonly used in machine learning to **understand the distribution of a particular variable in a data set.** It allows us to see **the frequency or number of occurrences of different values within a given range**, and can help us to i**dentify patterns** and **trends **in the data.

To create a distribution chart, we first need to divide the range of values for the variable into a series of bins or intervals. For example, if we are visualizing the age of a group of people, we might divide the range of ages into bins such as 0-10, 11-20, 21-30, etc. We can then count the number of occurrences of each value within each bin and plot this data on the chart.

The resulting chart will show the distribution of the variable in the data set. For example, if we are visualizing the age of a group of people, the chart might show that the majority of people are between the ages of 20 and 30, with a smaller number of people in the other age ranges.

Distribution charts are useful for machine learning because **they allow us to understand the distribution of variables in our data** and** identify any potential issues or anomalies.** For example, if we see that the **distribution of a particular variable is skewed or not evenly distributed,** this might indicate that we need to take certain steps to correct or adjust the data before building a machine learning model.

**Interquartile (IQR) Boxplot**

**A boxplot**, also known as a **box **and **whisker **plot, is a visualization tool that is commonly used in machine learning to understand **the distribution of a particular variable in a data set.** It is particularly useful for i**dentifying outliers **and the **skewness of the data**.

To create a boxplot, we first need to calculate the interquartile range (IQR) of the variable. The IQR is the range of values that falls between the first and third quartiles, or 25th and 75th percentiles, of the data. The first quartile, or Q1, is the value that divides the lowest 25% of the data from the rest, while the third quartile, or Q3, is the value that divides the highest 25% of the data from the rest.

The boxplot is then created by plotting a box from Q1 to Q3, and adding horizontal lines, or whiskers, to the plot that extend to the minimum and maximum values in the data set (excluding any outliers). **Outliers are values that fall outside of the range defined by Q1-1.5IQR and Q3+1.5IQR.**

The resulting chart shows the distribution of the variable in the data set, including the **median value** (the middle value in the data set), **the range of values** within the interquartile range, and **any outliers.**

Boxplots are useful for machine learning because they allow us to **quickly and easily identify outliers** and **understand the skewness of the data**. For example, if we see that the boxplot for a particular variable is heavily skewed to one side, this might indicate that we need to take certain steps to correct or adjust the data before building a machine learning model.

**In conclusion,** data visualization is a crucial tool for building machine learning models. It allows us to easily understand and analyze complex data sets, identify patterns and trends, and communicate our findings to others. Some examples of how data visualization can be used in building machine learning models include identifying relationships between variables, identifying biases or anomalies in the data, and conveying results and insights to a wider audience. By leveraging the power of data visualization, we can create more accurate and effective machine learning models that drive business insights and decision-making.