In the case of a real-world dataset, it is very common that some values in the dataset are missing. We represent these missing values as NaN (Not a Number) values. But to build a good machine learning model our dataset should be complete. That’s why we use some imputation techniques to replace the NaN values with some probable values. But before doing that we need to have a good understanding of how the NaN values are distributed in our dataset.
Missingno library offers a very nice way to visualize the distribution of NaN values. Missingno is a Python library and compatible with Pandas.
Install the library –
pip install missingno
To get the dataset used in the code, click here.
Using this matrix you can very quickly find the pattern of missingness in the dataset. In our example, the columns
SulphidityL-4 have a similar pattern of missing values while UCZAA shows a different pattern.
Bar Chart :
This bar chart gives you an idea about how many missing values are there in each column. In our example,
SulphidityL-4 contain the most number of missing values followed by UCZAA.
Heatmap shows the correlation of missingness between every 2 columns. In our example, the correlation between AAWhiteSt-4 and SulphidityL-4 is 1 which means if one of them is present then the other one must be present.
A value near -1 means if one variable appears then the other variable is very likely to be missing.
A value near 0 means there is no dependence between the occurrence of missing values of two variables.
A value near 1 means if one variable appears then the other variable is very likely to be present.
Reference : https://github.com/ResidentMario/missingno
- Python | Find missing and additional values in two lists
- Python - Remove duplicate values across Dictionary Values
- Python - Test for Even values dictionary values lists
- Python - Extract Unique values dictionary values
- Python - Extract values of Particular Key in Nested Values
- ML | Handling Missing Values
- Count NaN or missing values in Pandas DataFrame
- Drop rows from Pandas dataframe with missing values or NaN in columns
- Mapping external values to dataframe values in Pandas
- Python - Extract ith column values from jth column values
- Python - Dictionary Values Mean
- Python - Values frequencies of key
- Python | Segregating Key's Values
- Python dictionary | values()
- Python - Keys associated with Values in Dictionary
- Python | Even values update in dictionary
- Python | Pandas Index.values
- Python - Unique values Multiplication
- Python - False values Frequency
- Python | Pandas Series.values