text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import plotly.graph_objs as go

import plotly.offline as py

import seaborn as sns

a = pd.read_csv('/kaggle/input/abalone-dataset/abalone.csv')
a

a.shape

a.describe

a.dtypes

a.isna().sum()

a['age'] = a['Rings'] + 1.5
a.drop('Rings', axis=1, inplace=True)

fig, ((ax1, ax2, ax3, ax4), (ax5, ax6, ax7, ax8)) = plt.subplots(nrows= 2, ncols = 4, figsize = (25,20))
sns.boxplot(ax = ax1, y = 'Length', data = a, color = 'green')
sns.boxplot(ax = ax2, y = 'Diameter', data = a, color = 'red')
sns.boxplot(ax = ax3, y = 'Height', data = a, color = 'limegreen')
sns.boxplot(ax = ax4, y = 'Whole weight', data = a, color = 'cyan')
sns.boxplot(ax = ax5, y = 'Shucked weight', data = a, color = 'salmon')
sns.boxplot(ax = ax6, y = 'Viscera weight', data = a, color = 'mediumorchid')
sns.boxplot(ax = ax7, y = 'Shell weight', data = a, color = 'lime')
sns.boxplot(ax = ax8, y = 'age', data = a, color = 'plum')

a1 = a.copy()
a2 = a.copy()
a3 = a.copy()
a_m = a1[a1['Sex'] == 'M']
a_m.drop('Sex', axis=1, inplace=True)
a_f = a2[a2['Sex'] == 'F']
a_f.drop('Sex', axis=1, inplace=True)
a_i = a3[a3['Sex'] == 'I']
a_i.drop('Sex', axis=1, inplace=True)
a_m.drop(['age'], axis=1, inplace=True)
a_f.drop(['age'], axis=1, inplace=True)
a_i.drop(['age'], axis=1, inplace=True)
a_m = a_m.mean()
a_f = a_f.mean()
a_i = a_i.mean()
trace1 = go.Bar(x=a_m.index[::-1], y=a_m.values[::-1], name='M', marker=dict(color='cyan'))
trace2 = go.Bar(x=a_f.index[::-1], y=a_f.values[::-1], name='F', marker=dict(color='violet'))
trace3 = go.Bar(x=a_i.index[::-1], y=a_i.values[::-1], name='I', marker=dict(color='lightsteelblue'))
data = [trace1, trace2, trace3]
layout = go.Layout(title='Feature Distribution', width=800)
fig = go.Figure(data=data, layout=layout)

a1 = a.copy()
a2 = a.copy()
a3 = a.copy()
a_m = a1[a1['Sex'] == 'M']
a_m.drop('Sex', axis=1, inplace=True)
a_f = a2[a2['Sex'] == 'F']
a_f.drop('Sex', axis=1, inplace=True)
a_i = a3[a3['Sex'] == 'I']
a_i.drop('Sex', axis=1, inplace=True)
a_m.drop(['Length', 'Diameter', 'Height', 'Whole weight', 'Shucked weight', 'Viscera weight', 'Shell weight'], axis=1, inplace=True)
a_f.drop(['Length', 'Diameter', 'Height', 'Whole weight', 'Shucked weight', 'Viscera weight', 'Shell weight'], axis=1, inplace=True)
a_i.drop(['Length', 'Diameter', 'Height', 'Whole weight', 'Shucked weight', 'Viscera weight', 'Shell weight'], axis=1, inplace=True)
a_m = a_m.mean()
a_f = a_f.mean()
a_i = a_i.mean()
trace1 = go.Bar(x=a_m.index[::-1], y=a_m.values[::-1], name='M', marker=dict(color='limegreen'))
trace2 = go.Bar(x=a_f.index[::-1], y=a_f.values[::-1], name='F', marker=dict(color='olive'))
trace3 = go.Bar(x=a_i.index[::-1], y=a_i.values[::-1], name='I', marker=dict(color='seagreen'))
data = [trace1, trace2, trace3]
layout = go.Layout(title='Feature Distribution', width=800)
fig = go.Figure(data=data, layout=layout)

sns.pairplot(a, hue='Sex', palette='viridis_r')