MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to make a violinplot in matplotlib example 2?

# How to make a violinplot in matplotlib example 2?

This recipe helps you make a violinplot in matplotlib example 2

Violin plots are similar to boxplots which showcases the probability density along with interquartile, median and range at different values. They are more informative than boxplots which are used to showcase the full distribution of the data. They are also known to combine the features of histogram and boxplots.

They are mainly used to compare the distribution of different variables/columns in the dataset. There are different libraries used to plot this chart. The basic library that we can use is Matplotlib.

This recipe demonstrates how to make a violin plot using matplotlib

```
# importing matplotlib
import matplotlib.pyplot as plt
# importing numpy library to get 2 samples of normal distributions
import numpy as np
```

We use np.random.normal(size = n) function to get the normal distribution array of size "n"

```
x = np.random.normal(size = 1000)
# normal distribution with mean 10 and standard deviation 5
y = np.random.normal(10, 5, size = 1000)
# creating a list of arrays for comparison in the later step
l = [x, y]
```

We use violinplot() function to plot the chart.

Syntax: violinplot(dataset, showmeans=False, showextrema=True, showmedians=False, quantiles=None)

- dataset = (input data) vector or list of arrays ;
- showmeans: (optional) If True, will display means. ;
- showextrema:(optional) If True, will display extremas. ;
- showmedians: (optional) If True, will display medians
- quantiles: (optional) If not None, set a list of floats in interval [0, 1]

```
# Create a figure instance
fig = plt.figure()
# Create an axes instance
ax = fig.add_axes([0,0,1,1])
# Create the boxplot
bp = ax.violinplot(l, showmeans = True , showmedians = True, quantiles = [[0.25,0.75],[0.25,0.75]])
# Giving a title to the plot
plt.title("Violin Plot")
# Showcasing the plot
plt.show()
```

This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

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

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.

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 Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.

There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

In this project, we are going to work on Deep Learning using H2O to predict Census income.