text_plain_output_1.png
from scipy.io import arff

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

from scipy.io import arff
data = arff.loadarff('../input/dry-bean-dataset/Dry_Bean_Dataset.arff')
df = pd.DataFrame(data[0])

df.isnull().sum()

df.corr()

fig, ax = plt.subplots(4,2, figsize=(20,20))
sns.distplot(df.Area, bins = 40, ax=ax[0,0]) 
sns.distplot(df.Perimeter, bins = 40, ax=ax[0,1]) 
sns.distplot(df.Eccentricity, bins = 40, ax=ax[1,0]) 
sns.distplot(df.roundness, bins = 40, ax=ax[1,1]) 
sns.distplot(df.ConvexArea, bins = 40, ax=ax[2,0])
sns.distplot(df.Extent, bins = 40, ax=ax[2,1])
sns.distplot(df.Solidity, bins = 40, ax=ax[3,0])
sns.distplot(df.roundness, bins = 40, ax=ax[3,1])

# Check for outliers
fig, ax = plt.subplots(4,2, figsize=(20,20))
sns.boxplot(df.Area, ax=ax[0,0]) 
sns.boxplot(df.Perimeter, ax=ax[0,1]) 
sns.boxplot(df.Eccentricity, ax=ax[1,0]) 
sns.boxplot(df.roundness, ax=ax[1,1]) 
sns.boxplot(df.ConvexArea, ax=ax[2,0])
sns.boxplot(df.Extent, ax=ax[2,1])
sns.boxplot(df.Solidity, ax=ax[3,0])
sns.boxplot(df.roundness, ax=ax[3,1])

df_without_outliers = df.copy()
Q1 = df_without_outliers.quantile(q=0.25)
Q3 = df_without_outliers.quantile(q=0.75)
IQR = Q3 - Q1
df_without_outliers = df_without_outliers[~((df_without_outliers < Q1 - 1.5 * IQR) | (df_without_outliers > Q3 + 1.5 * IQR)).any(axis=1)]
round((df.shape[0] - df_without_outliers.shape[0]) * 100 / df.shape[0])