Machine Learning Prior Part 1 & Data Visualization
Last Updated on January 8, 2023 by Editorial Team
Author(s): Gencay I.
Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.
Machine Learning Prior Part 1 & DataVisualization
Matplotlib & Seaborn Briefly Explained andΒ Compared
Content Table
Β· Introduction
Β· Line Graph
β Matplotlib
β Seaborn
β Animated Line Graph
Β· Histogram
β Matplotlib
β Seaborn
Β· Scatter Graph
β Matplotlib
β Seaborn
Β· Violin Graph
β Matplotlib
β Seaborn
Β· Conclusion
Introduction
Hi toΒ all.
In my Machine learning series, I try to explain to you guys the logic behind Machine Learning.
As it is obvious and I always say, Machine Learning is the combination of different cultures.
MainlyΒ ;
- Statistics
- Programming
- Calculus
In the following articles, I explain most of the Statistical terms used in Machine Learning.
Now in that brief course, I try to explain to you guys the coding process of machine learning inΒ Python.
In Python, I divide the process intoΒ four.
- Data Visualization- Matplotlib &Β Seaborn
- Data Analytics- Pandas
- Getting familiar with Data Types-Numpy
- Building Models- Scikit-learn
Also, I divide model types into three, which areΒ ;
- Regression
- Classification
- Clustering
A clustering article is on theΒ way*
Now, data visualization and chart types can really vary, but I decided to explain the most common ones to you because that is a brief explanation article.
And also I will code this graph in Matplotlib and Seaborn, which are the most common visualization tools inΒ Python.
Line Graph
The line graph is used to observe changes, most commonly, inΒ time.
Matplotlib
First, download the data by loading and seaborn and use the load_dataset method.
Then drop the categorical column and draw a graph accordingly.
Seaborn
Like in the latterΒ code,
- Download the data by loading andΒ seaborn
- Load_dataset method, drop the categorical columnΒ and
- Draw a line graph accordingly by selecting x andΒ y.
- For more
Animated LineΒ Graph
Also if you would like to see an animatedΒ graph;
- Load the libraries
- Sort theΒ values
- Set the size of the number of png, that will create your animated line graphβsΒ gif.
- Write aΒ loop.
- Save yourΒ gif.
Histogram
The important graph to look density and distribution ofΒ data.
Matplotlib
Now let's explain step byΒ step
- Download and load theΒ data
- Define fig andΒ ax.
- Define the histogram and theΒ column.
- Set title, x and yΒ label
- Define the threshold, and draw the line accordingly.
- For more arguments.
Seaborn
Here is the source of distplot.
- Import library.
- Load dataΒ set
- Define the columnΒ name
- kde- draw gaussian kernel density orΒ not.
- bins- histogram binsΒ width
Scatter Graph
To see data points as a literal points, a scatter graph is a useful graphΒ type.
Matplotlib
- Download necessary libraries and dataΒ set.
- Set a title and gridΒ option
- For more about scatter plots in matplotlib.
Seaborn
Violin Graph
Here is the quick sum of the violinΒ graph.
Matplotlib
- Load libraries and downloadΒ data
- Select the iris sepal length column andΒ observe.
- For more.
Seaborn
- Import Seaborn and dataΒ set.
- Select the first 100 columns to compare setosa and versicolor.
- Select sepal and petalΒ length.
- For more.
Conclusion
Now as you can see there are a lot of different ways to visualize yourΒ data.
Data visualization is an important step of the ETL process in Machine Learning.
It helps you to see, sometimes the distribution of the data, and outliers and gives you insight into theΒ data.
Actually, it speaks to you in a different language and knowing that language better, helps you to be a real machine in Machine Learning.
βMachine learning is the last invention that humanity will ever need to make.β NickΒ Bostrom
Machine Learning Prior Part 1 & Data Visualization was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Join thousands of data leaders on the AI newsletter. Itβs free, we donβt spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI